From: Sol Boucher Date: Fri, 8 Jul 2022 16:09:13 +0000 (-0400) Subject: unshare: Fix "you (user xxxx) don't exist" error when uid differs from primary gid X-Git-Tag: v2.39-rc1~581 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c6fa0ebd7b0b6d2da5dd4d3edd5e885632ff65d0;p=thirdparty%2Futil-linux.git unshare: Fix "you (user xxxx) don't exist" error when uid differs from primary gid This problem affected the --map-auto and --map-groups=auto command-line switches. The root cause is that /etc/subgid is indexed by user or uid, not by group or gid; therefore, we should be using the effective uid to find entries in this file, just as we do for /etc/subuid. Signed-off-by: Sol Boucher --- diff --git a/sys-utils/unshare.c b/sys-utils/unshare.c index 88306f0f46..a379e8aede 100644 --- a/sys-utils/unshare.c +++ b/sys-utils/unshare.c @@ -864,14 +864,14 @@ int main(int argc, char *argv[]) case OPT_MAPGROUPS: unshare_flags |= CLONE_NEWUSER; if (!strcmp(optarg, "auto")) - groupmap = read_subid_range(_PATH_SUBGID, real_egid); + groupmap = read_subid_range(_PATH_SUBGID, real_euid); else groupmap = get_map_range(optarg); break; case OPT_MAPAUTO: unshare_flags |= CLONE_NEWUSER; usermap = read_subid_range(_PATH_SUBUID, real_euid); - groupmap = read_subid_range(_PATH_SUBGID, real_egid); + groupmap = read_subid_range(_PATH_SUBGID, real_euid); break; case OPT_SETGROUPS: setgrpcmd = setgroups_str2id(optarg);