]> Savannah Git Hosting - gnulib.git/commitdiff
mgetgroups: port to strict OS X
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 30 Jun 2015 16:32:07 +0000 (09:32 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 30 Jun 2015 16:34:05 +0000 (09:34 -0700)
The previous fix wasn't working, so use a bigger hammer (Bug#20923).
* lib/mgetgroups.c: Ignore -Wpointer-sign diagnostics.
(getgrouplist_gids) [HAVE_GETGROUPLIST]: Remove.  All uses removed.
* m4/mgetgroups.m4 (gl_MGETGROUPS): Revert recent changes.

ChangeLog
lib/mgetgroups.c
m4/mgetgroups.m4

index cb6ca08b6a38e785f6be51ade0b011092ef9af28..37120cdcc7f491eb52544d657560b13731fdcd0e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2015-06-30  Paul Eggert  <eggert@cs.ucla.edu>
+
+       mgetgroups: port to strict OS X
+       The previous fix wasn't working, so use a bigger hammer (Bug#20923).
+       * lib/mgetgroups.c: Ignore -Wpointer-sign diagnostics.
+       (getgrouplist_gids) [HAVE_GETGROUPLIST]: Remove.  All uses removed.
+       * m4/mgetgroups.m4 (gl_MGETGROUPS): Revert recent changes.
+
 2015-06-29  Paul Eggert  <eggert@cs.ucla.edu>
 
        mgetgroups: port to strict OS X
index dd0c7a595cb463956b208e9ab23630603d564f9b..6acb0191a2cd7cf6583f7d98d2f072df2786c8d7 100644 (file)
 #include "getugroups.h"
 #include "xalloc-oversized.h"
 
+/* Work around an incompatibility of OS X 10.11: getgrouplist
+   accepts int *, not gid_t *, and int and gid_t differ in sign.  */
+#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
+# pragma GCC diagnostic ignored "-Wpointer-sign"
+#endif
+
 static gid_t *
 realloc_groupbuf (gid_t *g, size_t num)
 {
@@ -64,11 +70,6 @@ mgetgroups (char const *username, gid_t gid, gid_t **groups)
   gid_t *g;
 
 #if HAVE_GETGROUPLIST
-# if HAVE_GETGROUPLIST_WITH_INT
-#  define getgrouplist_gids(g) ((int *) (g))
-# else
-#  define getgrouplist_gids(g) (g)
-# endif
   /* We prefer to use getgrouplist if available, because it has better
      performance characteristics.
 
@@ -92,8 +93,7 @@ mgetgroups (char const *username, gid_t gid, gid_t **groups)
           int last_n_groups = max_n_groups;
 
           /* getgrouplist updates max_n_groups to num required.  */
-          ng = getgrouplist (username, gid, getgrouplist_gids (g),
-                             &max_n_groups);
+          ng = getgrouplist (username, gid, g, &max_n_groups);
 
           /* Some systems (like Darwin) have a bug where they
              never increase max_n_groups.  */
index 5747148c718226512f257d60328b3ce2b0f936fd..42b5cf83a5b28d3c2251887212b2ca49006869d4 100644 (file)
@@ -1,4 +1,4 @@
-#serial 7
+#serial 5
 dnl Copyright (C) 2007-2015 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,38 +6,5 @@ dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_MGETGROUPS],
 [
-  AC_CHECK_HEADERS_ONCE([grp.h])
   AC_CHECK_FUNCS_ONCE([getgrouplist])
-  if test "$ac_cv_func_getgrouplist" = yes; then
-    AC_CACHE_CHECK([for getgrouplist with int signature],
-      [gl_cv_getgrouplist_with_int],
-      [gl_cv_getgrouplist_with_int=no
-       gl_save_c_werror_flag=$ac_c_werror_flag
-       ac_c_werror_flag=yes
-       AC_COMPILE_IFELSE(
-         [AC_LANG_PROGRAM(
-            [[#if HAVE_GRP_H
-               #include <grp.h>
-              #endif
-              int groups[1];
-              int ngroups = 1;
-            ]],
-            [[return - getgrouplist ("root", 0, groups, &ngroups);]])],
-         [],
-         [AC_COMPILE_IFELSE(
-           [AC_LANG_PROGRAM(
-              [[#if HAVE_GRP_H
-                 #include <grp.h>
-                #endif
-                int groups[sizeof (gid_t) == sizeof (int) ? 1 : -1];
-                int ngroups = 1;
-              ]],
-              [[return - getgrouplist ("root", 0, groups, &ngroups);]])],
-            [gl_cv_getgrouplist_with_int=yes])])
-       ac_c_werror_flag=$gl_save_c_werror_flag])
-    if test "$gl_cv_getgrouplist_with_int" = yes; then
-      AC_DEFINE([HAVE_GETGROUPLIST_WITH_INT], 1,
-        [Define to 1 if getgrouplist accepts and returns int and not gid_t.])
-    fi
-  fi
 ])