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
@@ -386,10 +386,16 @@ static int add_user (const char *name, uid_t uid, gid_t gid)
struct passwd pwent;
/* Check if this is a valid user name */
if (!is_valid_user_name (name)) {
fprintf (stderr,
_("%s: invalid user name '%s': use --badname to ignore\n"),
Prog, name);
if (!is_valid_user_name(name)) {
if (errno == EINVAL) {
fprintf(stderr,
_("%s: invalid user name '%s': use --badname to ignore\n"),
Prog, name);
} else {
fprintf(stderr,
_("%s: invalid user name '%s'\n"),
Prog, name);
}
return -1;
}