diff options
author | damien <damien@mandriva.com> | 2000-11-28 16:56:52 +0000 |
---|---|---|
committer | damien <damien@mandriva.com> | 2000-11-28 16:56:52 +0000 |
commit | 0880c7ba8ce88e87fa600aeb367a8f88a3ae71e7 (patch) | |
tree | 33f7ac905998f9ad6d85090f777ee4c0d0c67032 /perl-install/standalone/adduserdrake | |
parent | d5c526273db473a7d87a26000585900fc10dda7d (diff) | |
download | drakx-topic/unlabeled-1.1.1.tar drakx-topic/unlabeled-1.1.1.tar.gz drakx-topic/unlabeled-1.1.1.tar.bz2 drakx-topic/unlabeled-1.1.1.tar.xz drakx-topic/unlabeled-1.1.1.zip |
branch to build the firewall install.topic/unlabeled-1.1.1
Diffstat (limited to 'perl-install/standalone/adduserdrake')
-rwxr-xr-x | perl-install/standalone/adduserdrake | 73 |
1 files changed, 50 insertions, 23 deletions
diff --git a/perl-install/standalone/adduserdrake b/perl-install/standalone/adduserdrake index 52fbdfd68..1ce283f8c 100755 --- a/perl-install/standalone/adduserdrake +++ b/perl-install/standalone/adduserdrake @@ -4,23 +4,34 @@ use lib qw(/usr/lib/libDrakX); use common qw(:common :functional :system :file); use interactive; +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/; +$::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 = map { "/bin/$_" } qw(bash tcsh zsh ash ksh); +my @shells = grep { -x $_ } map { "/bin/$_" } qw(bash tcsh zsh ash ksh); my $isMD5 = cat_("/etc/pam.d/passwd") =~ /md5/; -my $security = $ENV{SECURITY_LEVEL}; +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 = interactive->vnew('su'); +my @users; new: +$u = { icon => translate('automagic') }; if ($in->ask_from_entries_refH( [ _("Add user"), _("Accept user"), _("Done") ], _("Enter a user\n%s", $users ? _("(already added %s)", join(", ", map { $_->{realname} || $_->{name} } @users)) : ''), @@ -32,6 +43,8 @@ if ($in->ask_from_entries_refH( _("Password (again)") => {val => \$u->{password2}, hidden => 1}, ), $::beginner ? () : ( _("Shell") => {val => \$u->{shell}, list => \@shells, not_edit => !$::expert} + ), $security > 3 ? () : ( + _("Icon") => {val => \$u->{icon}, list => [ any::facesnames() ], icon2f => \&any::face2xpm }, ), ], focus_out => sub { @@ -40,29 +53,43 @@ if ($in->ask_from_entries_refH( } }, complete => sub { - $u->{password} eq $u->{password2} or $o->ask_warn('', [ _("The passwords do not match"), _("Please try again") ]), return (1,3); - $security > 3 && length($u->{password}) < 6 and $o->ask_warn('', _("This password is too simple")), return (1,2); - $u->{name} or $o->ask_warn('', _("Please give a user name")), return (1,0); - $u->{name} =~ /^[a-z0-9_-]+$/ or $o->ask_warn('', _("The user name must contain only lower cased letters, numbers, `-' and `_'")), return (1,0); - member($u->{name}, map { $_->{name} } @users) and $o->ask_warn('', _("This user name is already added")), return (1,0); + $u->{password} eq $u->{password2} or $in->ask_warn('', [ _("The passwords do not match"), _("Please try again") ]), return (1,3); + $security > 3 && length($u->{password}) < 6 and $in->ask_warn('', _("This password is too simple")), return (1,2); + $u->{name} or $in->ask_warn('', _("Please give a user name")), return (1,0); + $u->{name} =~ /^[a-z0-9_-]+$/ or $in->ask_warn('', _("The user name must contain only lower cased letters, numbers, `-' and `_'")), return (1,0); + member($u->{name}, map { $_->{name} } @users) and $in->ask_warn('', _("This user name is already added")), return (1,0); + print $u->{icon}, "\n"; return 0; }, )) { push @users, $u; - $u->{pw} = $isMD5 ? c::crypt_md5($u->{password}, salt(8)) : crypt($u->{password}, salt(2)); - system("adduser $u->{name}"); + goto new; +} + +addusers(@users); + +sub addusers { + my @u = map { $_->{name} } my @users = @_; + + foreach (@users) { + $_->{pw} = any::crypt($_->{password}, $isMD5); + $_->{shell} ||= "/bin/bash"; + } + + system("adduser $_") foreach @u; + any::addUsers('', @_); + substInFile { - if (/^$u->{name}:/) { - chomp; - my %l; @l{@etc_pass_fields} = split ':'; - add2hash($u, \%l); - $_ = join(':', @$u{@etc_pass_fields}) . "\n"; + 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"; - - $u = {}; - goto new; + system("pwconv") if $isShadow; } - $in->exit(0); |