Skip to content
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

storage: make [l]chown errors clearer #303

Merged
merged 1 commit into from
Mar 11, 2019

Conversation

giuseppe
Copy link
Member

if os.[Lc,C]hown are failing with EINVAL, it might be related to an
UID/GID not mapped in the user namespace we are currently using.

It could be possible to detect this issue by inspecting
/proc/self/uid_map or /proc/self/gid_map, but that won't be possible
when we are pulling a new image and extracting it from a chroot where
/proc is not mounted.

Signed-off-by: Giuseppe Scrivano [email protected]

if os.[Lc,C]hown are failing with EINVAL, it might be related to an
UID/GID not mapped in the user namespace we are currently using.

It could be possible to detect this issue by inspecting
/proc/self/uid_map or /proc/self/gid_map, but that won't be possible
when we are pulling a new image and extracting it from a chroot where
/proc is not mounted.

Signed-off-by: Giuseppe Scrivano <[email protected]>
@AkihiroSuda
Copy link
Contributor

Any chance to use https://github.com/rootless-containers/proto , so that OCI runtime can emulate file permission using ptrace/seccomp ?

@giuseppe
Copy link
Member Author

that would work only with umoci and the rootless-containers fork of PRoot. Is there any other runtime honoring these xattrs?

I don't think at the moment we want to support syscalls emulation either in Podman and Buildah.

For containers/storage it is probably fine if we support it through an explicit configuration setting, if there is anyone using it. I am only opposed to silently doing it as a fallback when chown fails.


func checkChownErr(err error, name string, uid, gid int) error {
if e, ok := err.(*os.PathError); ok && e.Err == syscall.EINVAL {
return errors.Wrapf(err, "there might not be enough IDs available in the namespace (requested %d:%d for %s)", uid, gid, name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about
"%d:%d dones have have a valid mapping in the user namespace for %s"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are not sure that is the problem without checking /proc/self/uid_map, that is why I've left it as a possibility in the message. Even though I don't see other reasons why it could fail with that error code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe: "(err, "A valid mapping could not be determined for the usernamespace %s with the requested uid:gid (%s:%s)", name, uid, gid)"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if you want to add something about "verify the values in /proc/self/uid_map" or some such to that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is need to be in the correct namespace to verify /proc/self/uid_map

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just want something more specific for the user. then "Their might not be" ...

giuseppe added a commit to giuseppe/libpod that referenced this pull request Mar 11, 2019
we were playing safe and not allowed any container to have less than
65536 mappings.  There are a couple of reasons to change it:

- it blocked libpod to work in an environment where
  newuidmap/newgidmap are not available, or not configured.

- not allowed to use different partitions of subuids, where each user
  has less than 65536 ids available.

Hopefully this change in containers/storage:

containers/storage#303

will make error clearers if there are not enough IDs for the image
that is being used.

Closes: containers#1651

Signed-off-by: Giuseppe Scrivano <[email protected]>
@rhatdan
Copy link
Member

rhatdan commented Mar 11, 2019

LGTM

@rhatdan rhatdan merged commit 25923ca into containers:master Mar 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants