From f3070d9751736de12f72038f6d4a558c68cf63f0 Mon Sep 17 00:00:00 2001 From: delusionalai Date: Mon, 16 Nov 2026 22:17:39 +0000 Subject: login.sh: drop to dev with exec instead of running su and falling through to a root shell `su dev` starts a shell as dev, and when that shell exits the script carries on to `exec /bin/bash` - as root. So logging out of the devbox did not stop the container, it dropped you into a second, privileged shell: old: su dev; exec id -un -> root new: exec runuser -u dev -> dev runuser rather than su because this is exactly its job: root to a named user, no password prompt, no login shell. `su - dev` would also have cd'd to /home/dev and thrown away WORKDIR=/workspace. The environment was not the problem, su sets USER, LOGNAME, HOME and PATH on its own. exec is the other half: the shell replaces the entrypoint instead of being its child, so the container's lifetime is the shell's lifetime and signals reach it directly instead of queueing behind a root script that is waiting on su. Verified the drop happens on both storage paths (native filesystem and loop-mounted ext4) with the stub harness. --- Co-Authored-By: pi --- login.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'login.sh') diff --git a/login.sh b/login.sh index 00d1206..0c1b26a 100644 --- a/login.sh +++ b/login.sh @@ -79,7 +79,11 @@ if [ "$(cat /proc/self/cgroup 2>/dev/null)" = "0::/" ] && [ -w /sys/fs/cgroup ]; chown -R dev:dev /sys/fs/cgroup 2>/dev/null || true fi -su dev +# Everything above needed root; from here on this is the dev user. exec so that +# the shell replaces the entrypoint instead of being a child of it: as it was, +# `su dev` ran a shell whose exit dropped you into a root one, and the container +# only stopped when that second shell exited too. +exec runuser -u dev -- /bin/bash # if [[ -z "${PASEO_PASSWORD:-}" ]]; then # echo "PASEO_PASSWORD is required" >&2 @@ -87,5 +91,4 @@ su dev # fi # echo "[devbox] starting Paseo daemon on ${PASEO_LISTEN} (web UI: ${PASEO_WEB_UI_ENABLED})" -# exec paseo daemon run -exec /bin/bash +# exec runuser -u dev -- paseo daemon run -- cgit v1.2.3