components/sudo/patches/getgrset.patch
changeset 1209 5fd82ed384aa
parent 1208 8071b2820035
child 1210 abc0c01af810
equal deleted inserted replaced
1208:8071b2820035 1209:5fd82ed384aa
     1 This patch is using solaris private interface _getgroupsbymember(). We should
       
     2 switch to similar public interface once Solaris has one.
       
     3 
       
     4 --- sudo-1.8.4p5/compat/getgrouplist.c	Sat Jan 19 22:45:01 2013
       
     5 +++ sudo-1.8.4p5/compat/getgrouplist.c	Sat Jan 19 22:44:59 2013
       
     6 @@ -36,6 +36,15 @@
       
     7  
       
     8  #include "missing.h"
       
     9  
       
    10 +#ifdef HAVE__GETGRPSBYMEMBER
       
    11 +extern int _getgroupsbymember
       
    12 +(
       
    13 +    const char* username, gid_t gid_array[],
       
    14 +    int maxgids, int numgids
       
    15 +); 
       
    16 +#endif /* HAVE__GETGRPSBYMEMBER */
       
    17 +
       
    18 +
       
    19  #ifdef HAVE_GETGRSET
       
    20  /*
       
    21   * BSD-compatible getgrouplist(3) using getgrset(3)
       
    22 @@ -81,6 +90,25 @@
       
    23  
       
    24  #else /* HAVE_GETGRSET */
       
    25  
       
    26 +#ifdef HAVE__GETGRPSBYMEMBER
       
    27 +int
       
    28 +getgrouplist(const char *name, gid_t basegid, gid_t *groups, int *ngroupsp)
       
    29 +{
       
    30 +    int grpsize = *ngroupsp;
       
    31 +
       
    32 +    if (grpsize <= 0)
       
    33 +	return -1;
       
    34 +    groups[0] = basegid;
       
    35 +
       
    36 +    if ((grpsize = _getgroupsbymember(name, groups, grpsize, 1)) == -1)
       
    37 +	return -1;
       
    38 +
       
    39 +    *ngroupsp = grpsize;
       
    40 +    return 0;
       
    41 +}
       
    42 +
       
    43 +#else /* ! HAVE__GETGRPSBYMEMBER */
       
    44 +
       
    45  /*
       
    46   * BSD-compatible getgrouplist(3) using getgrent(3)
       
    47   */
       
    48 @@ -128,4 +156,7 @@
       
    49  
       
    50      return rval;
       
    51  }
       
    52 +
       
    53 +#endif /* ! HAVE__GETGRPSBYMEMBER */
       
    54 +
       
    55  #endif /* HAVE_GETGRSET */