]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
useradd: check if subid range exists for user
authorIker Pedrosa <ipedrosa@redhat.com>
Mon, 24 Oct 2022 08:46:36 +0000 (10:46 +0200)
committerSerge Hallyn <serge@hallyn.com>
Fri, 18 Nov 2022 15:04:42 +0000 (09:04 -0600)
Check if a user already has a subid range before assigning one.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2012929

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
src/useradd.c

index 7ea0a9c4d87426818f71eae6099a62fff9151ef1..e784d6029a75c5132807ecf5034acf0acc009dd2 100644 (file)
@@ -2188,14 +2188,14 @@ static void usr_update (unsigned long subuid_count, unsigned long subgid_count)
                fail_exit (E_PW_UPDATE);
        }
 #ifdef ENABLE_SUBIDS
-       if (is_sub_uid &&
+       if (is_sub_uid && !local_sub_uid_assigned(user_name) &&
            (sub_uid_add(user_name, sub_uid_start, subuid_count) == 0)) {
                fprintf (stderr,
                         _("%s: failed to prepare the new %s entry\n"),
                         Prog, sub_uid_dbname ());
                fail_exit (E_SUB_UID_UPDATE);
        }
-       if (is_sub_gid &&
+       if (is_sub_gid && !local_sub_gid_assigned(user_name) &&
            (sub_gid_add(user_name, sub_gid_start, subgid_count) == 0)) {
                fprintf (stderr,
                         _("%s: failed to prepare the new %s entry\n"),