f38d60a
diff -up shadow-4.6/libmisc/find_new_gid.c.min-limit shadow-4.6/libmisc/find_new_gid.c
f38d60a
--- shadow-4.6/libmisc/find_new_gid.c.min-limit	2018-04-29 18:42:37.000000001 +0200
1a1e747
+++ shadow-4.6/libmisc/find_new_gid.c	2018-11-06 10:51:20.554963292 +0100
1a1e747
@@ -82,6 +82,13 @@ static int get_ranges (bool sys_group, g
f38d60a
                             (unsigned long) *max_id);
f38d60a
 			return EINVAL;
1a1e747
 		}
f38d60a
+		/*
f38d60a
+		 * Zero is reserved for root and the allocation algorithm does not
f38d60a
+		 * work right with it.
f38d60a
+		 */
f38d60a
+		if (*min_id == 0) {
f38d60a
+			*min_id = (gid_t) 1;
1a1e747
+		}
f38d60a
 	} else {
f38d60a
 		/* Non-system groups */
1a1e747
 
f38d60a
diff -up shadow-4.6/libmisc/find_new_uid.c.min-limit shadow-4.6/libmisc/find_new_uid.c
f38d60a
--- shadow-4.6/libmisc/find_new_uid.c.min-limit	2018-04-29 18:42:37.000000001 +0200
1a1e747
+++ shadow-4.6/libmisc/find_new_uid.c	2018-11-06 10:51:39.341399569 +0100
1a1e747
@@ -82,6 +82,13 @@ static int get_ranges (bool sys_user, ui
f38d60a
                             (unsigned long) *max_id);
f38d60a
 			return EINVAL;
1a1e747
 		}
f38d60a
+		/*
f38d60a
+		 * Zero is reserved for root and the allocation algorithm does not
f38d60a
+		 * work right with it.
f38d60a
+		 */
f38d60a
+		if (*min_id == 0) {
f38d60a
+			*min_id = (uid_t) 1;
1a1e747
+		}
f38d60a
 	} else {
f38d60a
 		/* Non-system users */
1a1e747