Do not warn about useradd --system with Debian-globally allocated uids

This commit is contained in:
Chris Hofstaedtler
2025-03-16 13:37:18 +01:00
parent b56ac5f36b
commit 0e6f426896
3 changed files with 39 additions and 1 deletions
@@ -0,0 +1,37 @@
From: Chris Hofstaedtler <zeha@debian.org>
Date: Sun, 16 Mar 2025 13:29:45 +0100
Subject: Exclude Debian-globally allocated UIDs from sys_uid range warning
Bug: http://bugs.debian.org/1100563
---
src/useradd.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/useradd.c b/src/useradd.c
index 5e4eb2c..dd12cdf 100644
--- a/src/useradd.c
+++ b/src/useradd.c
@@ -2430,14 +2430,21 @@ static void create_mail (void)
#endif
}
+/* See Debian Policy 9.2.2 "UID and GID classes"
+ * https://www.debian.org/doc/debian-policy/ch-opersys.html#uid-and-gid-classes
+ */
+#define DEBIAN_GLOBAL_UID_MIN ((uid_t)60000)
+#define DEBIAN_GLOBAL_UID_MAX ((uid_t)64999)
+
static void check_uid_range(int rflg, uid_t user_id)
{
uid_t uid_min ;
uid_t uid_max ;
if (rflg) {
uid_max = getdef_ulong("SYS_UID_MAX",getdef_ulong("UID_MIN",1000UL)-1);
- if (user_id > uid_max) {
- fprintf(stderr, _("%s warning: %s's uid %d is greater than SYS_UID_MAX %d\n"), Prog, user_name, user_id, uid_max);
+ if (user_id > uid_max
+ && (!(user_id >= DEBIAN_GLOBAL_UID_MIN && user_id <= DEBIAN_GLOBAL_UID_MAX))) {
+ fprintf(stderr, _("%s warning: %s's uid %d is greater than SYS_UID_MAX %d\n"), Prog, user_name, user_id, uid_max);
}
}else{
uid_min = getdef_ulong("UID_MIN", 1000UL);
@@ -57,7 +57,7 @@ index b485a5a..e20be0f 100644
case 'h':
usage (E_SUCCESS);
diff --git a/src/useradd.c b/src/useradd.c
index 5e4eb2c..be9ec2e 100644
index dd12cdf..ba0eb50 100644
--- a/src/useradd.c
+++ b/src/useradd.c
@@ -895,7 +895,7 @@ static void usage (int status)
+1
View File
@@ -1,5 +1,6 @@
debian/Set-group-and-mode-for-g-shadow-files.patch
debian/Keep-using-Debian-adduser-defaults.patch
debian/Exclude-Debian-globally-allocated-UIDs-from-sys_uid-range.patch
debian/Document-the-shadowconfig-utility.patch
debian/Recommend-using-adduser-and-deluser.patch
debian/tests-disable-su.patch