summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl-install/NEWS4
-rw-r--r--perl-install/any.pm84
-rw-r--r--perl-install/install/NEWS6
-rw-r--r--perl-install/install/gtk.pm2
-rw-r--r--perl-install/install/help/help.pm39
-rw-r--r--perl-install/install/install2.pm11
-rw-r--r--perl-install/install/steps.pm9
-rw-r--r--perl-install/install/steps_auto_install.pm3
-rw-r--r--perl-install/install/steps_interactive.pm45
-rw-r--r--perl-install/install/steps_list.pm4
-rwxr-xr-xperl-install/standalone/adduserdrake2
-rwxr-xr-xperl-install/standalone/finish-install2
12 files changed, 89 insertions, 122 deletions
diff --git a/perl-install/NEWS b/perl-install/NEWS
index 9155d6b0c..9544728ad 100644
--- a/perl-install/NEWS
+++ b/perl-install/NEWS
@@ -1,3 +1,7 @@
+- adduserdrake, finish-install:
+ o create only one user
+ o fix checking user info (#32517)
+
Version 10.4.167 - 11 August 2007, by Pascal "Pixel" Rigaux
- fix plural translations (#32505)
diff --git a/perl-install/any.pm b/perl-install/any.pm
index ce56ceb80..6d938c75c 100644
--- a/perl-install/any.pm
+++ b/perl-install/any.pm
@@ -716,12 +716,21 @@ sub inspect {
$h;
}
-sub ask_user_one {
- my ($in, $users, $security, $u, $suggested_names, %options) = @_;
+sub ask_user {
+ my ($in, $users, $security, %options) = @_;
+
+ ask_user_and_root($in, undef, $users, $security, %options);
+}
+
+sub ask_user_and_root {
+ my ($in, $superuser, $users, $security, %options) = @_;
$options{needauser} ||= $security >= 3;
- my @suggested_names = grep { ! defined getpwnam($_) } @$suggested_names;
+ my @suggested_names = $::isInstall ? do {
+ my @l = grep { !/^\./ && $_ ne 'lost+found' && -d "$::prefix/home/$_" } all("$::prefix/home");
+ grep { ! defined getpwnam($_) } @l;
+ } : ();
my %high_security_groups = (
xgrp => N("access to X programs"),
@@ -732,6 +741,7 @@ sub ask_user_one {
ctools => N("access to compilation tools"),
);
+ my $u = {};
$u->{password2} ||= $u->{password} ||= '';
$u->{shell} ||= '/bin/bash';
my $names = @$users ? N("(already added %s)", join(", ", map { $_->{realname} || $_->{name} } @$users)) : '';
@@ -739,63 +749,57 @@ sub ask_user_one {
my %groups;
require authentication;
- my $verif = sub {
- authentication::check_given_password($in, $u, $security > 3 ? 6 : 0) or 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;
- defined getpwnam($u->{name}) || member($u->{name}, map { $_->{name} } @$users) and $in->ask_warn('', N("This user name has already been added")), return 1,0;
- foreach ([ $u->{uid}, N("User ID") ],
- [ $u->{gid}, N("Group ID") ]) {
- my ($id, $name) = @$_;
- $id or next;
- $id =~ /^\d+$/ or $in->ask_warn('', N("%s must be a number", $name)), return 1;
- $id >= 500 or $in->ask_yesorno('', N("%s should be above 500. Accept anyway?", $name)) or return 1;
- }
- return 0;
+ my $validate_name = sub {
+ $u->{name} or $in->ask_warn('', N("Please give a user name")), return;
+ $u->{name} =~ /^[a-z]+?[a-z0-9_-]*?$/ or $in->ask_warn('', N("The user name must contain only lower cased letters, numbers, `-' and `_'")), return;
+ length($u->{name}) <= 32 or $in->ask_warn('', N("The user name is too long")), return;
+ defined getpwnam($u->{name}) || member($u->{name}, map { $_->{name} } @$users) and $in->ask_warn('', N("This user name has already been added")), return;
+ 'ok';
+ };
+ my $validate_uid_gid = sub {
+ my ($field) = @_;
+ my $id = $u->{$field} or return 'ok';
+ my $name = $field eq 'uid' ? N("User ID") : N("Group ID");
+ $id =~ /^\d+$/ or $in->ask_warn('', N("%s must be a number", $name)), return;
+ $id >= 500 or $in->ask_yesorno('', N("%s should be above 500. Accept anyway?", $name)) or return;
+ 'ok';
};
my $ret = $in->ask_from_(
{ title => N("Add user"),
icon => 'banner-adduser',
- messages => N("Enter a user\n%s", $options{additional_msg} || $names),
interactive_help_id => 'addUser',
+ if_($::isInstall && $superuser, cancel => ''),
focus_first => 1,
- if_(!$::isInstall, ok => N("Done")),
- cancel => $options{noaccept} ? '' : N("Accept user"),
- callbacks => {
- canceled => $verif,
- ok_disabled => sub { $options{needauser} && !@$users || $u->{name} },
- } }, [
+ }, [
+ $superuser ? (
+ { label => N("Set administrator (root) password"), title => 1 },
+ { label => N("Password"), val => \$superuser->{password}, hidden => 1,
+ validate => sub { authentication::check_given_password($in, $superuser, 2 * $security) } },
+ { label => N("Password (again)"), val => \$superuser->{password2}, hidden => 1 },
+ ) : (),
+ { label => N("Enter a user"), title => 1 }, if_($names, { label => $names }),
{ label => N("Real name"), val => \$u->{realname}, focus_out => sub {
$u->{name} ||= lc first($u->{realname} =~ /([a-zA-Z0-9_-]+)/);
} },
- { label => N("Login name"), val => \$u->{name}, list => \@suggested_names, not_edit => 0 },
- { label => N("Password"),val => \$u->{password}, hidden => 1 },
+ { label => N("Login name"), val => \$u->{name}, list => \@suggested_names, not_edit => 0, validate => $validate_name },
+ { label => N("Password"),val => \$u->{password}, hidden => 1,
+ validate => sub { authentication::check_given_password($in, $u, $security > 3 ? 6 : 0) } },
{ label => N("Password (again)"), val => \$u->{password2}, hidden => 1 },
{ label => N("Shell"), val => \$u->{shell}, list => [ shells() ], advanced => 1 },
- { label => N("User ID"), val => \$u->{uid}, advanced => 1 },
- { label => N("Group ID"), val => \$u->{gid}, advanced => 1 },
+ { label => N("User ID"), val => \$u->{uid}, advanced => 1, validate => sub { $validate_uid_gid->('uid') } },
+ { label => N("Group ID"), val => \$u->{gid}, advanced => 1, validate => sub { $validate_uid_gid->('gid') } },
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, $suggested_names) = @_;
-
- while (1) {
- my $u = {};
- ask_user_one($in, $users, $security, $u, $suggested_names) and return;
- }
+ $ret && $u;
}
sub sessions() {
diff --git a/perl-install/install/NEWS b/perl-install/install/NEWS
index 58aba047f..334b2755c 100644
--- a/perl-install/install/NEWS
+++ b/perl-install/install/NEWS
@@ -1,3 +1,9 @@
+- merge root password step and create user step
+- fix checking user creation info (#32517)
+- allow to create only one user per default, but add an entry in summary to
+ create more users
+- authentication method is not configurable anymore for now.
+ should we add it to summary?
- 'ibm_acpi' driver was replaced by 'thinkpad_acpi (#31606)
- internal
o use urpm::select::get_preferred to choose preferred packages
diff --git a/perl-install/install/gtk.pm b/perl-install/install/gtk.pm
index 877f62596..22ef0eb18 100644
--- a/perl-install/install/gtk.pm
+++ b/perl-install/install/gtk.pm
@@ -135,7 +135,7 @@ sub create_steps_window {
my @l = $category->(N("Installation"));
foreach (grep { !eval $o->{steps}{$_}{hidden} } @{$o->{orderedSteps}}) {
- if ($_ eq 'setRootPassword') {
+ if ($_ eq 'setRootPassword_addUser') {
push @l, '', $category->(N("Configuration"));
}
my $img = gtknew('Image', file => 'steps_off.png');
diff --git a/perl-install/install/help/help.pm b/perl-install/install/help/help.pm
index dd30f1457..70aa3a785 100644
--- a/perl-install/install/help/help.pm
+++ b/perl-install/install/help/help.pm
@@ -16,7 +16,7 @@ covers the entire Mandriva Linux distribution. If you agree with all the
terms it contains, check the \"%s\" box. If not, clicking on the \"%s\"
button will reboot your computer.", N("Accept"), N("Quit"));
}
-sub addUser() {
+sub setRootPassword_addUser() {
N("GNU/Linux is a multi-user system which means each user can have his or her
own preferences, own files and so on. But unlike \"root\", who is the
system administrator, the users you add at this point will not be authorized
@@ -681,43 +681,6 @@ sub selectSerialPort() {
N("Please select the correct port. For example, the \"COM1\" port under
Windows is named \"ttyS0\" under GNU/Linux.");
}
-sub setRootPassword() {
- N("This is the most crucial decision point for the security of your GNU/Linux
-system: you must enter the \"root\" password. \"Root\" is the system
-administrator and is the only user authorized to make updates, add users,
-change the overall system configuration, and so on. In short, \"root\" can
-do everything! That's why you must choose a password which is difficult to
-guess: DrakX will tell you if the password you chose is too simple. As you
-can see, you're not forced to enter a password, but we strongly advise
-against this. GNU/Linux is just as prone to operator error as any other
-operating system. Since \"root\" can overcome all limitations and
-unintentionally erase all data on partitions by carelessly accessing the
-partitions themselves, it is important that it be difficult to become
-\"root\".
-
-The password should be a mixture of alphanumeric characters and at least 8
-characters long. Never write down the \"root\" password -- it makes it far
-too easy to compromise your system.
-
-One caveat: do not make the password too long or too complicated because you
-must be able to remember it!
-
-The password will not be displayed on screen as you type it. To reduce the
-chance of a blind typing error you'll need to enter the password twice. If
-you do happen to make the same typing error twice, you'll have to use this
-``incorrect'' password the first time you'll try to connect as \"root\".
-
-If you want an authentication server to control access to your computer,
-click on the \"%s\" button.
-
-If your network uses either LDAP, NIS, or PDC Windows Domain authentication
-services, select the appropriate one for \"%s\". If you do not know which
-one to use, you should ask your network administrator.
-
-If you happen to have problems with remembering passwords, or if your
-computer will never be connected to the Internet and you absolutely trust
-everybody who uses your computer, you can choose to have \"%s\".", N("Advanced"), N("authentication"), N("No password"));
-}
sub setupBootloaderBeginner() {
N("A boot loader is a little program which is started by the computer at boot
time. It's responsible for starting up the whole system. Normally, the boot
diff --git a/perl-install/install/install2.pm b/perl-install/install/install2.pm
index 8532a02c5..8addfdb33 100644
--- a/perl-install/install/install2.pm
+++ b/perl-install/install/install2.pm
@@ -271,17 +271,10 @@ sub configureServices {
installStepsCall($o, $auto, 'configureServices');
}
#------------------------------------------------------------------------------
-sub setRootPassword {
+sub setRootPassword_addUser {
my ($auto) = @_;
- return if $o->{isUpgrade};
- installStepsCall($o, $auto, 'setRootPassword');
-}
-#------------------------------------------------------------------------------
-sub addUser {
- my ($auto) = @_;
-
- installStepsCall($o, $auto, 'addUser') if !$o->{isUpgrade};
+ installStepsCall($o, $auto, 'setRootPassword_addUser') if !$o->{isUpgrade};
}
#------------------------------------------------------------------------------
diff --git a/perl-install/install/steps.pm b/perl-install/install/steps.pm
index e10c010ea..05dd04758 100644
--- a/perl-install/install/steps.pm
+++ b/perl-install/install/steps.pm
@@ -728,6 +728,13 @@ sub configureServices {
}
#------------------------------------------------------------------------------
+sub setRootPassword_addUser {
+ my ($o) = @_;
+
+ setRootPassword($o);
+ addUser($o);
+}
+
sub setRootPassword {
my ($o) = @_;
$o->{superuser} ||= {};
@@ -736,8 +743,6 @@ sub setRootPassword {
install::any::set_authentication($o);
}
-#------------------------------------------------------------------------------
-
sub addUser {
my ($o) = @_;
my $users = $o->{users} ||= [];
diff --git a/perl-install/install/steps_auto_install.pm b/perl-install/install/steps_auto_install.pm
index a8327df97..dfaa5f0e3 100644
--- a/perl-install/install/steps_auto_install.pm
+++ b/perl-install/install/steps_auto_install.pm
@@ -15,8 +15,9 @@ use install::steps;
sub new {
my ($type, $o) = @_;
- # Handle legacy options
$o->{interactive} ||= 'gtk' if $graphical || !is_empty_array_ref($o->{interactiveSteps});
+ # Handle legacy options
+ push @{$o->{interactiveSteps}}, qw(setRootPassword_addUser) if intersection($o->{interactiveSteps}, ['addUser', 'setRootPassword']);
push @{$o->{interactiveSteps}}, qw(installPackages configureNetwork), @graphical_steps, if_(!$o->{autoExitInstall}, 'exitInstall');
if ($o->{interactive}) {
diff --git a/perl-install/install/steps_interactive.pm b/perl-install/install/steps_interactive.pm
index e40f19eb0..0d3146df9 100644
--- a/perl-install/install/steps_interactive.pm
+++ b/perl-install/install/steps_interactive.pm
@@ -784,6 +784,16 @@ sub summary {
push @l, {
group => N("System"),
+ label => N("User management"),
+ clicked => sub {
+ if (my $u = any::ask_user($o, $o->{users}, $o->{security}, needauser => 1)) {
+ any::add_users([$u], $o->{authentication});
+ }
+ },
+ };
+
+ push @l, {
+ group => N("System"),
label => N("Services"),
val => sub {
require services;
@@ -935,37 +945,18 @@ sub summary {
}
#------------------------------------------------------------------------------
-sub setRootPassword {
- my ($o, $clicked) = @_;
- my $sup = $o->{superuser} ||= {};
- $sup->{password2} ||= $sup->{password} ||= "";
-
- if ($o->{security} >= 1 || $clicked) {
- require authentication;
- authentication::ask_root_password_and_authentication($o, $o->{net}, $sup, $o->{authentication} ||= {}, $o->{meta_class}, $o->{security});
- }
- install::steps::setRootPassword($o);
-}
-
-#------------------------------------------------------------------------------
-#-addUser
+#-setRootPassword_addUser
#------------------------------------------------------------------------------
-sub addUser {
- my ($o, $clicked) = @_;
+sub setRootPassword_addUser {
+ my ($o) = @_;
$o->{users} ||= [];
- if ($o->{security} < 1) {
- push @{$o->{users}}, { password => 'mandrake', realname => 'default', icon => 'automagic' }
- if !member('mandrake', map { $_->{name} } @{$o->{users}});
- }
- if ($o->{security} >= 1 || $clicked) {
- my @suggested_names = @{$o->{users}} ? () : grep { !/^\./ && $_ ne 'lost+found' && -d "$::prefix/home/$_" } all("$::prefix/home");
- any::ask_users($o, $o->{users}, $o->{security}, \@suggested_names);
- }
- add2hash($o, any::get_autologin());
- any::autologin($o, $o);
- any::set_autologin($o->do_pkgs, $o->{autologin}, $o->{desktop}) if $::globetrotter;
+ my $sup = $o->{superuser} ||= {};
+ $sup->{password2} ||= $sup->{password} ||= "";
+
+ any::ask_user_and_root($o, $sup, $o->{users}, $o->{security});
+ install::steps::setRootPassword($o);
install::steps::addUser($o);
}
diff --git a/perl-install/install/steps_list.pm b/perl-install/install/steps_list.pm
index 814fae0a4..03cfdc182 100644
--- a/perl-install/install/steps_list.pm
+++ b/perl-install/install/steps_list.pm
@@ -24,8 +24,8 @@ use common;
formatPartitions => [ N_("_: Keep these entry short\nFormatting"), 1, -1, '1', "doPartitionDisks" ],
choosePackages => [ N_("_: Keep these entry short\nChoosing packages"), 1, -2, '1', "formatPartitions" ],
installPackages => [ N_("_: Keep these entry short\nInstalling"), 1, -1, '', ["formatPartitions", "selectInstallClass"] ],
- setRootPassword => [ N_("_: Keep these entry short\nAuthentication"), 1, 1, '', "installPackages" ],
- addUser => [ N_("_: Keep these entry short\nUsers"), 1, 1, '', "installPackages" ],
+ setRootPassword_addUser
+ => [ N_("_: Keep these entry short\nUsers"), 1, 1, '', "installPackages" ],
configureNetwork => [ N_("_: Keep these entry short\nNetworking"), 1, 1, '1', "formatPartitions" ],
setupBootloader => [ N_("_: Keep these entry short\nBootloader"), 1, 0, '', "installPackages" ],
configureX => [ N_("_: Keep these entry short\nConfigure X"), 1, 1, '1', ["formatPartitions", "setupBootloader"] ],
diff --git a/perl-install/standalone/adduserdrake b/perl-install/standalone/adduserdrake
index a2d380766..b449ef52b 100755
--- a/perl-install/standalone/adduserdrake
+++ b/perl-install/standalone/adduserdrake
@@ -17,7 +17,7 @@ if (my @l = grep { ! /^-/ } @ARGV) {
$users = [ map { { name => $_, realname => $_ } } @l ];
} else {
$in = 'interactive'->vnew('su');
- any::ask_users($in, $users, security::level::get(), []);
+ any::ask_user($in, $users, security::level::get(), needauser => 1);
}
any::add_users($users, authentication::get());
diff --git a/perl-install/standalone/finish-install b/perl-install/standalone/finish-install
index 97ceb1fab..967bdacf6 100755
--- a/perl-install/standalone/finish-install
+++ b/perl-install/standalone/finish-install
@@ -86,7 +86,7 @@ sub ask_authentication() {
sub ask_users() {
my $users = [];
- any::ask_users($in, $users, $security, []);
+ any::ask_user($in, $users, $security);
my $old_user = $conf{USER_RENAME_FROM};
if (@$users && $old_user) {
$users->[0]{rename_from} = $old_user;