Re: [patch] document useradd behavior when run without the -g option
Johannes Winkelmann <[email protected]> Sat, 8 Apr 2006 11:19:21 +0200
| Newsgroups | gmane.linux.pld.shadow.general |
|---|---|
| Message-ID | <[email protected]> |
Hi Mike, On Fri, Apr 07, 2006 at 22:20:44 -0400, Mike Frysinger wrote: > On Friday 07 April 2006 20:27, Mike Frysinger wrote: > > a user submitted a bug that useradd behaved "incorrectly" when run with the > > -G option but not the -g option [...] > the current behavior of useradd ignores the GROUP setting > in /etc/defaults/useradd when the -g option is not provided. Great. I wasn't quite sure what the plans were for '-n' (see my previous mail), but I definitely prefer your way over Redhat's. 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. Best regards, Johannes -- Johannes Winkelmann mailto:[email protected] Zurich, Switzerland http://jw.tks6.net
shadow-4.0.15-nflg-conflict.diff
(text/plain, 705 B)
--- useradd.c.orig 2006-04-08 10:47:03.016040384 +0200
+++ useradd.c 2006-04-08 11:17:09.218455880 +0200
@@ -1214,6 +1214,16 @@
usage ();
/*
+ * Using -g and -n doesn't make sense
+ */
+ if (nflg && gflg) {
+ fprintf(stderr,
+ _("%s: options -n and -g conflict and can't be used together\n"),
+ Prog);
+ exit (E_BAD_ARG);
+ }
+
+ /*
* Either -D or username is required. Defaults can be set with -D
* for the -b, -e, -f, -g, -s options only.
*/
@@ -1778,7 +1788,7 @@
/* do we have to add a group for that user? This is why we need to
* open the group files in the open_files() function --gafton */
- if (nflg && !gflg) {
+ if (nflg) {
find_new_gid ();
grp_add ();
}