Lines Matching defs:groups

38 	    "  -u <user>         Target user (name or UID; name sets groups)\n"
41 " -i Keep current groups, unless explicitly overridden\n"
43 " -G <g1,g2,...> Set supplementary groups (name or GID list)\n"
44 " -s <mods> Modify supplementary groups using:\n"
362 gid_t *groups;
367 .groups = NULL,
380 const size_t new_size = new_nb * sizeof(*ga->groups);
383 ga->groups = realloc(ga->groups, new_size);
384 if (ga->groups == NULL)
385 err(EXIT_FAILURE, "realloc of groups failed");
406 qsort(ga->groups, ga->nb, sizeof(gid_t), gidp_cmp);
409 if (ga->groups[i] != ga->groups[j])
410 ga->groups[++j] = ga->groups[i];
430 cand = set->groups[0];
431 to_rem = remove->groups[0];
437 set->groups[to] = cand;
439 cand = set->groups[++from];
443 cand = set->groups[++from];
446 to_rem = remove->groups[++rem]; /* No duplicates. */
450 to_rem = remove->groups[++rem];
456 /* All remaining groups in 'set' must be kept. */
460 memmove(set->groups + to, set->groups + from,
576 * groups.
585 * of them in the password database and using its groups would
607 * supplementary groups ones, in which case the final result
633 * Determine primary groups.
637 * When not starting from the current groups, we need to set all
638 * primary groups. If '-g' was not passed, we use the primary
651 "must specify primary groups or a user name "
686 * Determine supplementary groups.
700 * Determine the supplementary groups to start with, but only if we
709 * If we are to replace supplementary groups (i.e.,
712 * start from those in the groups database if we were
715 * conflation in the groups database), else we simply
722 "groups set or a user name with an entry "
726 gid_t *groups;
729 groups = malloc(sizeof(*groups) * ngroups_alloc);
730 if (groups == NULL)
733 "user groups from the groups database");
736 getgrouplist(user_name, pw->pw_gid, groups, &ngroups);
740 "too many groups for user '%s'",
744 memcpy(supp_groups.groups + supp_groups.nb - ngroups,
745 groups, ngroups * sizeof(*groups));
746 free(groups);
751 * but we still have to set the supplementary groups to
752 * those of the groups database.
763 if (getgroups(ngroups, supp_groups.groups +
779 * We will set the supplementary groups to exactly the set
781 * "base" groups (current ones or those from the groups
795 supp_groups.groups[supp_groups.nb - 1] = g;
825 supp_groups.groups[supp_groups.nb - 1] = gid;
828 supp_rem.groups[supp_rem.nb - 1] = gid;
844 * new supplementary groups set (array sorted and without duplicates),
845 * so we don't do it here unless we need to remove some groups, where it
846 * enables more efficient algorithms (if the number of groups for some
857 wcred.sc_supp_groups = supp_groups.groups;