Changeset 599 for trunk/server/source3/lib/system_smbd.c
- Timestamp:
- Jul 6, 2011, 8:21:13 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/source3/lib/system_smbd.c
r454 r599 28 28 #ifndef HAVE_GETGROUPLIST 29 29 30 #ifdef HAVE_GETGRSET 31 static 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 30 80 /* 31 81 This is a *much* faster way of getting the list of groups for a user … … 118 168 #endif 119 169 } 120 #endif 170 #endif /* HAVE_GETGRSET */ 171 #endif /* HAVE_GETGROUPLIST */ 121 172 122 173 static int sys_getgrouplist(const char *user, gid_t gid, gid_t *groups, int *grpcnt) … … 136 187 retval = getgrouplist(user, gid, groups, grpcnt); 137 188 #else 189 #ifdef HAVE_GETGRSET 190 retval = getgrouplist_getgrset(user, gid, groups, grpcnt); 191 #else 138 192 become_root(); 139 193 retval = getgrouplist_internals(user, gid, groups, grpcnt); 140 194 unbecome_root(); 141 #endif 195 #endif /* HAVE_GETGRSET */ 196 #endif /* HAVE_GETGROUPLIST */ 142 197 143 198 /* allow winbindd lookups, but only if they were not already disabled */
Note:
See TracChangeset
for help on using the changeset viewer.