summaryrefslogtreecommitdiff
path: root/debian/patches/1000_configure_userns
blob: 0cddc99d9c06392fcfa3ae1a690076f8f0228978 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
=== modified file 'etc/login.defs'
Index: git/etc/login.defs
===================================================================
--- git.orig/etc/login.defs
+++ git/etc/login.defs
@@ -229,7 +229,7 @@
 # Extra per user uids
 SUB_UID_MIN		   100000
 SUB_UID_MAX		600100000
-SUB_UID_COUNT		    10000
+SUB_UID_COUNT		    65536
 
 #
 # Min/max values for automatic gid selection in groupadd(8)
@@ -242,7 +242,7 @@
 # Extra per user group ids
 SUB_GID_MIN		   100000
 SUB_GID_MAX		600100000
-SUB_GID_COUNT		    10000
+SUB_GID_COUNT		    65536
 
 #
 # Max number of login(1) retries if password is bad
Index: git/src/newusers.c
===================================================================
--- git.orig/src/newusers.c
+++ git/src/newusers.c
@@ -988,8 +988,8 @@
 	is_shadow_grp = sgr_file_present ();
 #endif
 #ifdef ENABLE_SUBIDS
-	is_sub_uid = sub_uid_file_present ();
-	is_sub_gid = sub_gid_file_present ();
+	is_sub_uid = sub_uid_file_present () && !rflg;
+	is_sub_gid = sub_gid_file_present () && !rflg;
 #endif				/* ENABLE_SUBIDS */
 
 	open_files ();
Index: git/src/useradd.c
===================================================================
--- git.orig/src/useradd.c
+++ git/src/useradd.c
@@ -1994,6 +1994,10 @@
 #endif				/* USE_PAM */
 #endif				/* ACCT_TOOLS_SETUID */
 
+	/* Needed for userns check */
+	uid_t uid_min = (uid_t) getdef_ulong ("UID_MIN", 1000UL);
+	uid_t uid_max = (uid_t) getdef_ulong ("UID_MAX", 60000UL);
+
 	/*
 	 * Get my name so that I can use it to report errors.
 	 */
@@ -2023,9 +2027,10 @@
 	is_shadow_grp = sgr_file_present ();
 #endif
 #ifdef ENABLE_SUBIDS
-	is_sub_uid = sub_uid_file_present ();
-	is_sub_gid = sub_gid_file_present ();
-#endif				/* ENABLE_SUBIDS */
+	is_sub_uid = sub_uid_file_present () && !rflg &&
+	    (!user_id || (user_id <= uid_max && user_id >= uid_min));
+	is_sub_gid = sub_gid_file_present () && !rflg &&
+	    (!user_id || (user_id <= uid_max && user_id >= uid_min));
 
 	get_defaults ();
 
Index: git/libmisc/find_new_sub_uids.c
===================================================================
--- git.orig/libmisc/find_new_sub_uids.c
+++ git/libmisc/find_new_sub_uids.c
@@ -58,7 +58,7 @@
 
 	min = getdef_ulong ("SUB_UID_MIN", 100000UL);
 	max = getdef_ulong ("SUB_UID_MAX", 600100000UL);
-	count = getdef_ulong ("SUB_UID_COUNT", 10000);
+	count = getdef_ulong ("SUB_UID_COUNT", 65536);
 
 	if (min > max || count >= max || (min + count - 1) > max) {
 		(void) fprintf (stderr,
Index: git/libmisc/find_new_sub_gids.c
===================================================================
--- git.orig/libmisc/find_new_sub_gids.c
+++ git/libmisc/find_new_sub_gids.c
@@ -58,7 +58,7 @@
 
 	min = getdef_ulong ("SUB_GID_MIN", 100000UL);
 	max = getdef_ulong ("SUB_GID_MAX", 600100000UL);
-	count = getdef_ulong ("SUB_GID_COUNT", 10000);
+	count = getdef_ulong ("SUB_GID_COUNT", 65536);
 
 	if (min > max || count >= max || (min + count - 1) > max) {
 		(void) fprintf (stderr,