INN commit: branches/2.5 (configure.ac frontends/inews.c)

INN Commit rra at isc.org
Sat Aug 6 20:22:05 UTC 2011


    Date: Saturday, August 6, 2011 @ 13:22:05
  Author: iulius
Revision: 9314

fix issues with calls to getgroups()

Properly check that the getgroups() functions exists and works before
trying to use it.

Also use GETGROUPS_T set by configure to be whichever of gid_t or int is
the base type of the array argument to getgroups().

Modified:
  branches/2.5/configure.ac
  branches/2.5/frontends/inews.c

-------------------+
 configure.ac      |    1 +
 frontends/inews.c |   10 ++++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

Modified: configure.ac
===================================================================
--- configure.ac	2011-08-06 20:21:28 UTC (rev 9313)
+++ configure.ac	2011-08-06 20:22:05 UTC (rev 9314)
@@ -420,6 +420,7 @@
 AC_TYPE_PID_T
 AC_TYPE_SIZE_T
 AC_TYPE_SSIZE_T
+AC_FUNC_GETGROUPS
 AC_TYPE_UID_T
 AC_CHECK_TYPES([ptrdiff_t])
 AC_CHECK_TYPES([sig_atomic_t], , ,

Modified: frontends/inews.c
===================================================================
--- frontends/inews.c	2011-08-06 20:21:28 UTC (rev 9313)
+++ frontends/inews.c	2011-08-06 20:22:05 UTC (rev 9314)
@@ -351,23 +351,25 @@
     /* See if we are in the right group and examine process
      * supplementary groups, rather than the group(5) file entry.
      */
+#ifdef HAVE_GETGROUPS
     {
         int ngroups = getgroups(0, 0);
-        gid_t *groups, *gp;
+        GETGROUPS_T *groups, *gp;
         int rv;
         int rest;
 
-        groups = (gid_t *) xmalloc(ngroups * sizeof(*groups));
+        groups = (GETGROUPS_T *) xmalloc(ngroups * sizeof(GETGROUPS_T));
         if ((rv = getgroups(ngroups, groups)) < 0) {
             /* Silent failure; client doesn't have the group. */
             return false;
         }
         for (rest = ngroups, gp = groups; rest > 0; rest--, gp++) {
-            if (*gp == news_gid)
+            if (*gp == (GETGROUPS_T) news_gid)
                 return true;
         }
     }
-    
+#endif
+
     return false;
 }
 




More information about the inn-committers mailing list