From 6eb98aee93be531b09425ea4bce86cfe05e8b4ef Mon Sep 17 00:00:00 2001 From: Michael Sweet Date: Fri, 13 May 2016 12:11:52 -0400 Subject: [PATCH] The scheduler now uses the getgrouplist function when available (Issue #4611) --- CHANGES.txt | 4 +++- config-scripts/cups-common.m4 | 3 +++ config.h.in | 7 +++++++ configure | 12 ++++++++++++ scheduler/auth.c | 17 ++++++++++++++++- vcnet/config.h | 7 +++++++ xcode/config.h | 7 +++++++ 7 files changed, 55 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index ec7b8aead4..25c7dabd17 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,8 +1,10 @@ -CHANGES.txt - 2.2b1 - 2016-05-11 +CHANGES.txt - 2.2b1 - 2016-05-13 -------------------------------- CHANGES IN CUPS V2.2b1 + - The scheduler now uses the getgrouplist function when available + (Issue #4611) - The IPP backend no longer enables compression by default except for certain raster formats that generally benefit from it () diff --git a/config-scripts/cups-common.m4 b/config-scripts/cups-common.m4 index 3a912478c9..fbba71503a 100644 --- a/config-scripts/cups-common.m4 +++ b/config-scripts/cups-common.m4 @@ -199,6 +199,9 @@ AC_CHECK_FUNCS(waitpid wait3) dnl Check for posix_spawn AC_CHECK_FUNCS(posix_spawn) +dnl Check for getgrouplist +AC_CHECK_FUNCS(getgrouplist) + dnl See if the tm structure has the tm_gmtoff member... AC_MSG_CHECKING(for tm_gmtoff member in tm structure) AC_TRY_COMPILE([#include ],[struct tm t; diff --git a/config.h.in b/config.h.in index e242d56118..37cfc4cd15 100644 --- a/config.h.in +++ b/config.h.in @@ -532,6 +532,13 @@ #undef HAVE_SCDYNAMICSTORECOPYCOMPUTERNAME +/* + * Do we have the getgrouplist() function? + */ + +#undef HAVE_GETGROUPLIST + + /* * Do we have OS X 10.4's mbr_XXX functions? */ diff --git a/configure b/configure index c3af70dd1c..38b2e9eb96 100755 --- a/configure +++ b/configure @@ -5307,6 +5307,18 @@ fi done +for ac_func in getgrouplist +do : + ac_fn_c_check_func "$LINENO" "getgrouplist" "ac_cv_func_getgrouplist" +if test "x$ac_cv_func_getgrouplist" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_GETGROUPLIST 1 +_ACEOF + +fi +done + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tm_gmtoff member in tm structure" >&5 $as_echo_n "checking for tm_gmtoff member in tm structure... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext diff --git a/scheduler/auth.c b/scheduler/auth.c index 4a0ece175b..9ffc06a5b5 100644 --- a/scheduler/auth.c +++ b/scheduler/auth.c @@ -1,7 +1,7 @@ /* * Authorization routines for the CUPS scheduler. * - * Copyright 2007-2015 by Apple Inc. + * Copyright 2007-2016 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * This file contains Kerberos support code, copyright 2006 by @@ -1176,6 +1176,21 @@ cupsdCheckGroup( * Group exists, check it... */ +#ifdef HAVE_GETGROUPLIST + if (user) + { + int ngroups, /* Number of groups */ + groups[2048]; /* Groups that user belongs to */ + + ngroups = (int)(sizeof(groups) / sizeof(groups[0])); + getgrouplist(username, (int)user->pw_gid, groups, &ngroups); + + for (i = 0; i < ngroups; i ++) + if ((int)group->gr_gid == groups[i]) + return (1); + } +#endif /* HAVE_GETGROUPLIST */ + for (i = 0; group->gr_mem[i]; i ++) if (!_cups_strcasecmp(username, group->gr_mem[i])) return (1); diff --git a/vcnet/config.h b/vcnet/config.h index e8e73f6b13..fdbfd68e45 100644 --- a/vcnet/config.h +++ b/vcnet/config.h @@ -585,6 +585,13 @@ typedef unsigned long useconds_t; /* #undef HAVE_SCDYNAMICSTORECOPYCOMPUTERNAME */ +/* + * Do we have the getgrouplist() function? + */ + +#undef HAVE_GETGROUPLIST + + /* * Do we have OS X 10.4's mbr_XXX functions? */ diff --git a/xcode/config.h b/xcode/config.h index e16c6667cb..98aa98749a 100644 --- a/xcode/config.h +++ b/xcode/config.h @@ -545,6 +545,13 @@ #endif /* !TARGET_OS_IOS */ +/* + * Do we have the getgrouplist() function? + */ + +#define HAVE_GETGROUPLIST 1 + + /* * Do we have OS X 10.4's mbr_XXX functions? */ -- 2.47.3