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

Prohibit --uid/gid map and --pod for container create/run #12849

Merged
merged 1 commit into from
Jan 14, 2022

Conversation

cdoern
Copy link
Contributor

@cdoern cdoern commented Jan 13, 2022

add a check in namespaceOptions() that ensures the user is not setting a new uid/gid map
if entering or creating a pod that has an infra container

resolves #12669

Signed-off-by: cdoern cdoern@redhat.com

@cdoern cdoern requested a review from rhatdan January 13, 2022 15:45
@mheon
Copy link
Member

mheon commented Jan 13, 2022

Should we add a note to the manpages about this?

@mheon
Copy link
Member

mheon commented Jan 13, 2022

Otherwise LGTM

@cdoern
Copy link
Contributor Author

cdoern commented Jan 13, 2022

sure @mheon do you think it should go in both podman run and podman create?

@mheon
Copy link
Member

mheon commented Jan 13, 2022

Yeah, we usually mirror contents of those manpages very closely

@Luap99
Copy link
Member

Luap99 commented Jan 13, 2022

But why do we forbid it if it works?

@cdoern
Copy link
Contributor Author

cdoern commented Jan 13, 2022

@Luap99 sharing of namespaces within a pod makes it so that the uid/gid maps should be on the pod level not overwritten by the container: #12669 (comment)

@rhatdan
Copy link
Member

rhatdan commented Jan 13, 2022

LGTM

@rhatdan
Copy link
Member

rhatdan commented Jan 13, 2022

/approve
/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 Jan 13, 2022
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 13, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 13, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cdoern, rhatdan

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 Jan 13, 2022
@Luap99
Copy link
Member

Luap99 commented Jan 13, 2022

But why? This clearly works just fine right now. This will be a breaking change for may users since uidmapping didn't work on pod earlier so I assume that there are people using podman run --uidmap with --pod. Also what if I want a different uidmapping for all containers in a pod?

@cdoern
Copy link
Contributor Author

cdoern commented Jan 13, 2022

@Luap99 that kind of defies the entire ways that pods and namespaces are supposed to work, if we allow for overwriting this flag then people will assume the same works for other flags that involve namespaces, which it doesn't. Take sysctls for example: #12836 we want things involving namespaces to be defined on the pod level and pod level only.

@Luap99
Copy link
Member

Luap99 commented Jan 13, 2022

OK but then this check needs to check if the pod has a infra bacause if you use a pod without infra this should still be allowed since there are no shared namespaces in this case. Also the check should be in specgen to also cover api users

@cdoern
Copy link
Contributor Author

cdoern commented Jan 13, 2022

@Luap99, can't do the check after FillOutSpecGen because that function autofills IDMappings if none are provided. I will throw a check in pkg/api/handlers/libpod when the specgen gets decoded. Will also add another check in validate() for if the pod we are entering has an infra container.

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jan 13, 2022
@cdoern
Copy link
Contributor Author

cdoern commented Jan 13, 2022

@Luap99 @rhatdan placed the check in specgen so that the change applies to remote and api users as well.

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 two small nits

pkg/specgen/generate/namespaces.go Outdated Show resolved Hide resolved
test/e2e/create_test.go Show resolved Hide resolved
@cdoern
Copy link
Contributor Author

cdoern commented Jan 13, 2022

added the test changes, sorry I didn't see you did the capitalization changed as well @Luap99

@cdoern
Copy link
Contributor Author

cdoern commented Jan 13, 2022

the tests had an issue because I used the same pod name. looks good now @rhatdan @Luap99

add a check in namespaceOptions() that ensures the user is not setting a new uid/gid map
if entering or creating a pod that has an infra container

resolves containers#12669

Signed-off-by: cdoern <cdoern@redhat.com>
@rhatdan
Copy link
Member

rhatdan commented Jan 13, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 13, 2022
@rhatdan
Copy link
Member

rhatdan commented Jan 14, 2022

/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 Jan 14, 2022
@openshift-merge-robot openshift-merge-robot merged commit 482e0b1 into containers:main Jan 14, 2022
@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 Sep 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Podman rootless container with --uidmap and --pod cannot bind to ports below 1024
5 participants