Skip to content

Commit ebbfa9e

Browse files
committed
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 <[email protected]>
1 parent 3d1b8a8 commit ebbfa9e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

rootless-install.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ checks() {
101101
>&2 echo "- or simply log back in as the desired unprivileged user (ssh works for remote machines)"
102102
exit 1
103103
fi
104-
export XDG_RUNTIME_DIR="/tmp/docker-$(id -u)"
105-
mkdir -p "$XDG_RUNTIME_DIR"
104+
export XDG_RUNTIME_DIR="$HOME/.docker/run"
105+
mkdir -p -m 700 "$XDG_RUNTIME_DIR"
106106
XDG_RUNTIME_DIR_CREATED=1
107107
fi
108108

@@ -307,6 +307,7 @@ print_instructions() {
307307
echo "# Make sure the following environment variables are set (or add them to ~/.bashrc):\n"
308308

309309
if [ -n "$XDG_RUNTIME_DIR_CREATED" ]; then
310+
echo "# WARN: systemd not found. You have to remove XDG_RUNTIME_DIR manually on every logout."
310311
echo "export XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR"
311312
fi
312313

0 commit comments

Comments
 (0)