]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
libmisc: minimum id check for system accounts
authorIker Pedrosa <ipedrosa@redhat.com>
Thu, 6 Oct 2022 09:21:18 +0000 (11:21 +0200)
committerSerge Hallyn <serge@hallyn.com>
Fri, 7 Oct 2022 01:09:35 +0000 (20:09 -0500)
The minimum id allocation for system accounts shouldn't be 0 as this is
reserved for root.

Signed-off-by: Tomáš Mráz <tm@t8m.info>
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
libmisc/find_new_gid.c
libmisc/find_new_uid.c

index 666b6107838f1d0ac9c5e1945f7e2e82dac91c57..65ab5d0132f3c944feafa2886df14dbe5641675b 100644 (file)
@@ -60,6 +60,13 @@ static int get_ranges (bool sys_group, gid_t *min_id, gid_t *max_id,
                             (unsigned long) *max_id);
                        return EINVAL;
                }
+               /*
+                * Zero is reserved for root and the allocation algorithm does not
+                * work right with it.
+                */
+               if (*min_id == 0) {
+                       *min_id = (gid_t) 1;
+               }
        } else {
                /* Non-system groups */
 
index 322d15ab71ef2c99237649283664037aa3788cea..5f7e74b53dd9e2a294242c17879b6d1448130e8f 100644 (file)
@@ -60,6 +60,13 @@ static int get_ranges (bool sys_user, uid_t *min_id, uid_t *max_id,
                             (unsigned long) *max_id);
                        return EINVAL;
                }
+               /*
+                * Zero is reserved for root and the allocation algorithm does not
+                * work right with it.
+                */
+               if (*min_id == 0) {
+                       *min_id = (uid_t) 1;
+               }
        } else {
                /* Non-system users */