[Pkg-shadow-commits] r1559 - in upstream/trunk: . src
nekral-guest at alioth.debian.org
nekral-guest at alioth.debian.org
Sat Dec 29 17:05:13 UTC 2007
Author: nekral-guest
Date: 2007-12-29 17:05:13 +0000 (Sat, 29 Dec 2007)
New Revision: 1559
Modified:
upstream/trunk/ChangeLog
upstream/trunk/NEWS
upstream/trunk/src/newusers.c
Log:
Do not add the new user to the group's members, because the group is already
the primary group of the new user.
Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog 2007-12-29 14:52:35 UTC (rev 1558)
+++ upstream/trunk/ChangeLog 2007-12-29 17:05:13 UTC (rev 1559)
@@ -1,5 +1,11 @@
2007-12-29 Nicolas François <nicolas.francois at centraliens.net>
+ * NEWS, src/newusers.c: Do not add the new user to the group's
+ members, because the group is already the primary group of the new
+ user.
+
+2007-12-29 Nicolas François <nicolas.francois at centraliens.net>
+
newusers cleanups
* src/newusers.c: main() split in new functions: process_flags(),
check_flags(), check_perms(), open_files(), and close_files().
Modified: upstream/trunk/NEWS
===================================================================
--- upstream/trunk/NEWS 2007-12-29 14:52:35 UTC (rev 1558)
+++ upstream/trunk/NEWS 2007-12-29 17:05:13 UTC (rev 1559)
@@ -28,6 +28,9 @@
- vipw/vigr
* Recommend editing the shadowed (resp. regular) file if the regular (resp.
shadowed) file was edited.
+- newusers
+ * The new users are no more added to the list of members of their groups
+ because the membership is already set by their primary group.
shadow-4.0.18.2 -> shadow-4.1.0 09-12-2008
Modified: upstream/trunk/src/newusers.c
===================================================================
--- upstream/trunk/src/newusers.c 2007-12-29 14:52:35 UTC (rev 1558)
+++ upstream/trunk/src/newusers.c 2007-12-29 17:05:13 UTC (rev 1559)
@@ -108,7 +108,7 @@
const struct passwd *pwd;
const struct group *grp;
struct group grent;
- char *members[2];
+ char *members[1];
int i;
/*
@@ -117,21 +117,9 @@
*/
grp = gr_locate (gid);
if (NULL != grp) {
- add_member:
- grent = *grp;
- *ngid = grent.gr_gid;
- for (i = 0; grent.gr_mem[i] != (char *) 0; i++) {
- if (strcmp (grent.gr_mem[i], name) == 0) {
- return 0;
- }
- }
-
- grent.gr_mem = (char **) xmalloc (sizeof (char *) * (i + 2));
- memcpy (grent.gr_mem, grp->gr_mem, sizeof (char *) * (i + 2));
- grent.gr_mem[i] = xstrdup (name);
- grent.gr_mem[i + 1] = (char *) 0;
-
- return !gr_update (&grent);
+ /* The user will use this ID for her primary group */
+ *ngid = grp->gr_gid;
+ return 0;
}
/*
@@ -156,13 +144,15 @@
} else if ((gid[0] >= '0') && (gid[0] <= '9')) {
/*
* The GID is a number, which means either this is a brand
- * new group, or an existing group. For existing groups I
- * just add myself as a member, just like I did earlier.
+ * new group, or an existing group.
*/
i = atoi (gid);
for (gr_rewind (); (grp = gr_next ());) {
if (grp->gr_gid == (unsigned int)i) {
- goto add_member;
+ /* The user will use this ID for her
+ * primary group */
+ *ngid = grp->gr_gid;
+ return 0;
}
}
} else {
@@ -197,8 +187,7 @@
grent.gr_passwd = "x"; /* XXX warning: const */
grent.gr_gid = i;
- members[0] = xstrdup (name);
- members[1] = (char *) 0;
+ members[0] = NULL;
grent.gr_mem = members;
*ngid = grent.gr_gid;
@@ -615,7 +604,10 @@
* Now the fields are processed one by one. The first field
* to be processed is the group name. A new group will be
* created if the group name is non-numeric and does not
- * already exist. The named user will be the only member. If
+ * already exist. If the group name is a number (which is not
+ * an existing GID), a group with the same name as the user
+ * will be created, with the given GID. The given or created
+ * group will be the primary group of the user. If
* there is no named group to be a member of, the UID will
* be figured out and that value will be a candidate for a
* new group, if that group ID exists, a whole new group ID
More information about the Pkg-shadow-commits
mailing list