Skip to content

Commit

Permalink
utils: subuid and subgid are keyed by username
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
  • Loading branch information
giuseppe committed Jul 29, 2019
1 parent b1d72bc commit a16fb8c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/libcrun/linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ libcrun_set_usernamespace (libcrun_container_t *container, pid_t pid, libcrun_er

if (!def->linux->gid_mappings_len)
{
gid_map_len = format_default_id_mapping (&gid_map, container->container_uid, container->host_gid, 0);
gid_map_len = format_default_id_mapping (&gid_map, container->container_gid, container->host_uid, 0);
if (gid_map == NULL)
{
if (container->host_gid)
Expand Down
19 changes: 4 additions & 15 deletions src/libcrun/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,21 +668,10 @@ getsubidrange (uid_t id, int is_uid, uint32_t *from, uint32_t *len)
cleanup_free char *lineptr = NULL;
size_t lenlineptr = 0, len_name;
const char *name;

if (is_uid)
{
struct passwd *pwd = getpwuid (id);
if (pwd == NULL)
return -1;
name = pwd->pw_name;
}
else
{
struct group *grp = getgrgid (id);
if (grp == NULL)
return -1;
name = grp->gr_name;
}
struct passwd *pwd = getpwuid (id);
if (pwd == NULL)
return -1;
name = pwd->pw_name;

len_name = strlen (name);

Expand Down

0 comments on commit a16fb8c

Please sign in to comment.