Skip to content

Commit

Permalink
create container user with no user group
Browse files Browse the repository at this point in the history
This issue was reported in #123, where @miellaby wrote:

> Context: Using cqfd from a host user (jenkins) who has no user
> group. For example, on our server, jenkins belongs to the docker group
> only (which is its primary group).
>
> Expected: commands run by cqfd inherits the credentials/ownership of
> the host user. Especially files generated by cqfd encapsulated
> commands have the same user and group than the files generated without
> cqfd. In our case, generated files should be owned by
> jenkins:docker (user jenkings group docker).
>
> Observed: files generated within cqfd are owned by jenkins:jenkins
> instead of jenkins:docker.
>
> Correction proposal (TBC): In make_launch() bash function, useradd
> should be called with the --no-user-group (-N) option to make the
> docker user consistent with the host user (that is with the same
> primary group).
  • Loading branch information
joufellasfl committed Feb 25, 2024
1 parent 0051142 commit 05ad21c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cqfd
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ test_su_session_command && has_su_session_command=1
# Add the host's user and group to the container, and adjust ownership.
groupadd -og $GROUPS -f builders || die "groupadd command failed."
useradd -s /bin/sh -ou $UID -g $GROUPS -d "$cqfd_user_home" $cqfd_user \
useradd -s /bin/sh -oN -u $UID -g $GROUPS -d "$cqfd_user_home" $cqfd_user \
|| die "useradd command failed."
mkdir -p "$cqfd_user_home" || die "mkdir command failed."
chown $UID:$GROUPS "$cqfd_user_home" || die "chown command failed."
Expand Down

0 comments on commit 05ad21c

Please sign in to comment.