1
Fork 0

fix: lookup user by name, not id

Previously, the `id -u $LOCAL_USER_ID` check would succeed, because there was already a user mapped to the $LOCAL_USER_ID with a different name.

Looking up the entry in the database by name, however, correctly makes the `useradd` operation idempotent. An alternative fix would be to avoid duplicating an already-existing-ID, however that would require either probing for an available ID or identifying where LOCAL_USER_ID is being set and changing it to better match the ubuntu base image, neither of which is a one-line change.
This commit is contained in:
sethp 2023-07-31 11:13:44 -07:00 committed by GitHub
parent 912dacb658
commit fff66a954c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,7 +8,7 @@ fi
if [ "$NO_CHANGE_USER" = "" ]; then
if [ "$LOCAL_USER_ID" != "" ]; then
id -u $LOCAL_USER_ID &>/dev/null || useradd --shell /bin/bash -u $LOCAL_USER_ID -o -c "" -m user
id -u user &>/dev/null || useradd --shell /bin/bash -u $LOCAL_USER_ID -o -c "" -m user
export HOME=/home/user
unset LOCAL_USER_ID