# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $Id: adduser.perl,v 1.28 1997/03/09 12:21:45 wosch Exp $
+# $Id: adduser.perl,v 1.35 1997/08/26 22:47:51 wosch Exp $
# read variables
# shell
$shell = ''; # $shell{`basename sh`} = sh
- # only for me (=Wolfram)
- if ($test) {
- $home = "/home/w/tmp/adduser/home";
- $etc_shells = "./shells";
- $etc_passwd = "./master.passwd";
- $group = "./group";
- $pwd_mkdb = "pwd_mkdb -p -d .";
- $config = "adduser.conf";
- $send_message = "./adduser.message";
- $logfile = "./log.adduser";
- }
-
umask 022; # don't give login group write access
$ENV{'PATH'} = "/sbin:/bin:/usr/sbin:/usr/bin";
}
}
-# Allow /nonexistent and /bin/date as a valid shell for system utils
+ # Allow /nonexistent and /bin/date as a valid shell for system utils
push(@list, "/nonexistent");
- push(@shellpref, "no");
+ push(@shellpref, "no") if !grep(/^no$/, @shellpref);
$shell{"no"} = "/nonexistent";
push(@list, "/bin/date");
- push(@shellpref, "date");
+ push(@shellpref, "date") if !grep(/^date$/, @shellpref);
$shell{"date"} = "/bin/date";
return $err;
if ($verbose && $sh &&
!$shell{&basename($sh)} &&
$p_username !~ /^(news|xten|bin|nobody|uucp)$/ &&
- $sh !~ /\/(pppd|sliplogin)$/);
+ $sh !~ /\/(pppd|sliplogin|nologin)$/);
$uid{$p_uid} = $p_username;
$pwgid{$p_gid} = $p_username;
}
sub new_users_name_valid {
local($name) = @_;
- if ($name !~ /^[a-z0-9_][a-z0-9_\-]*$/) {
+ if ($name !~ /^[a-z0-9_][a-z0-9_\-]*$/ || $name eq "a-z0-9_-") {
warn "Wrong username. " .
"Please use only lowercase characters or digits\a\n";
return 0;
local($def) = @_;
local($class);
- $class = &confirm_list("Enter login class", 1, $def, "");
+ $class = &confirm_list("Enter login class:", 1, $def, ($def, "default"));
+ $class = "" if $class eq "default";
return $class;
}
# copy files from $dotdir to $homedir
# rename 'dot.foo' files to '.foo'
print "Copy files from $dotdir to $homedir\n" if $verbose;
- system("cp -r $dotdir $homedir");
+ system("cp -R $dotdir $homedir");
system("chmod -R u+wrX,go-w $homedir");
system("chown -R $name:$group $homedir");