Suggest badname if name has special characters

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2076819

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
This commit is contained in:
Iker Pedrosa 2022-04-26 16:45:04 +02:00 committed by Serge Hallyn
parent 58b6e97a9e
commit 0593b330d8
3 changed files with 4 additions and 3 deletions

View File

@ -383,7 +383,7 @@ static int add_user (const char *name, uid_t uid, gid_t gid)
/* Check if this is a valid user name */ /* Check if this is a valid user name */
if (!is_valid_user_name (name)) { if (!is_valid_user_name (name)) {
fprintf (stderr, fprintf (stderr,
_("%s: invalid user name '%s'\n"), _("%s: invalid user name '%s': use --badname to ignore\n"),
Prog, name); Prog, name);
return -1; return -1;
} }

View File

@ -470,7 +470,8 @@ static void check_pw_file (int *errors, bool *changed)
*/ */
if (!is_valid_user_name (pwd->pw_name)) { if (!is_valid_user_name (pwd->pw_name)) {
printf (_("invalid user name '%s'\n"), pwd->pw_name); printf (_("invalid user name '%s': use --badname to ignore\n"),
pwd->pw_name);
*errors += 1; *errors += 1;
} }

View File

@ -1095,7 +1095,7 @@ static void process_flags (int argc, char **argv)
case 'l': case 'l':
if (!is_valid_user_name (optarg)) { if (!is_valid_user_name (optarg)) {
fprintf (stderr, fprintf (stderr,
_("%s: invalid user name '%s'\n"), _("%s: invalid user name '%s': use --badname to ignore\n"),
Prog, optarg); Prog, optarg);
exit (E_BAD_ARG); exit (E_BAD_ARG);
} }