Re: [patch] document useradd behavior when run without the -g option

Johannes Winkelmann <[email protected]> Wed, 12 Apr 2006 12:00:28 +0200
Newsgroups gmane.linux.pld.shadow.general
Message-ID <[email protected]>
Hi,

On Sat, Apr 08, 2006 at 11:19:21 +0200, Johannes Winkelmann wrote:
[...]
> I think however that using -n and -g together should issue an error,
> since it's not quite clear what the primary group would be in this case.
> The attached patch does this (plus simplifies the if to reflect that
> nflg and gflg are exclusive); it introduces a new string which need to
> be translated though.

The attached patch avoids printing a confusing warning when nflg is not
set, and one tries to add a user with the same name as an existing
group, like:

# groupadd tester
# useradd tester (would create uid=tester, gid=users/default)

This currently prints an error message "group tester exists - if you
want to add this user to that group, use -g." which makes sense if the
-n switch is used, i.e. uid=tester gid=tester was requested, but not
anymore with Mike's patch. 

The original patch introducing this message took nflg into account [1],
but this part was removed since nflg wasn't there yet at that point in
time [2].

Depends on Mike Frysinger's shadow-fix-useradd-usergroups.patch and my
previous patch to make nflg and gflg exclusive.


Feedback welcome.
Regards, Johannes

References:
 1. http://cvs.pld.org.pl/shadow/src/useradd.c?r1=1.20&r2=1.21
 2. http://cvs.pld.org.pl/shadow/src/useradd.c?r1=1.21&r2=1.22
-- 
Johannes Winkelmann              mailto:[email protected]
Zurich, Switzerland              http://jw.smts.ch
useradd-usergroup.diff (text/plain, 289 B)
--- useradd.c-r1.92	2006-04-12 10:58:55.000000000 +0200
+++ useradd.c	2006-04-12 11:05:03.000000000 +0200
@@ -1733,7 +1733,7 @@
 	 * to that group, use useradd -g username username.
 	 * --bero
 	 */
-	if (!gflg) {
+	if (nflg) {
 		if (getgrnam (user_name)) {
 			fprintf (stderr,
 				 _