aboutsummaryrefslogtreecommitdiffstats
path: root/package/busybox/patches/803-id_getgrouplist.patch
blob: 04d8dc406789f771c265d99910dbd9f11519e371 (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
This patch disable supplementary groups handling in id with uClibc versions 
prior to v0.9.30, which are lacking the 'getgrouplist' function.

Signed-off-by: Nicolas Thill <nico@openwrt.org>

--- a/coreutils/id.c
+++ b/coreutils/id.c
@@ -19,10 +19,12 @@
 
 /* This is a NOEXEC applet. Be very careful! */
 
+#define HAVE_GETGROUPLIST 1
+
 #if !ENABLE_USE_BB_PWD_GRP
 #if defined(__UCLIBC_MAJOR__) && (__UCLIBC_MAJOR__ == 0)
 #if (__UCLIBC_MINOR__ < 9) || (__UCLIBC_MINOR__ == 9 &&  __UCLIBC_SUBLEVEL__ < 30)
-#error "Sorry, you need at least uClibc version 0.9.30 for id applet to build"
+#undef HAVE_GETGROUPLIST
 #endif
 #endif
 #endif
@@ -84,7 +86,11 @@ static int get_groups(const char *userna
 		/* If the user is a member of more than
 		 * *n groups, then -1 is returned. Otherwise >= 0.
 		 * (and no defined way of detecting errors?!) */
+#if HAVE_GETGROUPLIST
 		m = getgrouplist(username, rgid, groups, n);
+#else
+		*n = -1;
+#endif
 		/* I guess *n < 0 might indicate error. Anyway,
 		 * malloc'ing -1 bytes won't be good, so: */
 		//if (*n < 0)
@@ -156,6 +162,7 @@ int id_main(int argc UNUSED_PARAM, char 
 			if (egid != rgid)
 				status |= print_group(egid, " ");
 		}
+#if HAVE_GETGROUPLIST
 		/* We are supplying largish buffer, trying
 		 * to not run get_groups() twice. That might be slow
 		 * ("user database in remote SQL server" case) */
@@ -183,6 +190,7 @@ int id_main(int argc UNUSED_PARAM, char 
 		}
 		if (ENABLE_FEATURE_CLEAN_UP)
 			free(groups);
+#endif
 #if ENABLE_SELINUX
 		if (is_selinux_enabled()) {
 			if (getcon(&scontext) == 0)