From 46ae2113b6bea7fca5963bf9ae2205abadef7427 Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Wed, 21 Nov 2007 21:27:44 +0000 Subject: [PATCH] * Try harder to get the GID equal to the UID. This was not the case when the GID is not specified, and a GID exist with an ID higher than the all the UIDs. * Typo in comment: contrained -> constrained. --- ChangeLog | 7 +++++++ src/newusers.c | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1449de15..1e0495c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-11-21 Nicolas François + + * src/newusers.c: Try harder to get the GID equal to the UID. + This was not the case when the GID is not specified, and a GID + exist with an ID higher than the all the UIDs. + * src/newusers.c: Typo in comment: contrained -> constrained. + 2007-11-20 Nicolas François * src/chgpasswd.c: If the shadow group file is not present, do not diff --git a/src/newusers.c b/src/newusers.c index 15af7c91..239d9a3a 100644 --- a/src/newusers.c +++ b/src/newusers.c @@ -189,7 +189,9 @@ static int add_user (const char *name, const char *uid, uid_t * nuid, gid_t gid) } else if (uid[0] && (pwd = pw_locate (uid))) { i = pwd->pw_uid; } else { - i = 100; + /* Start with gid, either the specified GID, or an ID + * greater than all the group and user IDs */ + i = gid; for (pw_rewind (); (pwd = pw_next ());) if (pwd->pw_uid >= i) i = pwd->pw_uid + 1; @@ -378,7 +380,7 @@ int main (int argc, char **argv) /* * Read each line. The line has the same format as a password file - * entry, except that certain fields are not contrained to be + * entry, except that certain fields are not constrained to be * numerical values. If a group ID is entered which does not already * exist, an attempt is made to allocate the same group ID as the * numerical user ID. Should that fail, the next available group ID