ngompa / rpms / sudo

Forked from rpms/sudo 2 years ago
Clone
Blob Blame History Raw
diff -up sudo-1.7.2p4/check.c.getgrouplist sudo-1.7.2p4/check.c
--- sudo-1.7.2p4/check.c.getgrouplist	2009-05-25 14:02:41.000000000 +0200
+++ sudo-1.7.2p4/check.c	2010-03-01 11:27:38.000000000 +0100
@@ -353,6 +353,24 @@ user_is_exempt()
 	    return(TRUE);
     }
 
+#ifdef HAVE_GETGROUPLIST
+    {
+	gid_t *grouplist, grouptmp;
+	int n_groups, i;
+	n_groups = 1;
+	if (getgrouplist(user_name, user_gid, &grouptmp, &n_groups) == -1) {
+	    grouplist = (gid_t *) emalloc(sizeof(gid_t) * (n_groups + 1));
+	    if (getgrouplist(user_name, user_gid, grouplist, &n_groups) > 0)
+		for (i = 0; i < n_groups; i++)
+		    if (grouplist[i] == grp->gr_gid) {
+			free(grouplist);
+			return(TRUE);
+		    }
+	    free(grouplist);
+	}
+    }
+#endif
+
     return(FALSE);
 }
 
diff -up sudo-1.7.2p4/configure.in.getgrouplist sudo-1.7.2p4/configure.in
--- sudo-1.7.2p4/configure.in.getgrouplist	2010-03-01 11:27:38.000000000 +0100
+++ sudo-1.7.2p4/configure.in	2010-03-01 11:29:45.000000000 +0100
@@ -1852,7 +1852,7 @@ dnl
 AC_FUNC_GETGROUPS
 AC_CHECK_FUNCS(strchr strrchr memchr memcpy memset sysconf tzset \
 	       strftime setrlimit initgroups getgroups fstat gettimeofday \
-	       setlocale getaddrinfo setsid setenv setrlimit64)
+	       setlocale getaddrinfo setsid setenv setrlimit64 getgrouplist)
 AC_CHECK_FUNCS(unsetenv, SUDO_FUNC_UNSETENV_VOID)
 SUDO_FUNC_PUTENV_CONST
 if test -z "$SKIP_SETRESUID"; then