Skip to content

Commit 155cbf4

Browse files
author
Brendan DeBeasi
committed
fix: use exact match for USER_NAME in /etc/passwd check
The grep pattern `^${USER_NAME}` incorrectly matches usernames that are prefixes of existing users. For example, USER_NAME=b matches the 'bin' user, causing the container to halt with a false positive. Adding a colon after USER_NAME ensures exact username matching: `^${USER_NAME}:` only matches the exact username field. closes #118
1 parent 3923d9a commit 155cbf4

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • root/etc/s6-overlay/s6-rc.d/init-adduser

root/etc/s6-overlay/s6-rc.d/init-adduser/run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/with-contenv bash
22
# shellcheck shell=bash
33

4-
if [[ ! -f "/usermod.done" ]] && [[ -n "${USER_NAME}" ]] && [[ "${USER_NAME}" != "abc" ]] && grep -q "^${USER_NAME}" /etc/passwd; then
4+
if [[ ! -f "/usermod.done" ]] && [[ -n "${USER_NAME}" ]] && [[ "${USER_NAME}" != "abc" ]] && grep -q "^${USER_NAME}:" /etc/passwd; then
55
echo "*** USER_NAME cannot be set to an user that already exists in /etc/passwd. Halting init. ***"
66
sleep infinity
77
else

0 commit comments

Comments
 (0)