|
|
9ed61c |
From 663824ef4ca927aa2b4319b69e0bfa68282ec719 Mon Sep 17 00:00:00 2001
|
|
|
9ed61c |
From: Serge Hallyn <serge@hallyn.com>
|
|
|
9ed61c |
Date: Sat, 22 May 2021 11:42:02 -0500
|
|
|
9ed61c |
Subject: [PATCH] Fix useradd with SUB_UID_COUNT=0
|
|
|
9ed61c |
|
|
|
9ed61c |
Closes #298
|
|
|
9ed61c |
|
|
|
9ed61c |
Fix useradd when SUB_UID_COUNT=0 in login.defs.
|
|
|
9ed61c |
|
|
|
9ed61c |
Signed-off-by: Serge Hallyn <serge@hallyn.com>
|
|
|
9ed61c |
---
|
|
|
9ed61c |
src/useradd.c | 8 ++++++--
|
|
|
9ed61c |
1 file changed, 6 insertions(+), 2 deletions(-)
|
|
|
9ed61c |
|
|
|
9ed61c |
diff --git a/src/useradd.c b/src/useradd.c
|
|
|
9ed61c |
index 06accb2f..9862ae55 100644
|
|
|
9ed61c |
--- a/src/useradd.c
|
|
|
9ed61c |
+++ b/src/useradd.c
|
|
|
9ed61c |
@@ -2386,6 +2386,8 @@ int main (int argc, char **argv)
|
|
|
9ed61c |
#ifdef ENABLE_SUBIDS
|
|
|
9ed61c |
uid_t uid_min;
|
|
|
9ed61c |
uid_t uid_max;
|
|
|
9ed61c |
+ unsigned long subuid_count;
|
|
|
9ed61c |
+ unsigned long subgid_count;
|
|
|
9ed61c |
#endif
|
|
|
9ed61c |
|
|
|
9ed61c |
/*
|
|
|
9ed61c |
@@ -2427,9 +2429,11 @@ int main (int argc, char **argv)
|
|
|
9ed61c |
#ifdef ENABLE_SUBIDS
|
|
|
9ed61c |
uid_min = (uid_t) getdef_ulong ("UID_MIN", 1000UL);
|
|
|
9ed61c |
uid_max = (uid_t) getdef_ulong ("UID_MAX", 60000UL);
|
|
|
9ed61c |
- is_sub_uid = sub_uid_file_present () && !rflg &&
|
|
|
9ed61c |
+ subuid_count = getdef_ulong ("SUB_UID_COUNT", 65536);
|
|
|
9ed61c |
+ subgid_count = getdef_ulong ("SUB_GID_COUNT", 65536);
|
|
|
9ed61c |
+ is_sub_uid = subuid_count > 0 && sub_uid_file_present () && !rflg &&
|
|
|
9ed61c |
(!user_id || (user_id <= uid_max && user_id >= uid_min));
|
|
|
9ed61c |
- is_sub_gid = sub_gid_file_present () && !rflg &&
|
|
|
9ed61c |
+ is_sub_gid = subgid_count > 0 && sub_gid_file_present () && !rflg &&
|
|
|
9ed61c |
(!user_id || (user_id <= uid_max && user_id >= uid_min));
|
|
|
9ed61c |
#endif /* ENABLE_SUBIDS */
|
|
|
9ed61c |
|
|
|
9ed61c |
--
|
|
|
9ed61c |
2.30.2
|
|
|
9ed61c |
|