You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Under certain conditions - specifically when the container relies on an implicit root user for each step - the Linux groups added to the root user in the Dockerfile do not apply to an interactive shell session started with podman exec -it ... /bin/sh. This issue also impacts any groups defined in the base image.
I am only able to reproduce this issue when the following conditions are met:
Building from a Dockerfile WITHOUT any USER directive
Podman run the image WITHOUT the --user parameter
Podman exec into the running container WITHOUT the --user parameter
Note: As soon as I add --user or the USER directive at any step I cannot reproduce this issue anymore.
Steps to reproduce the issue
Steps to reproduce the issue
Create a Dockerfile with the following content:
FROM alpine
# for capsh --printRUN apk add libcap
RUN addgroup -S appgroup && \
adduser -S appuser -G appgroup && \
addgroup root appgroup
Build the image
podman build .
Run the container (without the --user parameter).
podman run -itd $IMAGE /bin/sh
Exec into the container (without the --user parameter).
podman exec -it $CONTAINER /bin/sh
Verify that the root user does not have any group memberships in the current shell session:
# In the container
capsh --print | grep groups
Describe the results you received
/ # capsh --print | grep groups
groups=
Describe the results you expected
/ # capsh --print | grep groups
groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),20(dialout),26(tape),27(video),101(appgroup)
I don't understand it, @mheon why do we ignore execUser.Sgids when user is empty? Wouldn't be better if we consider execUser.Sgids everytime sgids is empty?
Commit introducing is #5349 which seems to be aimed at fixing a very similar bug to what was reported here - though I suspect you meant to point at the next line, which goes back even further, to the original introduction of our Conmon-based exec code in #3143 - so the condition appears to have originally been added by Peter around 6 years ago as part of our conversion to Conmon for exec? It looks like it was originally intended that it be unconditional so long as we actually had an execUser but a half-dozen refactorings made that no longer the case.
Anyways, this is a long-winded way of saying that I don't think there is a good reason and it's probably safe to change.
Issue Description
Under certain conditions - specifically when the container relies on an implicit root user for each step - the Linux groups added to the root user in the Dockerfile do not apply to an interactive shell session started with podman exec -it ... /bin/sh. This issue also impacts any groups defined in the base image.
I am only able to reproduce this issue when the following conditions are met:
Note: As soon as I add --user or the USER directive at any step I cannot reproduce this issue anymore.
Steps to reproduce the issue
Steps to reproduce the issue
Describe the results you received
Describe the results you expected
podman info output
Podman in a container
No
Privileged Or Rootless
None
Upstream Latest Release
Yes
Additional environment details
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: