summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/adduserdrake
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2000-01-01 17:09:26 +0000
committerPascal Rigaux <pixel@mandriva.com>2000-01-01 17:09:26 +0000
commitd004436dc848800c9d65b90e39c39836c4d44cdf (patch)
treeb37bdcac9dad762a2b692076522785a83533c5f6 /perl-install/standalone/adduserdrake
parent1dc94110fc837dbe6cf06806f60c207ab1b64e83 (diff)
downloaddrakx-backup-do-not-use-d004436dc848800c9d65b90e39c39836c4d44cdf.tar
drakx-backup-do-not-use-d004436dc848800c9d65b90e39c39836c4d44cdf.tar.gz
drakx-backup-do-not-use-d004436dc848800c9d65b90e39c39836c4d44cdf.tar.bz2
drakx-backup-do-not-use-d004436dc848800c9d65b90e39c39836c4d44cdf.tar.xz
drakx-backup-do-not-use-d004436dc848800c9d65b90e39c39836c4d44cdf.zip
no_comment
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);