Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run: block PODMAN_USERNS and --pod #18601

Merged

Conversation

giuseppe
Copy link
Member

@giuseppe giuseppe commented May 17, 2023

the combination --pod and --userns is already blocked. The PODMAN_USERNS environment variable instead circumvents the check. Make sure the combination is also blocked, otherwise we end up creating containers in a different user namespace than their pod.

Ideally a container should be able to do that, but its user namespace must be a child of the pod user namespace, not a sibling. Since nested user namespaces are not allowed in the OCI runtime specs, disallow this case, since the end result is just confusing for the user.

Closes: #18580

Does this PR introduce a user-facing change?

Now PODMAN_USERNS is ignored if --pod is specified

@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 17, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giuseppe

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 17, 2023
@Luap99
Copy link
Member

Luap99 commented May 17, 2023

Would it make more sense to ignore the env when the pod already has the same userns mode? Consider the case where someone might set it in their bashrc. It would be very annoying to unset the env for all podman run/create commands and you know the pod has already the specified userns mode anyway.

@giuseppe giuseppe force-pushed the block-PODMAN_USERNS-and---pod branch from 74f624e to 471baf7 Compare May 17, 2023 13:37
@giuseppe
Copy link
Member Author

Would it make more sense to ignore the env when the pod already has the same userns mode? Consider the case where someone might set it in their bashrc. It would be very annoying to unset the env for all podman run/create commands and you know the pod has already the specified userns mode anyway.

I thought about it but I wasn't sure what was better, if blocking or ignoring it; but you made a good point, it will start causing weird errors and failures now, so let's just ignore

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

LGTM, just one thing, should we mention that in the man page?

@baude
Copy link
Member

baude commented May 17, 2023

LGTM, just one thing, should we mention that in the man page?

i think this is a good idea. everything else LGTM

@rhatdan
Copy link
Member

rhatdan commented May 17, 2023

/lgtm
/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 17, 2023
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 17, 2023
the combination --pod and --userns is already blocked.  Ignore the
PODMAN_USERNS variable when a pod is used, since it would cause to
create a new user namespace for the container.

Ideally a container should be able to do that, but its user namespace
must be a child of the pod user namespace, not a sibling.  Since
nested user namespaces are not allowed in the OCI runtime specs,
disallow this case, since the end result is just confusing for the
user.

Closes: containers#18580

Signed-off-by: Giuseppe Scrivano <[email protected]>
@giuseppe giuseppe force-pushed the block-PODMAN_USERNS-and---pod branch from 471baf7 to 192ad70 Compare May 17, 2023 14:49
@giuseppe
Copy link
Member Author

LGTM, just one thing, should we mention that in the man page?

sure, added a note

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label May 17, 2023
@Luap99
Copy link
Member

Luap99 commented May 17, 2023

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 17, 2023
@TomSweeneyRedHat
Copy link
Member

LGTM
/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 17, 2023
@openshift-merge-robot openshift-merge-robot merged commit ae66ad4 into containers:main May 17, 2023
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Aug 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

An error occurred while joining the pod with userns=keep-id
6 participants