src/: Recommend --badname only if it is useful

(Review with -w (--ignore-all-space).)

Closes: <https://github.com/shadow-maint/shadow/issues/1067>
Reported-by: Anselm Schüler <mail@anselmschueler.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2024-08-31 11:55:27 +02:00
committed by Serge Hallyn
parent 0663c91f80
commit 1f11a5ce5a
4 changed files with 38 additions and 15 deletions
+10 -4
View File
@@ -1116,10 +1116,16 @@ process_flags(int argc, char **argv)
usage (E_SUCCESS);
/*@notreached@*/break;
case 'l':
if (!is_valid_user_name (optarg)) {
fprintf (stderr,
_("%s: invalid user name '%s': use --badname to ignore\n"),
Prog, optarg);
if (!is_valid_user_name(optarg)) {
if (errno == EINVAL) {
fprintf(stderr,
_("%s: invalid user name '%s': use --badname to ignore\n"),
Prog, optarg);
} else {
fprintf(stderr,
_("%s: invalid user name '%s'\n"),
Prog, optarg);
}
exit (E_BAD_ARG);
}
lflg = true;