16195225 use _getgroupsbymember() instead of slow getgrent() calls s11u1-sru
authorVladimir Marek <Vladimir.Marek@oracle.com>
Mon, 04 Mar 2013 21:41:55 +0100
branchs11u1-sru
changeset 2511 4a3540719f56
parent 2509 b7784efdcc03
child 2513 8507b46f64f5
16195225 use _getgroupsbymember() instead of slow getgrent() calls
components/sudo/Makefile
components/sudo/patches/getgrset.patch
--- a/components/sudo/Makefile	Mon Mar 04 01:04:36 2013 -0800
+++ b/components/sudo/Makefile	Mon Mar 04 21:41:55 2013 +0100
@@ -19,7 +19,7 @@
 # CDDL HEADER END
 
 #
-# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
 #
 
 include ../../make-rules/shared-macros.mk
@@ -40,7 +40,7 @@
 include $(WS_TOP)/make-rules/ips.mk
 
 CONFIGURE_ENV +=	"CC=$(CC)"
-CONFIGURE_ENV +=	"CFLAGS=$(CFLAGS)"
+CONFIGURE_ENV +=	"CFLAGS=$(CFLAGS) -DHAVE__GETGRPSBYMEMBER"
 CONFIGURE_ENV +=	"CXX=$(CXX)"
 CONFIGURE_ENV +=	"MAKE=$(GMAKE)"
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/sudo/patches/getgrset.patch	Mon Mar 04 21:41:55 2013 +0100
@@ -0,0 +1,55 @@
+This patch is using solaris private interface _getgroupsbymember(). We should
+switch to similar public interface once Solaris has one.
+
+--- sudo-1.8.4p5/compat/getgrouplist.c	Sat Jan 19 22:45:01 2013
++++ sudo-1.8.4p5/compat/getgrouplist.c	Sat Jan 19 22:44:59 2013
[email protected]@ -36,6 +36,15 @@
+ 
+ #include "missing.h"
+ 
++#ifdef HAVE__GETGRPSBYMEMBER
++extern int _getgroupsbymember
++(
++    const char* username, gid_t gid_array[],
++    int maxgids, int numgids
++); 
++#endif /* HAVE__GETGRPSBYMEMBER */
++
++
+ #ifdef HAVE_GETGRSET
+ /*
+  * BSD-compatible getgrouplist(3) using getgrset(3)
[email protected]@ -81,6 +90,25 @@
+ 
+ #else /* HAVE_GETGRSET */
+ 
++#ifdef HAVE__GETGRPSBYMEMBER
++int
++getgrouplist(const char *name, gid_t basegid, gid_t *groups, int *ngroupsp)
++{
++    int grpsize = *ngroupsp;
++
++    if (grpsize <= 0)
++	return -1;
++    groups[0] = basegid;
++
++    if ((grpsize = _getgroupsbymember(name, groups, grpsize, 1)) == -1)
++	return -1;
++
++    *ngroupsp = grpsize;
++    return 0;
++}
++
++#else /* ! HAVE__GETGRPSBYMEMBER */
++
+ /*
+  * BSD-compatible getgrouplist(3) using getgrent(3)
+  */
[email protected]@ -128,4 +156,7 @@
+ 
+     return rval;
+ }
++
++#endif /* ! HAVE__GETGRPSBYMEMBER */
++
+ #endif /* HAVE_GETGRSET */