-
Notifications
You must be signed in to change notification settings - Fork 232
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
unshare: fix creating a userns when running as root #1415
unshare: fix creating a userns when running as root #1415
Conversation
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.
What is this actually fixing?
Some situation where we are in a user namespace already, one that wasn’t created by this subpackage (no environment variables), we do have CAP_ADMIN (per IsRootless
), but don’t have some other capability?
Something else?
Does that mean that the semantics of IsRootless
is also incorrect and needs updating? (The documentation of IsRootless
says basically nothing, so I have absolutely no idea.)
I’m not saying that this change is incorrect, I’m saying that I have no way to tell, and this might be a good opportunity to actually clarify the semantics.
@@ -464,11 +464,6 @@ func bailOnError(err error, format string, a ...interface{}) { // nolint: golint | |||
|
|||
// MaybeReexecUsingUserNamespace re-exec the process in a new namespace | |||
func MaybeReexecUsingUserNamespace(evenForRoot bool) { |
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.
If this changes the semantics of the function in caller-visible ways, I’d expect that to show up at least in the documentation, if not in the name.
IMHO doc strings should be enough for a caller to understand what the function does (from the caller’s perspective) without needing to read the implementation, and this one is way below that standard.
this check would prevent the function to ever be used when running as root, since we won't check what capabilities are currently available to the process. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
dbc6c4e
to
1af3928
Compare
the issue I've observed is that if we run as root but without CAP_SYS_ADMIN, then the function exits immediately without creating the user namespace as it was asked to do. I've changed the patch so we avoid the additional checks if we an unprivileged user (uid > 0) created the user namespace and we are not already running with euid == 0 |
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.
LGTM Just confirming that this PR does not appears to be functionally changing anything and just avoiding checks for capabilities when it is guaranteed that efffective UID is 0 and this is rootless session.
can we please move this forward? It is needed for buildah inside a container |
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.
LGTM
/lgtm
This change broke my usage of buildah inside container. Before this change:
After this change:
|
@giuseppe WDYT? |
We've discussed that a bit in containers/buildah#4538, but since they're kinda separate issues, I've created containers/buildah#4563 specifically to address regression. |
this check would prevent the function to ever be used when running as root, since we won't check what capabilities are currently available to the process.
Signed-off-by: Giuseppe Scrivano gscrivan@redhat.com