-
Notifications
You must be signed in to change notification settings - Fork 213
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
s6-overlay-preinit: fatal: unable to chown /var/run/s6: Operation not permitted #309
Comments
Always open for PRs! I think the fix is to try and chown + chmod A hard requirement is we only use tools that ship in the tarball, so you'll need to use |
I have now spent exactly 25 minutes using
|
It would probably be good to run the whole thing in a foreground block, right now this would be introducing the
Only issue here is @skarnet would it make sense for s6-portable-utils to get an |
@jprjr Well it wouldn't really make sense outside of suid binaries. If you want to |
At a minimum we want to check the ownership of I'm not familiar enough with the s6 tools like exceline, but based on the suggestion above, how about something like this..
Unfortunately this does end up depending on I don't think using the UPDATE: changed the check from |
When the image was built on or pulled by a dockerd running with userns-remap the root filesystem will be owned by the remapped UID. When that image is run explicitly in the host's user namespace the ownership of the files on disk will be based on the userns-remapped UIDs. This is generally fine, except where an executable is SUID, in which case, which is the case for the s6-overlay-preinit tool, so we must detect the situation and set the ownership of the relevant tools. See: - just-containers#309 - moby/moby#28986 - https://docs.docker.com/engine/security/userns-remap/#disable-namespace-remapping-for-a-container
This might be similar to the permission issues I get when running docker 20.10 as rootless. |
Are we overcomplicating this? The idea is s6-overlay-preinit should run as root no matter what the Should this just be:
If you're running with |
Thanks for looking at this. Perhaps just doing a blind chown may simplify things. I tried all sorts of variations to the execlineb init script a couple of weeks ago without success, though possibly not a blind chown. It did seem that only changing ownership of The issue isn't about the
When the docker daemon is running as such the pulled images and builds will inherit the remapped UIDs. The problem arises when you run a container on the daemon with the Unfortunately one of the reason it is necessary to run a container in the host user namespace like this is when that container must also be on the host network namespace - i.e. you can't have the host network namespace without the host user namespace. This is the case for the linuxserver/docker-unifi-controller container as it doesn't function correctly behind a NAT. A few weeks ago I did try again to make this all work and after a few hours of tinkering unsuccessfully I fell back to patching the upstream container like this.
|
Right, sorry, I just brought up So what I'm wondering is, it seems like the core issue is - SUID binaries need to have their UID set to 0. I know I got hung up on trying to identify at runtime whether this is running in a userns-remap scenario, and only running |
Good question - I believe it wasn't sufficient, but I will have another go using your proposed approach over the weekend and let you know my findings. |
Tbh it's not surprising that suid binaries don't play nice with user namespaces and uid squashing and whatever mutant Linux feature is at play here. |
@skarnet Thing 1: Thing 2: |
Now that I've written that out, maybe If the euid isn't 0, the |
@jinnko If you could try this build of Here's a Dockerfile that will download, unzip, etc automatically - this is a build of overlay-preinit that only tries to chown the /var/run/s6 folder if the EUID is 0. FROM linuxserver/unifi-controller:latest
RUN apt-get update && apt-get install -y unzip
RUN curl -R -L -o /tmp/dist.zip \
https://nightly.link/just-containers/s6-overlay-preinit/workflows/all/issue-309/dist.zip
RUN cd /tmp && unzip -d dist dist.zip
RUN tar xzf /tmp/dist/s6-overlay-preinit-1.0.4-linux-amd64.tar.gz -C / |
@jprjr The build worked perfectly on a docker daemon running with
Thinking through the various launch scenarios, these are the outcomes I would expect:
I think the 4th scenario would fail currently, and I think it would still fail with the update provided. Having said that this is still a step forward and I'd suggest it's worth rolling with. To give an idea of why it's important to support Thanks for helping solve this - very much appreciated. The specific scenario I hit is resolved so I'm happy with the outcome. I'll leave the decision about closing this issue to you as there's still one more scenario that probably needs attention, but it does seem a bit of an edge case. |
Latest version |
Going to close this out, that fourth use-case is still an issue, I think the only really good workaround for that is to create |
Raising this issue here as I suspect a recent change may have changed the behaviour. Originally raised this in linuxserver/docker-unifi-controller#62
When running dockerd with
userns-remap
, then starting up a container with--userns=host
, I get the following error message:Inspecting the contents of the container I found:
I found an old ticket for dockerd (moby) that seems to indicate this is to be expected, however this wasn't a problem until just this past week.
So the issue is that when the container is started the ownership of
/bin/s6-overlay-preinit
is the remapped UID, and given it's SUID, it doesn't run as the intended user. This is also confirmed in the docker documentation: https://docs.docker.com/engine/security/userns-remap/#disable-namespace-remapping-for-a-containerHas anything changed in this or a related repo that may be related?
Would you be open to a PR that ensures the ownership of
/bin/s6-overlay-preinit
is correct at runtime?The text was updated successfully, but these errors were encountered: