sudo/sudo-1.6.9p4-getgrouplist.p...

41 lines
1.3 KiB
Diff

diff -up sudo-1.6.9p17/configure.in.getgrouplist sudo-1.6.9p17/configure.in
--- sudo-1.6.9p17/configure.in.getgrouplist 2008-07-04 16:07:42.000000000 +0200
+++ sudo-1.6.9p17/configure.in 2008-07-04 16:09:29.000000000 +0200
@@ -1720,7 +1720,7 @@ dnl
AC_FUNC_GETGROUPS
AC_CHECK_FUNCS(strchr strrchr memchr memcpy memset sysconf tzset \
strftime setrlimit initgroups getgroups fstat gettimeofday \
- setlocale getaddrinfo setsid)
+ setlocale getaddrinfo setsid getgrouplist)
if test -z "$SKIP_SETRESUID"; then
AC_CHECK_FUNCS(setresuid, [SKIP_SETREUID=yes])
fi
diff -up sudo-1.6.9p17/check.c.getgrouplist sudo-1.6.9p17/check.c
--- sudo-1.6.9p17/check.c.getgrouplist 2008-01-06 00:59:42.000000000 +0100
+++ sudo-1.6.9p17/check.c 2008-07-04 16:08:40.000000000 +0200
@@ -330,6 +330,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);
}