Ignore:
Timestamp:
Jul 6, 2011, 8:21:13 PM (14 years ago)
Author:
Herwig Bauernfeind
Message:

Samba 3.5: Update trunk to 3.5.9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/source3/lib/system_smbd.c

    r454 r599  
    2828#ifndef HAVE_GETGROUPLIST
    2929
     30#ifdef HAVE_GETGRSET
     31static int getgrouplist_getgrset(const char *user, gid_t gid, gid_t *groups,
     32                                 int *grpcnt)
     33{
     34        char *grplist;
     35        char *grp;
     36        gid_t temp_gid;
     37        int num_gids = 1;
     38        int ret = 0;
     39        long l;
     40
     41        grplist = getgrset(user);
     42
     43        DEBUG(10, ("getgrset returned %s\n", grplist));
     44
     45        if (grplist == NULL) {
     46                return -1;
     47        }
     48
     49        if (*grpcnt > 0) {
     50                groups[0] = gid;
     51        }
     52
     53        while ((grp = strsep(&grplist, ",")) != NULL) {
     54                l = strtol(grp, NULL, 10);
     55                temp_gid = (gid_t) l;
     56                if (temp_gid == gid) {
     57                        continue;
     58                }
     59
     60                if (num_gids + 1 > *grpcnt) {
     61                        num_gids++;
     62                        continue;
     63                }
     64                groups[num_gids++] = temp_gid;
     65        }
     66        free(grplist);
     67
     68        if (num_gids > *grpcnt) {
     69                ret = -1;
     70        }
     71        *grpcnt = num_gids;
     72
     73        DEBUG(10, ("Found %d groups for user %s\n", *grpcnt, user));
     74
     75        return ret;
     76}
     77
     78#else /* HAVE_GETGRSET */
     79
    3080/*
    3181  This is a *much* faster way of getting the list of groups for a user
     
    118168#endif
    119169}
    120 #endif
     170#endif /* HAVE_GETGRSET */
     171#endif /* HAVE_GETGROUPLIST */
    121172
    122173static int sys_getgrouplist(const char *user, gid_t gid, gid_t *groups, int *grpcnt)
     
    136187        retval = getgrouplist(user, gid, groups, grpcnt);
    137188#else
     189#ifdef HAVE_GETGRSET
     190        retval = getgrouplist_getgrset(user, gid, groups, grpcnt);
     191#else
    138192        become_root();
    139193        retval = getgrouplist_internals(user, gid, groups, grpcnt);
    140194        unbecome_root();
    141 #endif
     195#endif /* HAVE_GETGRSET */
     196#endif /* HAVE_GETGROUPLIST */
    142197
    143198        /* allow winbindd lookups, but only if they were not already disabled */
Note: See TracChangeset for help on using the changeset viewer.