Blame SOURCES/shadow-4.9-useradd-avoid-generating-empty-subid-range.patch

b8f1b8
diff --git a/src/useradd.c b/src/useradd.c
b8f1b8
index baeffb35..9abeea6e 100644
b8f1b8
--- a/src/useradd.c
b8f1b8
+++ b/src/useradd.c
b8f1b8
@@ -142,9 +142,7 @@ static bool is_sub_gid = false;
b8f1b8
 static bool sub_uid_locked = false;
b8f1b8
 static bool sub_gid_locked = false;
b8f1b8
 static uid_t sub_uid_start;	/* New subordinate uid range */
b8f1b8
-static unsigned long sub_uid_count;
b8f1b8
 static gid_t sub_gid_start;	/* New subordinate gid range */
b8f1b8
-static unsigned long sub_gid_count;
b8f1b8
 #endif				/* ENABLE_SUBIDS */
b8f1b8
 static bool pw_locked = false;
b8f1b8
 static bool gr_locked = false;
b8f1b8
@@ -234,7 +232,7 @@ static void open_shadow (void);
b8f1b8
 static void faillog_reset (uid_t);
b8f1b8
 static void lastlog_reset (uid_t);
b8f1b8
 static void tallylog_reset (const char *);
b8f1b8
-static void usr_update (void);
b8f1b8
+static void usr_update (unsigned long subuid_count, unsigned long subgid_count);
b8f1b8
 static void create_home (void);
b8f1b8
 static void create_mail (void);
b8f1b8
 static void check_uid_range(int rflg, uid_t user_id);
b8f1b8
@@ -2092,7 +2090,7 @@ static void tallylog_reset (const char *user_name)
b8f1b8
  *	usr_update() creates the password file entries for this user
b8f1b8
  *	and will update the group entries if required.
b8f1b8
  */
b8f1b8
-static void usr_update (void)
b8f1b8
+static void usr_update (unsigned long subuid_count, unsigned long subgid_count)
b8f1b8
 {
b8f1b8
 	struct passwd pwent;
b8f1b8
 	struct spwd spent;
b8f1b8
@@ -2155,14 +2153,14 @@ static void usr_update (void)
b8f1b8
 	}
b8f1b8
 #ifdef ENABLE_SUBIDS
b8f1b8
 	if (is_sub_uid &&
b8f1b8
-	    (sub_uid_add(user_name, sub_uid_start, sub_uid_count) == 0)) {
b8f1b8
+	    (sub_uid_add(user_name, sub_uid_start, subuid_count) == 0)) {
b8f1b8
 		fprintf (stderr,
b8f1b8
 		         _("%s: failed to prepare the new %s entry\n"),
b8f1b8
 		         Prog, sub_uid_dbname ());
b8f1b8
 		fail_exit (E_SUB_UID_UPDATE);
b8f1b8
 	}
b8f1b8
 	if (is_sub_gid &&
b8f1b8
-	    (sub_gid_add(user_name, sub_gid_start, sub_gid_count) == 0)) {
b8f1b8
+	    (sub_gid_add(user_name, sub_gid_start, subgid_count) == 0)) {
b8f1b8
 		fprintf (stderr,
b8f1b8
 		         _("%s: failed to prepare the new %s entry\n"),
b8f1b8
 		         Prog, sub_uid_dbname ());
b8f1b8
@@ -2624,16 +2622,16 @@ int main (int argc, char **argv)
b8f1b8
 	}
b8f1b8
 
b8f1b8
 #ifdef ENABLE_SUBIDS
b8f1b8
-	if (is_sub_uid && sub_uid_count != 0) {
b8f1b8
-		if (find_new_sub_uids(&sub_uid_start, &sub_uid_count) < 0) {
b8f1b8
+	if (is_sub_uid && subuid_count != 0) {
b8f1b8
+		if (find_new_sub_uids(&sub_uid_start, &subuid_count) < 0) {
b8f1b8
 			fprintf (stderr,
b8f1b8
 			         _("%s: can't create subordinate user IDs\n"),
b8f1b8
 			         Prog);
b8f1b8
 			fail_exit(E_SUB_UID_UPDATE);
b8f1b8
 		}
b8f1b8
 	}
b8f1b8
-	if (is_sub_gid && sub_gid_count != 0) {
b8f1b8
-		if (find_new_sub_gids(&sub_gid_start, &sub_gid_count) < 0) {
b8f1b8
+	if (is_sub_gid && subgid_count != 0) {
b8f1b8
+		if (find_new_sub_gids(&sub_gid_start, &subgid_count) < 0) {
b8f1b8
 			fprintf (stderr,
b8f1b8
 			         _("%s: can't create subordinate group IDs\n"),
b8f1b8
 			         Prog);
b8f1b8
@@ -2642,7 +2640,7 @@ int main (int argc, char **argv)
b8f1b8
 	}
b8f1b8
 #endif				/* ENABLE_SUBIDS */
b8f1b8
 
b8f1b8
-	usr_update ();
b8f1b8
+	usr_update (subuid_count, subgid_count);
b8f1b8
 
b8f1b8
 	close_files ();
b8f1b8