summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1997-08-07 02:57:25 +0000
committerMiles Bader <miles@gnu.org>1997-08-07 02:57:25 +0000
commit70ae496acfdcafbc4d4182e0bc72a1d9e62dd211 (patch)
treeb5af8e64d4b0a729ec77c629ff67d0a580fcac83
parentbc9e0e168b9197effb7893b4ca84584172481a7f (diff)
(ugids_set_posix_user):
Ignore errors from idvec_merge_implied_gids.
-rw-r--r--libshouldbeinlibc/ugids-posix.c102
1 files changed, 50 insertions, 52 deletions
diff --git a/libshouldbeinlibc/ugids-posix.c b/libshouldbeinlibc/ugids-posix.c
index b8ed8e74..35d73e32 100644
--- a/libshouldbeinlibc/ugids-posix.c
+++ b/libshouldbeinlibc/ugids-posix.c
@@ -33,62 +33,60 @@ ugids_set_posix_user (struct ugids *ugids, uid_t uid)
uid_t uids_ids[] = { uid };
struct idvec uids = { uids_ids, 1 };
- err = idvec_merge_implied_gids (&imp_gids, &uids);
+ error_t update_real (struct idvec *avail_ids, uid_t id)
+ {
+ if (avail_ids->num == 0
+ || !idvec_tail_contains (avail_ids, 1, avail_ids->ids[0]))
+ return idvec_insert (avail_ids, 0, id);
+ else
+ avail_ids->ids[0] = id;
+ return 0;
+ }
+
+ idvec_merge_implied_gids (&imp_gids, &uids);
+
+ /* Try to add UID. */
+ err = idvec_insert_only (&ugids->eff_uids, 0, uid); /* Effective */
+ if (! err)
+ err = update_real (&ugids->avail_uids, uid); /* Real */
if (! err)
+ err = idvec_insert_only (&ugids->avail_uids, 1, uid); /* Saved */
+
+ if (!err && imp_gids.num > 0)
+ /* Now do the gids. */
{
- error_t update_real (struct idvec *avail_ids, uid_t id)
- {
- if (avail_ids->num == 0
- || !idvec_tail_contains (avail_ids, 1, avail_ids->ids[0]))
- return idvec_insert (avail_ids, 0, id);
- else
- avail_ids->ids[0] = id;
- return 0;
- }
-
- /* Try to add UID. */
- err = idvec_insert_only (&ugids->eff_uids, 0, uid); /* Effective */
+ /* The main gid associated with UID (usually from /etc/passwd). */
+ gid_t gid = imp_gids.ids[0];
+ /* True if GID was already an available gid. */
+ int gid_was_avail = idvec_contains (&ugids->avail_gids, gid);
+
+ /* Update the implied sets for the gids: they're implied unless
+ they were present as non-implied gids before. Here we
+ remove existing effective gids from the IMP_GIDS before we
+ added it to the implied sets -- if some of those gids were
+ actually implied, they'll already be present in the implied
+ set. */
+ idvec_subtract (&imp_gids, &ugids->eff_gids);
+
+ /* Now add GID, as effective, real, and saved gids. */
+ if (! err) /* Effective */
+ err = idvec_insert_only (&ugids->eff_gids, 0, gid);
+ if (! err) /* Real */
+ err = update_real (&ugids->avail_gids, gid);
+ if (! err) /* Saved */
+ err = idvec_insert_only (&ugids->avail_gids, 1, gid);
+
+ /* Mark GID as implied in the available gids unless it was already
+ present (in which case its implied status is already settled). */
+ if (!err && !gid_was_avail)
+ err = idvec_add (&ugids->imp_avail_gids, gid);
+
+ /* Add the other implied gids to the end of the effective gids. */
if (! err)
- err = update_real (&ugids->avail_uids, uid); /* Real */
+ err = idvec_merge (&ugids->eff_gids, &imp_gids);
+ /* And make them implied. */
if (! err)
- err = idvec_insert_only (&ugids->avail_uids, 1, uid); /* Saved */
-
- if (!err && imp_gids.num > 0)
- /* Now do the gids. */
- {
- /* The main gid associated with UID (usually from /etc/passwd). */
- gid_t gid = imp_gids.ids[0];
- /* True if GID was already an available gid. */
- int gid_was_avail = idvec_contains (&ugids->avail_gids, gid);
-
- /* Update the implied sets for the gids: they're implied unless
- they were present as non-implied gids before. Here we
- remove existing effective gids from the IMP_GIDS before we
- added it to the implied sets -- if some of those gids were
- actually implied, they'll already be present in the implied
- set. */
- idvec_subtract (&imp_gids, &ugids->eff_gids);
-
- /* Now add GID, as effective, real, and saved gids. */
- if (! err) /* Effective */
- err = idvec_insert_only (&ugids->eff_gids, 0, gid);
- if (! err) /* Real */
- err = update_real (&ugids->avail_gids, gid);
- if (! err) /* Saved */
- err = idvec_insert_only (&ugids->avail_gids, 1, gid);
-
- /* Mark GID as implied in the available gids unless it was already
- present (in which case its implied status is already settled). */
- if (!err && !gid_was_avail)
- err = idvec_add (&ugids->imp_avail_gids, gid);
-
- /* Add the other implied gids to the end of the effective gids. */
- if (! err)
- err = idvec_merge (&ugids->eff_gids, &imp_gids);
- /* And make them implied. */
- if (! err)
- err = idvec_merge (&ugids->imp_eff_gids, &imp_gids);
- }
+ err = idvec_merge (&ugids->imp_eff_gids, &imp_gids);
}
idvec_fini (&imp_gids);