summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/adduserdrake
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/standalone/adduserdrake')
-rwxr-xr-xperl-install/standalone/adduserdrake54
1 files changed, 35 insertions, 19 deletions
diff --git a/perl-install/standalone/adduserdrake b/perl-install/standalone/adduserdrake
index 0bc27dd94..87384e06b 100755
--- a/perl-install/standalone/adduserdrake
+++ b/perl-install/standalone/adduserdrake
@@ -8,20 +8,27 @@ use any;
local $_ = join '', @ARGV;
-/-h/ and die "usage: adduserdrake [--beginner] [--expert]\n";
+/-h/ and die "usage: adduserdrake [--beginner] [--expert] [<users...>]\n";
$::beginner = /-beginner/;
$::expert = /-expert/;
$::isStandalone = 1;
-my $in = vnew interactive('su');
-
my @etc_pass_fields = qw(name pw uid gid realname home shell);
my @shells = grep { -x $_ } map { "/bin/$_" } qw(bash tcsh zsh ash ksh);
my $isMD5 = cat_("/etc/pam.d/passwd") =~ /md5/;
my $isShadow = cat_("/etc/pam.d/passwd") =~ /shadow/;
my $security = $ENV{SECURE_LEVEL};
+
+
+if (my @l = grep { ! /^-/ } @ARGV) {
+ addusers(map {{ name => $_, realname => $_ }} @l);
+ exit 0;
+}
+
+my $in = vnew interactive('su');
+
new:
if ($in->ask_from_entries_refH(
[ _("Add user"), _("Accept user"), _("Done") ],
@@ -51,25 +58,34 @@ if ($in->ask_from_entries_refH(
},
)) {
push @users, $u;
- $u->{pw} = $isMD5 ? c::crypt_md5($u->{password}, salt(8)) : crypt($u->{password}, salt(2));
$u = {};
goto new;
}
-my @u = map { $_->{name} } @users;
-
-system("adduser $_") foreach @u;
-any::addUsers('', @u);
-
-substInFile {
- foreach my $u (@users) {
- if (/^$u->{name}:/) {
- chomp;
- my %l; @l{@etc_pass_fields} = split ':';
- add2hash($u, \%l);
- $_ = join(':', @$u{@etc_pass_fields}) . "\n";
- }
+
+addusers(@users);
+
+sub addusers {
+ my @u = map { $_->{name} } my @users = @_;
+
+ foreach (@users) {
+ $_->{pw} = $isMD5 ? c::crypt_md5($_->{password}, salt(8)) : crypt($_->{password}, salt(2));
+ $_->{shell} ||= "/bin/bash";
}
-} "/etc/passwd";
-system("pwconv") if $isShadow;
+
+ system("adduser $_") foreach @u;
+ any::addUsers('', @u);
+
+ substInFile {
+ foreach my $u (@users) {
+ if (/^$u->{name}:/) {
+ chomp;
+ my %l; @l{@etc_pass_fields} = split ':';
+ add2hash($u, \%l);
+ $_ = join(':', @$u{@etc_pass_fields}) . "\n";
+ }
+ }
+ } "/etc/passwd";
+ system("pwconv") if $isShadow;
+}
$in->exit(0);