diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2001-01-11 11:51:37 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2001-01-11 11:51:37 +0000 |
commit | 1c04736962769df73d14f0247f53e765f67b2c38 (patch) | |
tree | b6f5ac9b9c3efa0f232d605d8eb7b60f361b701e /perl-install/install_steps_interactive.pm | |
parent | 824049f130f973f256d513bc8226caf18a6c7d7a (diff) | |
download | drakx-1c04736962769df73d14f0247f53e765f67b2c38.tar drakx-1c04736962769df73d14f0247f53e765f67b2c38.tar.gz drakx-1c04736962769df73d14f0247f53e765f67b2c38.tar.bz2 drakx-1c04736962769df73d14f0247f53e765f67b2c38.tar.xz drakx-1c04736962769df73d14f0247f53e765f67b2c38.zip |
(addUser): use any::ask_users
Diffstat (limited to 'perl-install/install_steps_interactive.pm')
-rw-r--r-- | perl-install/install_steps_interactive.pm | 49 |
1 files changed, 4 insertions, 45 deletions
diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm index c60fa9252..d8af12044 100644 --- a/perl-install/install_steps_interactive.pm +++ b/perl-install/install_steps_interactive.pm @@ -785,54 +785,13 @@ sub setRootPassword { #------------------------------------------------------------------------------ sub addUser { my ($o, $clicked) = @_; - my $u = $o->{user} ||= {}; + $o->{users} ||= []; if ($o->{security} < 1) { - add2hash_($u, { name => "mandrake", password => "mandrake", realname => "default", icon => 'automagic' }); - $o->{users} ||= [ $u ]; + push @{$o->{users}}, { password => 'mandrake', realname => 'default', icon => 'automagic' } + if !member('mandrake', map { $_->{name} } @{$o->{users}}); } - $u->{password2} ||= $u->{password} ||= ""; - $u->{shell} ||= "/bin/bash"; - my @fields = qw(realname name password password2); - my @shells = map { chomp; $_ } cat_("$o->{prefix}/etc/shells"); - if (($o->{security} >= 1 || $clicked)) { - $u->{icon} = translate($u->{icon}); - if ($o->ask_from_entries_refH_powered( - { title => _("Add user"), - messages => _("Enter a user\n%s", $o->{users} ? _("(already added %s)", join(", ", map { $_->{realname} || $_->{name} } @{$o->{users}})) : ''), - ok => _("Accept user"), - cancel => ($o->{security} < 4 || @{$o->{users}} ? _("Done") : ''), - callbacks => { - focus_out => sub { - if ($_[0] eq 0) { - $u->{name} ||= lc first($u->{realname} =~ /((\w|-)+)/); - } - }, - complete => sub { - $u->{password} eq $u->{password2} or $o->ask_warn('', [ _("The passwords do not match"), _("Please try again") ]), return (1,2); - $o->{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} } @{$o->{users}}) and $o->ask_warn('', _("This user name is already added")), return (1,0); - return 0; - }, - } }, [ - { label => _("Real name"), val => \$u->{realname} }, - { label => _("User name"), val => \$u->{name} }, - if_($o->{security} >= 2, - { label => _("Password"),val => \$u->{password}, hidden => 1}, - { label => _("Password (again)"), val => \$u->{password2}, hidden => 1}, - ), if_(!$::beginner, - { label => _("Shell"), val => \$u->{shell}, list => [ any::shells($o->{prefix}) ], not_edit => !$::expert} - ), if_($o->{security} <= 3, - { label => _("Icon"), val => \$u->{icon}, list => [ any::facesnames($o->{prefix}) ], icon2f => sub { any::face2xpm($_[0], $o->{prefix}) } }, - ), - ], - )) { - push @{$o->{users}}, $o->{user}; - $o->{user} = {}; - goto &addUser; - } + any::ask_users($o->{prefix}, $o, $o->{users}, $o->{security}); } install_steps::addUser($o); } |