From d004436dc848800c9d65b90e39c39836c4d44cdf Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Sat, 1 Jan 2000 17:09:26 +0000 Subject: no_comment --- perl-install/standalone/adduserdrake | 54 +++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 19 deletions(-) (limited to 'perl-install/standalone/adduserdrake') 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] []\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); -- cgit v1.2.1