Open Syquel opened 1 year ago
Hi @Syquel , It seems there is question unanswered in original discussion, could you continue discussion there before opening a issue. If there is a consensus in discussion that this is a bug, then please feel free to re-open.
I converted the discussion to an issue because I am sure that this behavior is not intended.
I don't see any relevant open questions in the discussion only one which asked something which I extensively described at the beginning of the discussion.
@Syquel Sure we can reopen this issue, i saw this question un-answered https://github.com/containers/buildah/discussions/5053#discussioncomment-7047374
A friendly reminder that this issue had no activity for 30 days.
Had some time to dig further through the source code.
Buildah calls unshare.MaybeReexecUsingUserNamespace(true)
:
https://github.com/containers/buildah/blob/540a73296f945aacbfaed40fa98e2fe86c7e52ac/cmd/buildah/unshare.go#L106C10-L106C39
This method is defined in containers/storage
:
https://github.com/containers/storage/blob/91725e06f6f8eb4d1115fba7348c2e9b03874225/pkg/unshare/unshare_linux.go#L475
Re-exec and appending of -in-a-user-namespace
to the command name occur here:
https://github.com/containers/storage/blob/91725e06f6f8eb4d1115fba7348c2e9b03874225/pkg/unshare/unshare_linux.go#L549
There are only two points where this method returns without re-execing the current executable:
os.Geteuid() == 0
) and the UID in the parent user namespace is not root (GetRootlessUID() > 0
).uidNum == 0
), the evenForRoot
flag is not set and we have the capability CAP_SYS_ADMIN.evenForRoot
flag to true
, when calling unshare.MaybeReexecUsingUserNamespace(true)
.So the issue seems to be that there is a recursive loop of buildah unshare
calling unshare.MaybeReexecUsingUserNamespace(true)
calling buildah unshare
again without any applicable terminating condition.
I am not sure what the correct fix would be but I see the following possibilities:
evenForRoot
flag unconditionally, but based on the result of unshare.isRootless()
:_CONTAINERS_USERNS_CONFIGURED
:_CONTAINERS_USERNS_CONFIGURED
in unshare.MaybeReexecUsingUserNamespace(bool)
:The third option seems to be the most clean solution, but I have no idea whether that would impact other use cases.
Discussed in https://github.com/containers/buildah/discussions/5053