#
# Email: Wolfram Schneider <wosch@cs.tu-berlin.de>
#
-# $Id: adduser.perl,v 1.4 1995/03/08 22:44:37 ache Exp $
+# $Id: adduser.perl,v 1.10 1996/02/10 17:15:47 wosch Exp $
#
# read variables
# List of directories where shells located
@path = ('/bin', '/usr/bin', '/usr/local/bin');
# common shells, first element has higher priority
- @shellpref = ('bash', 'tcsh', 'ksh', 'csh', 'sh');
+ @shellpref = ('csh', 'sh', 'bash', 'tcsh', 'ksh');
- $defaultshell = 'bash'; # defaultshell if not empty
+ $defaultshell = 'sh'; # defaultshell if not empty
$group_uniq = 'USER';
$defaultgroup = $group_uniq;# login groupname, $group_uniq means username
}
}
}
+
+# Allow /nonexistant and /bin/date as a valid shell for system utils
+ push(@list, "/nonexistant");
+ push(@shellpref, "no");
+ $shell{"no"} = "/nonexistant";
+
+ push(@list, "/bin/date");
+ push(@shellpref, "date");
+ $shell{"date"} = "/bin/date";
+
return $err;
}
while(1) {
$name = &confirm_list("Enter username", 1, "a-z0-9", "");
+ if (length($name) > 8) {
+ warn "Username is longer than 8 chars\a\n";
+ next;
+ }
last if (&new_users_name_valid($name) eq $name);
}
return $name;
Shell: $sh
EOF
- return &confirm_yn("Ok?", "yes");
+ return &confirm_yn("OK?", "yes");
}
# make password database
print "\n";
local(@message_buffer_append) = ();
- if (!&confirm_yn("Add somethings to message", "no")) {
- print "Finish with beginning ``.'' or ^D\n";
+ if (!&confirm_yn("Add anything to default message", "no")) {
+ print "Use ``.'' or ^D alone on a line to finish your message.\n";
push(@message_buffer_append, "\n");
while($read = <STDIN>) {
last if $read eq "\.\n";
while(1) {
$password = &confirm_list("Enter password", 1, "", "");
last if $password ne "";
- last if &confirm_yn("Use empty password?", "yes");
+ last if &confirm_yn("Use an empty password?", "yes");
}
return $password;
print "\n" if $verbose;
print "Ok, let's go.\n" .
- "Don't worry about mistakes. I ask you later for " .
- "correct input.\n" if $verbose;
+ "Don't worry about mistakes. I will give you the chance later to " .
+ "correct any input.\n" if $verbose;
# name: Username
# fullname: Full name
} else {
$new_users_ok = 0;
}
- if (!&confirm_yn("Continue with next user?", "yes")) {
- print "Good bye.\n" if $verbose;
+ if (!&confirm_yn("Add another user?", "yes")) {
+ print "Goodbye!\n" if $verbose;
last;
}
print "\n" if !$verbose;
# see /usr/src/usr.bin/passwd/local_passwd.c or librcypt, crypt(3)
sub salt {
- local($salt) = '_'; # initialization
+ local($salt); # initialization
local($i, $rand);
local(@itoa64) = ( 0 .. 9, a .. z, A .. Z ); # 0 .. 63
sub hints {
if ($verbose) {
print "Use option ``-silent'' if you don't want see " .
- "some warnings & questions.\n\n";
+ "all warnings & questions.\n\n";
} else {
print "Use option ``-verbose'' if you want see more warnings & " .
"questions \nor try to repair bugs.\n\n";
return 0;
}
+ if ($dotdir eq 'no') {
+ if (!mkdir("$homedir",0755)) {
+ warn "mkdir $homedir: $!\n"; return 0;
+ }
+ system 'chown', "$name:$group", $homedir;
+ return !$?;
+ }
+
# copy files from $dotdir to $homedir
# rename 'dot.foo' files to '.foo'
print "Copy files from $dotdir to $homedir\n" if $verbose;
$dotdir = &dotdir_default; # check $dotdir
$send_message = &message_default; # send message to new user
$defaultpasswd = &password_default; # maybe use password
-&config_write(0); # write variables in file
+&config_write(!$verbose); # write variables in file
# main loop for creating new users
&new_users; # add new users