-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
runtime: create userns when CAP_SYS_ADMIN is not present #10079
runtime: create userns when CAP_SYS_ADMIN is not present #10079
Conversation
related: containers/common#499 |
cmd/podman/root.go
Outdated
return err | ||
} | ||
|
||
if !registry.IsRemote() && !hasCapSysAdmin && !found { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same change must be made here
podman/cmd/podman/common/completion.go
Line 46 in 6908557
if !registry.IsRemote() && rootless.IsRootless() { |
pkg/rootless/rootless.go
Outdated
) | ||
|
||
// HasCapSysAdmin returns whether the current process has CAP_SYS_ADMIN. | ||
func HasCapSysAdmin() (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need this in storage/pkg/unshare so that buildah could use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
buildah has already the equivalent check, I'll refactor podman and buildah to use the common code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// by looking up 4294967295 in /proc/self/uid_map. If the mappings would be | ||
// copied as they are, the check in the OCI runtimes would fail. So just split | ||
// it in two different ranges. | ||
if bytes.Contains(content, []byte("4294967295")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cute.
f9028e3
to
8f0b02b
Compare
Concern: a lot of our code is wired to use different paths for rootless, but I think we really only want to do that for non-EUID 0 rootless - root + non SYS_ADMIN can (and IMO should) still use standard Podman paths. |
This would only cause this in rare conditions like podman inside of a container. We will have to study this, and see if it is an issue with using /root/.config/containers rather then /etc/containers ... |
8f0b02b
to
3ec3916
Compare
reworked to use the code from containers/storage |
3ec3916
to
64ccec9
Compare
64ccec9
to
a1e737d
Compare
7b6d113
to
7806c1b
Compare
7806c1b
to
498164e
Compare
Signed-off-by: Giuseppe Scrivano <[email protected]>
tests are green now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small change and then LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: giuseppe, 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 |
@containers/podman-maintainers PTAL |
Would we consider this a breaking change for Podman in a unprivileged container when run as root, given that the paths in use potentially changed? I know this isn't really a supported configuration, but I imagine someone may have figured out how to get it working? I'm not opposed to merging if it is, but we should have release notes and troubleshooting guide ready if so. |
No, because rootfull podman within a container and with overlay is currently broken. and would not work. I see this as more of a bugfix. Basically you can not mount any thing without SYS_ADMIN or a user namespace. So only way to get this to work would be if the users had created a user namepspace for podman to use, and this change would not break that. |
@giuseppe fix my Error->Warn and we can get this merged. |
when creating a user namespace, attempt to create it first by copying the current mappings and then fallback to the other methods: 1) use newidmap tools and ... 2) create a user namespace with a single user mapped. Signed-off-by: Giuseppe Scrivano <[email protected]>
when deciding to create a user namespace, check for CAP_SYS_ADMIN instead of looking at the euid. [NO TESTS NEEDED] Needs nested Podman Signed-off-by: Giuseppe Scrivano <[email protected]>
498164e
to
722ea2f
Compare
fixed and pushed a new version |
LGTM |
@containers/podman-maintainers PTAL |
/lgtm |
when deciding to create a user namespace, check for CAP_SYS_ADMIN instead of looking at the euid.
This is useful for running podman inside podman.
Signed-off-by: Giuseppe Scrivano [email protected]