diff options
| author | delusionalai <delusionalai@users.noreply.git.jnsn.dev> | 2026-11-16 22:17:39 +0000 |
|---|---|---|
| committer | delusionalai <delusionalai@users.noreply.git.jnsn.dev> | 2026-11-16 22:17:39 +0000 |
| commit | f3070d9751736de12f72038f6d4a558c68cf63f0 (patch) | |
| tree | 84d8eb7bb2a575221f23eae219653182fc49b1f2 | |
| parent | f2fd518c16eec93bebc846db9341ee5831a41bed (diff) | |
| download | devbox-ai/podman-minimal.tar.gz devbox-ai/podman-minimal.zip | |
login.sh: drop to dev with exec instead of running su and falling through to a root shellai/podman-minimal
`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 <pi@pi.dev>
| -rw-r--r-- | login.sh | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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 |
