|
version 1.1.1.2, 2013/10/14 07:51:14
|
version 1.1.1.3, 2016/11/01 09:54:32
|
|
Line 3
|
Line 3
|
| * |
* |
| * Copyright (C) 1996 Andrew Tridgell |
* Copyright (C) 1996 Andrew Tridgell |
| * Copyright (C) 1996 Paul Mackerras |
* Copyright (C) 1996 Paul Mackerras |
| * Copyright (C) 2004-2013 Wayne Davison | * Copyright (C) 2004-2015 Wayne Davison |
| * |
* |
| * This program is free software; you can redistribute it and/or modify |
* This program is free software; you can redistribute it and/or modify |
| * it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
|
Line 473 void parse_name_map(char *map, BOOL usernames)
|
Line 473 void parse_name_map(char *map, BOOL usernames)
|
| usernames ? "user" : "group", cp); |
usernames ? "user" : "group", cp); |
| exit_cleanup(RERR_SYNTAX); |
exit_cleanup(RERR_SYNTAX); |
| } |
} |
| if (dash) | if (dash) { |
| | *dash = '\0'; |
| noiu.max_id = id_parse(dash+1); |
noiu.max_id = id_parse(dash+1); |
| else | } else |
| noiu.max_id = 0; |
noiu.max_id = 0; |
| flags = 0; |
flags = 0; |
| id1 = id_parse(cp); |
id1 = id_parse(cp); |
| |
if (dash) |
| |
*dash = '-'; |
| } else if (strpbrk(cp, "*[?")) { |
} else if (strpbrk(cp, "*[?")) { |
| flags = NFLAGS_WILD_NAME_MATCH; |
flags = NFLAGS_WILD_NAME_MATCH; |
| noiu.name = cp; |
noiu.name = cp; |
|
Line 521 void parse_name_map(char *map, BOOL usernames)
|
Line 524 void parse_name_map(char *map, BOOL usernames)
|
| } |
} |
| |
|
| #ifdef HAVE_GETGROUPLIST |
#ifdef HAVE_GETGROUPLIST |
| const char *getallgroups(uid_t uid, gid_t *gid_list, int *size_ptr) | const char *getallgroups(uid_t uid, item_list *gid_list) |
| { |
{ |
| struct passwd *pw; |
struct passwd *pw; |
| |
gid_t *gid_array; |
| |
int size; |
| |
|
| if ((pw = getpwuid(uid)) == NULL) |
if ((pw = getpwuid(uid)) == NULL) |
| return "getpwuid failed"; |
return "getpwuid failed"; |
| |
|
| |
gid_list->count = 0; /* We're overwriting any items in the list */ |
| |
EXPAND_ITEM_LIST(gid_list, gid_t, 32); |
| |
size = gid_list->malloced; |
| |
|
| /* Get all the process's groups, with the pw_gid group first. */ |
/* Get all the process's groups, with the pw_gid group first. */ |
| if (getgrouplist(pw->pw_name, pw->pw_gid, gid_list, size_ptr) < 0) | if (getgrouplist(pw->pw_name, pw->pw_gid, gid_list->items, &size) < 0) { |
| return "getgrouplist failed"; | if (size > (int)gid_list->malloced) { |
| | gid_list->count = gid_list->malloced; |
| | EXPAND_ITEM_LIST(gid_list, gid_t, size); |
| | if (getgrouplist(pw->pw_name, pw->pw_gid, gid_list->items, &size) < 0) |
| | size = -1; |
| | } else |
| | size = -1; |
| | if (size < 0) |
| | return "getgrouplist failed"; |
| | } |
| | gid_list->count = size; |
| | gid_array = gid_list->items; |
| | |
| /* Paranoia: is the default group not first in the list? */ |
/* Paranoia: is the default group not first in the list? */ |
| if (gid_list[0] != pw->pw_gid) { | if (gid_array[0] != pw->pw_gid) { |
| int j; |
int j; |
| for (j = 0; j < *size_ptr; j++) { | for (j = 1; j < size; j++) { |
| if (gid_list[j] == pw->pw_gid) { | if (gid_array[j] == pw->pw_gid) |
| gid_list[j] = gid_list[0]; | |
| gid_list[0] = pw->pw_gid; | |
| break; |
break; |
| } |
|
| } |
} |
| |
if (j == size) { /* The default group wasn't found! */ |
| |
EXPAND_ITEM_LIST(gid_list, gid_t, size+1); |
| |
gid_array = gid_list->items; |
| |
} |
| |
gid_array[j] = gid_array[0]; |
| |
gid_array[0] = pw->pw_gid; |
| } |
} |
| |
|
| return NULL; |
return NULL; |
| } |
} |
| #endif |
#endif |