Skip to content

Commit

Permalink
Delete user and group in case of conflicts (#36528)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgn69 authored Nov 19, 2024
1 parent db9d872 commit c39a06f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ RUN apt-get update \
icecc \
&& :

RUN groupadd -g $USER_GID $USERNAME \
RUN (getent passwd $USER_UID && userdel -f $(getent passwd $USER_UID | cut -d: -f1) || true) \
&& (getent group $USER_GID && groupdel -f $(getent group $USER_GID | cut -d: -f1) || true) \
&& (getent passwd $USERNAME && userdel -f $USERNAME || true) \
&& (getent group $USERNAME && groupdel -f $USERNAME || true) \
&& groupadd -g $USER_GID $USERNAME \
&& useradd --no-log-init -s /bin/bash -u $USER_UID -g $USER_GID -G docker,sudo -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
Expand Down

0 comments on commit c39a06f

Please sign in to comment.