rootless-install.sh: use safer XRD on non-systemd hosts

`/tmp/docker-$(id -u)` is not a good candidate as `$XDG_RUNTIME_DIR`,
because it might be already created by another user.

The new path is `$HOME/.docker/run`.

This commit does not affect systemd-based hosts.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
Akihiro Suda committed 2020-06-17 12:11:26 +09:00
1 parent 3d1b8a87b3
commit ebbfa9e2c9
1 file changed
+3 -2
+3 -2
View File
@@ -101,8 +101,8 @@ checks() {
>&2 echo "- or simply log back in as the desired unprivileged user (ssh works for remote machines)"
exit 1
fi
export XDG_RUNTIME_DIR="/tmp/docker-$(id -u)"
mkdir -p "$XDG_RUNTIME_DIR"
export XDG_RUNTIME_DIR="$HOME/.docker/run"
mkdir -p -m 700 "$XDG_RUNTIME_DIR"
XDG_RUNTIME_DIR_CREATED=1
fi
@@ -307,6 +307,7 @@ print_instructions() {
echo "# Make sure the following environment variables are set (or add them to ~/.bashrc):\n"
if [ -n "$XDG_RUNTIME_DIR_CREATED" ]; then
echo "# WARN: systemd not found. You have to remove XDG_RUNTIME_DIR manually on every logout."
echo "export XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR"
fi