Changeset 1596
- Timestamp:
- Aug 21, 2010, 2:49:50 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/common/oursrc/accountadm/admof.c
r1347 r1596 56 56 parse_rights(int n, const char **p, const char *user) 57 57 { 58 int rights = 0; 59 60 int i; 58 int rights = 0, *trights = malloc(n * sizeof(int)), i; 59 namelist tnames = {.namelist_len = n, 60 .namelist_val = malloc(n * PR_MAXNAMELEN)}; 61 idlist tids = {.idlist_len = 0, 62 .idlist_val = NULL}; 63 61 64 for (i = 0; i < n; ++i) { 62 char tname[PR_MAXNAMELEN];63 int trights;64 65 65 int off; 66 if (sscanf(*p, "%" STR(PR_MAXNAMELEN) "s %d\n%n", tname, &trights, &off) < 2) 66 if (sscanf(*p, "%" STR(PR_MAXNAMELEN) "s %d\n%n", 67 tnames.namelist_val[i], &trights[i], &off) < 2) 67 68 die("internal error: can't parse output from pioctl\n"); 68 69 *p += off; 69 70 if (~rights & trights && 71 (strcasecmp(tname, user) == 0 || 72 (strchr(tname, ':') != 0 && ismember(user, tname)))) 73 rights |= trights; 74 } 70 } 71 72 if (pr_NameToId(&tnames, &tids) != 0) 73 die("internal error: pr_NameToId failed"); 74 if (tids.idlist_len != n) 75 die("internal error: pr_NameToId did not return as many ids as names"); 76 77 for (i = 0; i < n; ++i) { 78 if (~rights & trights[i] && 79 (strcasecmp(tnames.namelist_val[i], user) == 0 || 80 (tids.idlist_val[i] < 0 && ismember(user, tnames.namelist_val[i])))) 81 rights |= trights[i]; 82 } 83 84 /* Note: this first free probably should be xdr_free in OpenAFS 1.5. 85 * See commits b40b606 and f02f2e8 */ 86 free(tids.idlist_val); 87 tids.idlist_val = NULL; 88 free(tnames.namelist_val); 89 free(trights); 75 90 76 91 return rights;
Note: See TracChangeset
for help on using the changeset viewer.