Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/common-utils/main.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @sleiner ,

Thank you for the contribution. Please describe the fix in a detailed manner. Also add test here & to test you can use devcontainer features test command locally in the vscode terminal. Also please do a version bump

Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,16 @@ elif [ "${USERNAME}" = "none" ]; then
USER_UID=0
USER_GID=0
fi

# Create or update a non-root user to match UID/GID.
group_name="${USERNAME}"
group_name=$(getent group "$USER_GID" | cut -d: -f3)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @sleiner

I am not sure if this would really solve the problem you had encountered as you have mentioned. It would probably fail while trying to create a new group for user someone as the gid will be passed on as 1000 which is already existing.

if [ -z "$group_name" ]; then
# Group does not yet exist and will be created. Use the user name as group name.
group_name="${USERNAME}"
fi
if id -u ${USERNAME} > /dev/null 2>&1; then
# User exists, update if needed
if [ "${USER_GID}" != "automatic" ] && [ "$USER_GID" != "$(id -g $USERNAME)" ]; then
group_name="$(id -gn $USERNAME)"
groupmod --gid $USER_GID ${group_name}
usermod --gid $USER_GID $USERNAME
fi
Expand Down