From 8335d0edc2f01e6e93346422388d7ad47ec852bc Mon Sep 17 00:00:00 2001 From: Yaroslav Tykhiy Date: Mon, 28 Jan 2002 17:59:09 +0000 Subject: [PATCH] Keep similar things together: Check for too long usernames inside the function that verifies username validity. --- usr.sbin/adduser/adduser.perl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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;