summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2003-10-31 12:02:34 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2003-10-31 12:02:34 +0000
commit76d3d95775674636aa96aecb19cd428a9da9f9c4 (patch)
treeb2c051438c9bd03830824f7d426632692341ac21
parente554fd0f017b4e3e6d24a0c2da0ba0decbe6ac83 (diff)
downloaddrakx-76d3d95775674636aa96aecb19cd428a9da9f9c4.tar
drakx-76d3d95775674636aa96aecb19cd428a9da9f9c4.tar.gz
drakx-76d3d95775674636aa96aecb19cd428a9da9f9c4.tar.bz2
drakx-76d3d95775674636aa96aecb19cd428a9da9f9c4.tar.xz
drakx-76d3d95775674636aa96aecb19cd428a9da9f9c4.zip
move: "adduser" alike step
-rw-r--r--move/move.pm6
-rw-r--r--perl-install/any.pm102
2 files changed, 60 insertions, 48 deletions
diff --git a/move/move.pm b/move/move.pm
index 34903682e..f21a27498 100644
--- a/move/move.pm
+++ b/move/move.pm
@@ -59,6 +59,12 @@ drakx_stuff:
sub install2::startMove {
my $o = $::o;
+
+ require any;
+ any::ask_user_one($o, $o->{users} ||= [], $o->{security},
+ additional_msg => N("BLA BLA user for move, password for screensaver"), noaccept => 1, needauser => 1, noicons => 1);
+ require install_steps;
+ install_steps::addUser($o);
require install_any;
install_any::write_fstab($o);
diff --git a/perl-install/any.pm b/perl-install/any.pm
index f136bfb4f..ab95ab2d5 100644
--- a/perl-install/any.pm
+++ b/perl-install/any.pm
@@ -559,10 +559,8 @@ sub inspect {
$h;
}
-sub ask_users {
- my ($in, $users, $security) = @_;
-
- my $u if 0; $u ||= {};
+sub ask_user_one {
+ my ($in, $users, $security, %options) = @_;
my @icons = facesnames();
@@ -574,29 +572,30 @@ sub ask_users {
ntools => N("access to network tools"),
ctools => N("access to compilation tools"),
);
- while (1) {
- $u->{password2} ||= $u->{password} ||= '';
- $u->{shell} ||= '/bin/bash';
- my $names = @$users ? N("(already added %s)", join(", ", map { $_->{realname} || $_->{name} } @$users)) : '';
-
- my %groups;
- my $verif = sub {
- $u->{password} eq $u->{password2} or $in->ask_warn('', [ N("The passwords do not match"), N("Please try again") ]), return 1,2;
- $security > 3 && length($u->{password}) < 6 and $in->ask_warn('', N("This password is too simple")), return 1,2;
+
+ my $u;
+ $u->{password2} ||= $u->{password} ||= '';
+ $u->{shell} ||= '/bin/bash';
+ my $names = @$users ? N("(already added %s)", join(", ", map { $_->{realname} || $_->{name} } @$users)) : '';
+
+ my %groups;
+ my $verif = sub {
+ $u->{password} eq $u->{password2} or $in->ask_warn('', [ N("The passwords do not match"), N("Please try again") ]), return 1,2;
+ $security > 3 && length($u->{password}) < 6 and $in->ask_warn('', N("This password is too simple")), return 1,2;
$u->{name} or $in->ask_warn('', N("Please give a user name")), return 1,0;
- $u->{name} =~ /^[a-z]+?[a-z0-9_-]*?$/ or $in->ask_warn('', N("The user name must contain only lower cased letters, numbers, `-' and `_'")), return 1,0;
- length($u->{name}) <= 32 or $in->ask_warn('', N("The user name is too long")), return 1,0;
- member($u->{name}, 'root', map { $_->{name} } @$users) and $in->ask_warn('', N("This user name has already been added")), return 1,0;
- return 0;
- };
- my $ret = $in->ask_from_(
- { title => N("Add user"),
- messages => N("Enter a user\n%s", $names),
- interactive_help_id => 'addUser',
- focus_first => 1,
- if_(!$::isInstall, ok => N("Done")),
- cancel => N("Accept user"),
- callbacks => {
+ $u->{name} =~ /^[a-z]+?[a-z0-9_-]*?$/ or $in->ask_warn('', N("The user name must contain only lower cased letters, numbers, `-' and `_'")), return 1,0;
+ length($u->{name}) <= 32 or $in->ask_warn('', N("The user name is too long")), return 1,0;
+ member($u->{name}, 'root', map { $_->{name} } @$users) and $in->ask_warn('', N("This user name has already been added")), return 1,0;
+ return 0;
+ };
+ my $ret = $in->ask_from_(
+ { title => N("Add user"),
+ messages => N("Enter a user\n%s", $options{additional_msg} || $names),
+ interactive_help_id => 'addUser',
+ focus_first => 1,
+ if_(!$::isInstall, ok => N("Done")),
+ cancel => $options{noaccept} ? '' : N("Accept user"),
+ callbacks => {
focus_out => sub {
if ($_[0] eq '0') {
$u->{name} ||= lc first($u->{realname} =~ /([\w-]+)/);
@@ -604,28 +603,35 @@ sub ask_users {
},
complete => sub { $u->{name} ? &$verif : 0 },
canceled => $verif,
- ok_disabled => sub { $security >= 4 && !@$users },
- } }, [
- { label => N("Real name"), val => \$u->{realname} },
- { label => N("User name"), val => \$u->{name} },
- { label => N("Password"),val => \$u->{password}, hidden => 1 },
- { label => N("Password (again)"), val => \$u->{password2}, hidden => 1 },
- { label => N("Shell"), val => \$u->{shell}, list => [ shells() ], not_edit => !$::expert, advanced => 1 },
- if_($security <= 3 && @icons,
- { label => N("Icon"), val => \ ($u->{icon} ||= 'man'), list => \@icons, icon2f => \&face2png, format => \&translate },
- ),
- if_($security > 3,
- map {
- { label => $_, val => \$groups{$_}, text => $high_security_groups{$_}, type => 'bool' }
- } keys %high_security_groups,
- ),
- ],
- );
- $u->{groups} = [ grep { $groups{$_} } keys %groups ];
-
- push @$users, $u if $u->{name};
- $u = {};
- $ret and return;
+ ok_disabled => sub { $security >= 4 && !@$users || $options{needauser} && !$u->{name} },
+ } }, [
+ { label => N("Real name"), val => \$u->{realname} },
+ { label => N("User name"), val => \$u->{name} },
+ { label => N("Password"),val => \$u->{password}, hidden => 1 },
+ { label => N("Password (again)"), val => \$u->{password2}, hidden => 1 },
+ { label => N("Shell"), val => \$u->{shell}, list => [ shells() ], not_edit => !$::expert, advanced => 1 },
+ if_($security <= 3 && !$options{noicons} && @icons,
+ { label => N("Icon"), val => \ ($u->{icon} ||= 'man'), list => \@icons, icon2f => \&face2png, format => \&translate },
+ ),
+ if_($security > 3,
+ map {
+ { label => $_, val => \$groups{$_}, text => $high_security_groups{$_}, type => 'bool' }
+ } keys %high_security_groups,
+ ),
+ ],
+ );
+ $u->{groups} = [ grep { $groups{$_} } keys %groups ];
+
+ push @$users, $u if $u->{name};
+
+ return $ret;
+}
+
+sub ask_users {
+ my ($in, $users, $security) = @_;
+
+ while (1) {
+ ask_user_one($in, $users, $security) and return;
}
}