summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIker Pedrosa <ipedrosa@redhat.com>2022-10-06 11:21:18 +0200
committerSerge Hallyn <serge@hallyn.com>2022-10-06 20:09:35 -0500
commitd324c6776b3a1d4ac22bced543f72dc5dd366927 (patch)
treec18b63727b8178fdd5f0504498f25107a7f1759e
parentead03afeba68310de778547c8b384d086ce802d0 (diff)
libmisc: minimum id check for system accounts
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>
-rw-r--r--libmisc/find_new_gid.c7
-rw-r--r--libmisc/find_new_uid.c7
2 files changed, 14 insertions, 0 deletions
diff --git a/libmisc/find_new_gid.c b/libmisc/find_new_gid.c
index 666b6107..65ab5d01 100644
--- a/libmisc/find_new_gid.c
+++ b/libmisc/find_new_gid.c
@@ -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 */
diff --git a/libmisc/find_new_uid.c b/libmisc/find_new_uid.c
index 322d15ab..5f7e74b5 100644
--- a/libmisc/find_new_uid.c
+++ b/libmisc/find_new_uid.c
@@ -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 */