diff --git a/usr.sbin/adduser/adduser.perl b/usr.sbin/adduser/adduser.perl index 2aa9c319b877..322bac6e2541 100644 --- a/usr.sbin/adduser/adduser.perl +++ b/usr.sbin/adduser/adduser.perl @@ -317,10 +317,6 @@ sub new_users_name { while(1) { $name = &confirm_list("Enter username", 1, $usernameregexp, ""); - if (length($name) > 16) { - warn "Username is longer than 16 chars\a\n"; - next; - } last if (&new_users_name_valid($name)); } return $name; @@ -332,6 +328,9 @@ sub new_users_name_valid { if ($name eq $usernameregexp) { # user/admin just pressed warn "Please enter a username\a\n"; return 0; + } elsif (length($name) > 16) { + warn "Username is longer than 16 characters.\a\n"; + return 0; } elsif ($name =~ /[:\n]/) { warn "Username cannot contain colon or newline characters.\a\n"; return 0;