Validate that two of the -L, -p, and -U options are not used at the same

time after the parsing of options. -U used to be allowed after -p or -L,
but not before.
This commit is contained in:
nekral-guest 2007-11-17 14:33:26 +00:00
parent 71392cdc8f
commit 488184394e
2 changed files with 15 additions and 10 deletions

View File

@ -1,6 +1,12 @@
2007-11-17 Nicolas François <nicolas.francois@centraliens.net> 2007-11-17 Nicolas François <nicolas.francois@centraliens.net>
* src/usermod.c: Make usermod -d and -m work independant of the * src/usermod.c: Validate that two of the -L, -p, and -U options
are not used at the same time after the parsing of options. -U
used to be allowed after -p or -L, but not before.
2007-11-17 Nicolas François <nicolas.francois@centraliens.net>
* src/usermod.c: Make usermod -d and -m work independent of the
argument order. Thanks to Justin Pryzby <jpryzby+d@quoininc.com> argument order. Thanks to Justin Pryzby <jpryzby+d@quoininc.com>
for the patch. This fixes Debian's bug #451518. for the patch. This fixes Debian's bug #451518.

View File

@ -981,9 +981,6 @@ static void process_flags (int argc, char **argv)
user_newname = optarg; user_newname = optarg;
break; break;
case 'L': case 'L':
if (Uflg || pflg)
usage ();
Lflg++; Lflg++;
break; break;
case 'm': case 'm':
@ -996,9 +993,6 @@ static void process_flags (int argc, char **argv)
oflg++; oflg++;
break; break;
case 'p': case 'p':
if (Lflg || Uflg)
usage ();
user_pass = optarg; user_pass = optarg;
pflg++; pflg++;
break; break;
@ -1021,9 +1015,6 @@ static void process_flags (int argc, char **argv)
uflg++; uflg++;
break; break;
case 'U': case 'U':
if (Lflg && pflg)
usage ();
Uflg++; Uflg++;
break; break;
default: default:
@ -1056,6 +1047,14 @@ static void process_flags (int argc, char **argv)
exit (E_USAGE); exit (E_USAGE);
} }
if ((Lflg && (pflg || Uflg)) || (pflg && Uflg)) {
fprintf (stderr,
_("%s: the -L, -p, and -U flags are exclusive\n"),
Prog);
usage ();
exit (E_USAGE);
}
if (mflg && !dflg) { if (mflg && !dflg) {
fprintf (stderr, fprintf (stderr,
_("%s: -m flag is ONLY allowed with the -d flag\n"), _("%s: -m flag is ONLY allowed with the -d flag\n"),