Remove the newly added -force option because it made adduser(8)

less robust to possible errors of the user/admin while adduser(8)
had been intended to minimize their possibility.
An alternative way of introducing strange symbols into usernames
to be committed really soon.
This commit is contained in:
Yaroslav Tykhiy 2002-01-28 16:37:35 +00:00
parent 46948173e8
commit 743511b28c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=89921
2 changed files with 2 additions and 29 deletions

View file

@ -37,7 +37,6 @@
.Op Fl class Ar login_class
.Op Fl config_create
.Op Fl dotdir Ar dotdir
.Op Fl f | force
.Op Fl group Ar login_group
.Op Fl h | help
.Op Fl home Ar home
@ -61,9 +60,6 @@ directory, dotfiles and sends the new user a welcome message.
.It Sy username
Login name.
May contain only lowercase characters or digits.
(See also the
.Fl force
option.)
Maximum length
is 16 characters (see
.Xr setlogin 2
@ -158,10 +154,6 @@ to read/execute/write
.Pa prv ,
.Pa iscreen ,
.Pa term .
.It Fl force , f
Add a user even if the username contains illegal characters.
Only semicolon or newline characters will be disallowed in
usernames to avoid breaking the password file format.
.It Fl group Ar login_group
Login group.
.Ar USER

View file

@ -30,7 +30,6 @@
# read variables
sub variables {
$verbose = 1; # verbose = [0-2]
$force = 0; # relax username validity check if true
$defaultusepassword = "yes"; # use password authentication for new users
$defaultenableaccount = "yes"; # enable the account by default
$defaultemptypassword = "no"; # don't create an empty password
@ -328,29 +327,13 @@ sub new_users_name {
sub new_users_name_valid {
local($name) = @_;
if ($force) {
if ($name eq "a-z0-9_-") {
warn "Please enter a username.\a\n";
return 0;
}
if ($name =~ /[:\n]/) {
warn "Illegal username, which would break your passwd file.\a\n";
return 0;
}
if ($name !~ /^[a-z0-9_][a-z0-9_\-]*$/) {
warn "Caution: Username contains illegal characters.\n" .
"Adding this user may cause utilities " .
"or applications to malfunction,\n" .
"or even impose a security risk on your system.\a\n";
}
} elsif ($name !~ /^[a-z0-9_][a-z0-9_\-]*$/ || $name eq "a-z0-9_-") {
if ($name !~ /^[a-z0-9_][a-z0-9_\-]*$/ || $name eq "a-z0-9_-") {
warn "Illegal username.\n" .
"Please use only lowercase Roman, decimal, underscore, " .
"or hyphen characters.\n" .
"Additionally, a username should not start with a hyphen.\a\n";
return 0;
}
if ($username{$name}) {
} elsif ($username{$name}) {
warn "Username ``$name'' already exists!\a\n"; return 0;
}
return 1;
@ -878,7 +861,6 @@ usage: adduser
[-class login_class]
[-config_create]
[-dotdir dotdir]
[-f|-force]
[-group login_group]
[-h|-help]
[-home home]
@ -952,7 +934,6 @@ sub parse_arguments {
if (/^--?(v|verbose)$/) { $verbose = 1 }
elsif (/^--?(s|silent|q|quiet)$/) { $verbose = 0 }
elsif (/^--?(debug)$/) { $verbose = 2 }
elsif (/^--?(f|force)$/) { $force = 1 }
elsif (/^--?(h|help|\?)$/) { &usage }
elsif (/^--?(home)$/) { $home = $argv[0]; shift @argv }
elsif (/^--?(shell)$/) { $defaultshell = $argv[0]; shift @argv }