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

utils: fix creating default userns #1073

Merged
merged 1 commit into from
Nov 19, 2022

Conversation

giuseppe
Copy link
Member

fix creating the default user namespace when the GID on the host is different than the UID and there is not not already a mapping specified in the OCI configuration.

Closes: #1072

Signed-off-by: Giuseppe Scrivano gscrivan@redhat.com

fix creating the default user namespace when the GID on the host is
different than the UID and there is not not already a mapping
specified in the OCI configuration.

Closes: containers#1072

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@@ -323,7 +323,7 @@ int copy_from_fd_to_fd (int src, int dst, int consume, libcrun_error_t *err);

int run_process (char **args, libcrun_error_t *err);

size_t format_default_id_mapping (char **ret, uid_t container_id, uid_t host_id, int is_uid);
size_t format_default_id_mapping (char **ret, uid_t container_id, uid_t host_uid, uid_t host_id, int is_uid);
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be (..., uid_t host_uid, uid_t host_gid,...)

Copy link
Member Author

Choose a reason for hiding this comment

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

host_id is either UID or GID, depending on the value of is_uid. We need to differentiate since we use different files for the lookup (/etc/subuid or /etc/subgid)

@@ -1403,15 +1403,15 @@ getsubidrange (uid_t id, int is_uid, uint32_t *from, uint32_t *len)
#define MIN(x, y) ((x) < (y) ? (x) : (y))

size_t
format_default_id_mapping (char **ret, uid_t container_id, uid_t host_id, int is_uid)
format_default_id_mapping (char **ret, uid_t container_id, uid_t host_uid, uid_t host_id, int is_uid)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be (..., uid_t host_uid, uid_t host_gid,...)

Copy link
Collaborator

Choose a reason for hiding this comment

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

@rhatdan is this resolved I think this has same explanation as the above one.

Copy link
Collaborator

@flouthoc flouthoc left a comment

Choose a reason for hiding this comment

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

LGTM

@rhatdan
Copy link
Member

rhatdan commented Nov 19, 2022

LGTM

@rhatdan rhatdan merged commit b42e7ec into containers:main Nov 19, 2022
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.

default gid map not allowed error when uid != gid
3 participants