mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-21 17:52:12 +03:00
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:
+1
-1
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user