-
Notifications
You must be signed in to change notification settings - Fork 324
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
volume idmap fails on rootless containers but succeeds with sudo (should work with both) #1632
Comments
as an aside im happy to do this work if its agreeable and someone points me in the correct direction. |
The kernel does not allow rootless users to do idmap.Nothing crun can do about it. |
documentation i linked to says otherwise.
|
I am not sure Podman is assuming the CAP_SYS_ADMIN permissions. You could try this directly on the crun command rather then Podman, which would get you closer to what you expect. |
@rhatdan im not sure either, I didnt realize podman sets up a user namespace before calling crun. i'll back track. thanks. |
some background here - just in case its needed.
Problem: I want to run a rootless container starting systemd using /usr/sbin/init with a volume mounted with a specific idmap. currently this fails, however running the same command with sudo succeeds and does what I want, and running the command without the idmap succeeds. this implies the following:
the problem lies with the fact the rootless command with the idmap fails with a mount_setattr EPERM error. from what I've read about the mount_setattr command what I'm trying to do should work.
using the minimal example:
mounting the volume is clearly possible in the rootless context.
the idmap clearly is workable.
either the volume can be mounted or it cant. the mapping is either valid or it isnt. adding a idmap shouldn't suddenly choke.
taking a look at mount_setattr there are 4 reasons for mount_setattr to return EPERM:
MOUNT_ATTR_NOATIME - I'm assuming this is unset.
MOUNT_ATTR_NODIRATIME - I'm assuming this is unset.
MOUNT_ATTR_NOEXEC - docs be default this is not set.
MOUNT_ATTR_NOSUID - docs by default this is set.
MOUNT_ATTR_RDONLY - docs by default volumes are mounted RW.
Defaults mean setting the idmap should fail this by default. due to NOSUID being set by default. but since it doesn't in the sudo case I'm guessing the sudo case prevents the flag from getting locked.
Im hoping this isnt the case.
also possible, but I'm guessing not the case due to sudo working.
this is possible and root would resolve this problem.
Taking what we've learned:
any guidance would be appreciated. my current guess is its the lack of sys_admin cap for my current user and that I didn't properly set my user to have the capability in the initial user namespace. not 100% sure how to do that.
edit:
additional notes - the mount_setattr idmap'd notes section implies the following:
The caller must have the CAP_SYS_ADMIN capability in the user namespace the filesystem was mounted in
this is different from the the EPERM statement about the initial user namespace. is it possible crun just isn't setting this cap for the usernamespace for the current user?overflow user ID
which i believe would be incredibly useful to set settable as an option and default to the default user id (typically root unless overridden by the --user option). currently looks like its set to the end of the uid/gid space. im assuming for security reasons?The text was updated successfully, but these errors were encountered: