diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2001-09-07 20:34:12 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2001-09-07 20:34:12 +0000 |
commit | 54aab4a77a7153d8644e75b0acd438516a60c84a (patch) | |
tree | 82c604b6b381504ed4ba76bb5fdceb333a3bfdc9 | |
parent | 0be9d67d305749cdc036b9949925eeb5ac5acbeb (diff) |
Cleanup from Brian Poole:
o remove useless copyright() sub since it does nothing
o remov unused variables
o clear hashes properly
o grammar/spelling fixes
o pass perl -w
o unlock the ptmp file before we close it, not after
o parse args in config_read() correctly
o man page cleanup
-rw-r--r-- | usr.sbin/adduser/adduser.8 | 15 | ||||
-rw-r--r-- | usr.sbin/adduser/adduser.perl | 57 |
2 files changed, 35 insertions, 37 deletions
diff --git a/usr.sbin/adduser/adduser.8 b/usr.sbin/adduser/adduser.8 index 09e912690d1..207c65d3a9a 100644 --- a/usr.sbin/adduser/adduser.8 +++ b/usr.sbin/adduser/adduser.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: adduser.8,v 1.23 2001/07/20 19:09:46 mpech Exp $ +.\" $OpenBSD: adduser.8,v 1.24 2001/09/07 20:34:11 millert Exp $ .\" .\" Copyright (c) 1995-1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. .\" All rights reserved. @@ -46,7 +46,7 @@ .Op Fl dotdir Ar directory .Oo .Fl e -.Ar method No \&| Fl encrypt_method Ar method +.Ar method No \&| Fl encryption Ar method .Oc .Op Fl group Ar login_group .Op Fl h | help | ? @@ -55,7 +55,6 @@ .Op Fl noconfig .Op Fl shell Ar shell .Op Fl s | silent | q | quiet -.Op Fl uid Ar uid .Op Fl uid_start Ar uid .Op Fl uid_end Ar uid .Op Fl v | verbose @@ -102,7 +101,7 @@ their owner. .\" don't allow group or world to write files and allow only owner .\" to read/execute/write .rhost, .Xauthority, .kermrc, .netrc, Mail, .\" prv, iscreen, term. -.It Fl encrypt Ns No , Fl e Ar method +.It Fl encryption Ns No , Fl e Ar method Encrypt local passwords using .Ar method of encryption as described in @@ -137,10 +136,14 @@ Specify the default shell for new users. .Fl quiet Ns No , Fl q .Xc Causes the program to print fewer warnings, questions, and bug reports. -.It Fl uid Ar uid +.It Fl uid_start Ar uid Use UIDs from .Ar uid up when automatically generating UIDs. +.It Fl uid_end Ar uid +Do not use UIDs higher than +.Ar uid +when generating UIDs. .It Fl unencrypted Causes the program to assume that the password given in batch mode is unencrypted. @@ -348,6 +351,8 @@ user database group database .It Pa /etc/shells shell database +.It Pa /etc/ptmp +lock file for the passwd database .It Pa /etc/adduser.conf configuration file for .Nm adduser diff --git a/usr.sbin/adduser/adduser.perl b/usr.sbin/adduser/adduser.perl index 723e3efc5f4..aa2e6908ce7 100644 --- a/usr.sbin/adduser/adduser.perl +++ b/usr.sbin/adduser/adduser.perl @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# $OpenBSD: adduser.perl,v 1.31 2001/09/03 16:19:32 millert Exp $ +# $OpenBSD: adduser.perl,v 1.32 2001/09/07 20:34:11 millert Exp $ # # Copyright (c) 1995-1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. # All rights reserved. @@ -48,7 +48,7 @@ $SIG{'TERM'} = 'cleanup'; &parse_arguments(@ARGV); # parse arguments if (!$check_only && $#batch < 0) { - ©right; &hints; + &hints; } # check @@ -89,7 +89,7 @@ sub variables { $group = "/etc/group"; $pwd_mkdb = "pwd_mkdb -p"; # program for building passwd database $encryptionmethod = "blowfish"; - $rcsid = '$OpenBSD: adduser.perl,v 1.31 2001/09/03 16:19:32 millert Exp $'; + $rcsid = '$OpenBSD: adduser.perl,v 1.32 2001/09/07 20:34:11 millert Exp $'; # List of directories where shells located @path = ('/bin', '/usr/bin', '/usr/local/bin'); @@ -107,19 +107,19 @@ sub variables { # global variables # passwd - $username = ''; # $username{username} = uid - $uid = ''; # $uid{uid} = username - $pwgid = ''; # $pwgid{pwgid} = username; gid from passwd db + %username = (); # $username{username} = uid + %uid = (); # $uid{uid} = username + %pwgid = (); # $pwgid{pwgid} = username; gid from passwd db $password = ''; # password for new users # group - $groupname =''; # $groupname{groupname} = gid - $groupmembers = ''; # $groupmembers{gid} = members of group/kommalist - $gid = ''; # $gid{gid} = groupname; gid form group db + %groupname = (); # $groupname{groupname} = gid + %groupmembers = (); # $groupmembers{gid} = members of group/kommalist + %gid = ''; # $gid{gid} = groupname; gid form group db # shell - $shell = ''; # $shell{`basename sh`} = sh + %shell = ''; # $shell{`basename sh`} = sh # only for me (=Wolfram) if ($test) { @@ -149,7 +149,7 @@ sub shells_read { local($err) = 0; print "Reading $etc_shells\n" if $verbose; - open(S, $etc_shells) || die "$etc_shells:$!\n"; + open(S, $etc_shells) || die "$etc_shells: $!\n"; while(<S>) { if (/^\s*\//) { @@ -262,7 +262,7 @@ sub home_partition_valid { $h = &stripdir($h); # all right (I hope) - return $h if $h =~ "^/" && -e $h && -w $h && (-d $h || -l $h); + return $h if $h =~ "^/" && -e $h && -w _ && (-d _ || -l $h); # Errors or todo if ($h !~ "^/") { @@ -291,7 +291,7 @@ sub passwd_check { # read /etc/passwd sub passwd_read { - local($p_username, $pw, $p_uid, $p_gid, $sh, %shlist); + local($p_username, $pw, $p_uid, $p_gid, $sh); print "Check $etc_passwd\n" if $verbose; open(P, "$etc_passwd") || die "$etc_passwd: $!\n"; @@ -379,7 +379,7 @@ sub new_users_name_valid { local($name) = @_; if ($name !~ /^[a-z0-9_][a-z0-9_\-]*$/ || $name eq "a-z0-9_-") { - warn "Wrong username. " . + warn "Illegal username. " . "Please use only lowercase characters or digits\a\n"; return 0; } elsif ($username{$name}) { @@ -458,8 +458,8 @@ sub add_group { # Longer lines will be skiped. if ($#l >= 200 || length($groupmembers{$gid}) > 1024 - 50) { # 50 is for group name - warn "WARNING, maybe group line ``$gid{$gid}'' is to long or to\n" . - "much users in group, see group(5)\a\n"; + warn "WARNING, group line ``$gid{$gid}'' is either too long or has\n" . + "too many users in the group, see group(5)\a\n"; } return $name; } @@ -896,7 +896,7 @@ USAGE # uniq(1) sub uniq { local(@list) = @_; - local($e, $last, @array); + local($e, $last = "", @array); foreach $e (sort @list) { push(@array, $e) unless $e eq $last; @@ -941,7 +941,6 @@ sub salt { sub encrypt { local($pass, $salt) = ($_[0], $_[1]); local($args, $crypt); - local($goodpass); if ($encryptionmethod eq "des" || $encryptionmethod eq "old") { $args = "-s $salt"; @@ -961,11 +960,6 @@ sub encrypt { return($crypt); } -# print banner -sub copyright { - return; -} - # hints sub hints { if ($verbose) { @@ -1000,7 +994,7 @@ sub parse_arguments { die "batch: too few arguments\n" if $#batch < 0; } # see &config_read - elsif (/^--?(config_create)$/) { ©right; &hints; &create_conf; exit(0); } + elsif (/^--?(config_create)$/) { &hints; &create_conf; exit(0); } elsif (/^--?(noconfig)$/) { $config_read = 0; } elsif (/^--?(e|encryption)$/) { $encryptionmethod = $argv[0]; @@ -1028,7 +1022,7 @@ sub dirname { # return 1 if $file is a readable file or link sub filetest { - local($file, $verb) = @_; + local($file, $verbose) = @_; if (-e $file) { if (-f $file || -l $file) { @@ -1362,13 +1356,13 @@ sub append_file { print "Lock $file.\n" if $verbose > 1; while(!flock(F, LOCK_EX | LOCK_NB)) { warn "Cannot lock file: $file\a\n"; - die "Sorry, give up\n" + die "Sorry, gave up\n" unless &confirm_yn("Try again?", "yes"); } print F join("\n", @list) . "\n"; - close F; print "Unlock $file.\n" if $verbose > 1; flock(F, LOCK_UN); + close F; } # return free uid+gid @@ -1390,7 +1384,7 @@ sub next_id { $gid_start = $groupname{$group}; } # gid is in use, looking for another gid. - # Note: uid an gid are not equal + # Note: uid and gid are not equal elsif ($gid{$uid_start}) { while($gid{$gid_start} || $uid{$gid_start}) { $gid_start--; @@ -1402,7 +1396,7 @@ sub next_id { # read config file - typically /etc/adduser.conf sub config_read { - local($opt) = @_; + local($opt) = join " ", @_; local($user_flag) = 0; # don't read config file @@ -1525,8 +1519,6 @@ EOF # check for sane variables sub variable_check { - local($abort) = 0; - # Check uid_start & uid_end warn "WARNING: uid_start < 1000!\n" if($uid_start < 1000); die "ERROR: uid_start >= uid_end!\n" if($uid_start >= $uid_end); @@ -1543,7 +1535,8 @@ sub cleanup { } END { - if (-e $etc_ptmp) { + if (-e $etc_ptmp && defined PTMP) { + close PTMP; unlink($etc_ptmp) || warn "Error: unable to remove $etc_ptmp: $!\nPlease verify that $etc_ptmp no longer exists!\n"; } } |