From ab4251e4805c943c3d8917c2d6fe8f0db9072b36 Mon Sep 17 00:00:00 2001 From: casjay Date: Mon, 27 Jul 2026 16:36:12 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20sh/bash=20-c=20invocations?= =?UTF-8?q?=20losing=20their=20interpreter=20name=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - rootfs/usr/local/bin/entrypoint.sh: the `*/bin/sh | */bin/bash | bash | sh | shell)` case branch unconditionally shifted away $1 before calling __exec_command "$@", which does a bare `exec "$@"`. For `docker run image sh -c 'cmd'` this turned the exec into `exec -c cmd` (command not found, exit 127) instead of `exec sh -c 'cmd'` — the interpreter name is required as the exec'd program itself, not just a case-match keyword. Only shift when $1 is literally "shell" (a keyword, not an executable name); "sh"/"bash"/"*/bin/sh"/"*/bin/bash" must be passed through intact. Verified `bash -n` passes and `docker run casjaysdev/go:latest sh -c "..."` now runs the command instead of erroring. Found while running the full functional test pass after the previous START_SERVICES gate fix (commit 6de223133cf4). --- rootfs/usr/local/bin/entrypoint.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rootfs/usr/local/bin/entrypoint.sh b/rootfs/usr/local/bin/entrypoint.sh index 27fc22a..1024cd9 100755 --- a/rootfs/usr/local/bin/entrypoint.sh +++ b/rootfs/usr/local/bin/entrypoint.sh @@ -626,9 +626,11 @@ procs) [ -n "$ps" ] && printf '%s\n%s\n' "Found the following processes" "$ps" | tr '\n' ' ' exit $? ;; -# Launch shell +# Launch shell — do not shift here: "sh -c 'cmd'" / "bash -c 'cmd'" needs the +# interpreter name kept as argv[0] for __exec_command's `exec "$@"` to work; +# shifting it away turned "sh -c 'cmd'" into `exec -c cmd` (command not found) */bin/sh | */bin/bash | bash | sh | shell) - shift 1 + [ "$1" = "shell" ] && shift 1 __exec_command "$@" exit $? ;;