diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2003-08-10 23:53:18 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2003-08-10 23:53:18 +0000 |
commit | ba2e9575a26cb1c9a81ef5d1303422f862d5e019 (patch) | |
tree | 14240b5d02125b97c1e8c6279573f4fe200cb173 | |
parent | 5f78b9376156a4c9d9cec4e8c630a632c4402fea (diff) | |
download | drakx-backup-do-not-use-ba2e9575a26cb1c9a81ef5d1303422f862d5e019.tar drakx-backup-do-not-use-ba2e9575a26cb1c9a81ef5d1303422f862d5e019.tar.gz drakx-backup-do-not-use-ba2e9575a26cb1c9a81ef5d1303422f862d5e019.tar.bz2 drakx-backup-do-not-use-ba2e9575a26cb1c9a81ef5d1303422f862d5e019.tar.xz drakx-backup-do-not-use-ba2e9575a26cb1c9a81ef5d1303422f862d5e019.zip |
use $::prefix instead of passing $prefix to functions
-rw-r--r-- | perl-install/any.pm | 49 | ||||
-rw-r--r-- | perl-install/install_any.pm | 7 | ||||
-rw-r--r-- | perl-install/install_steps.pm | 29 | ||||
-rw-r--r-- | perl-install/install_steps_interactive.pm | 2 | ||||
-rwxr-xr-x | perl-install/standalone/adduserdrake | 6 |
5 files changed, 44 insertions, 49 deletions
diff --git a/perl-install/any.pm b/perl-install/any.pm index b8a096c37..c1ea5301d 100644 --- a/perl-install/any.pm +++ b/perl-install/any.pm @@ -23,30 +23,28 @@ sub drakx_version() { sprintf "DrakX v%s built %s", $::testing ? ('TEST', scalar gmtime()) : (split('/', cat_("$ENV{SHARE_PATH}/VERSION")))[2,3]; } -sub facesdir { - my ($prefix) = @_; - "$prefix/usr/share/mdk/faces/"; +sub facesdir() { + "$::prefix/usr/share/mdk/faces/"; } sub face2png { - my ($face, $prefix) = @_; - facesdir($prefix) . $face . ".png"; + my ($face) = @_; + facesdir() . $face . ".png"; } -sub facesnames { - my ($prefix) = @_; - my $dir = facesdir($prefix); +sub facesnames() { + my $dir = facesdir(); my @l = grep { /^[A-Z]/ } all($dir); map { if_(/(.*)\.png/, $1) } (@l ? @l : all($dir)); } sub addKdmIcon { - my ($prefix, $user, $icon) = @_; - my $dest = "$prefix/usr/share/faces/$user.png"; - eval { cp_af(facesdir($prefix) . $icon . ".png", $dest) } if $icon; + my ($user, $icon) = @_; + my $dest = "$::prefix/usr/share/faces/$user.png"; + eval { cp_af(facesdir() . $icon . ".png", $dest) } if $icon; } sub allocUsers { - my ($prefix, $users) = @_; - my @m = my @l = facesnames($prefix); + my ($users) = @_; + my @m = my @l = facesnames(); foreach (grep { !$_->{icon} || $_->{icon} eq "automagic" } @$users) { $_->{auto_icon} = splice(@m, rand(@m), 1); #- known biased (see cookbook for better) log::l("auto_icon is $_->{auto_icon}"); @@ -55,12 +53,12 @@ sub allocUsers { } sub addUsers { - my ($prefix, $users) = @_; + my ($users) = @_; - allocUsers($prefix, $users); + allocUsers($users); foreach my $u (@$users) { - run_program::rooted($prefix, "usermod", "-G", join(",", @{$u->{groups}}), $u->{name}) if !is_empty_array_ref($u->{groups}); - addKdmIcon($prefix, $u->{name}, delete $u->{auto_icon} || $u->{icon}); + run_program::rooted($::prefix, "usermod", "-G", join(",", @{$u->{groups}}), $u->{name}) if !is_empty_array_ref($u->{groups}); + addKdmIcon($u->{name}, delete $u->{auto_icon} || $u->{icon}); } } @@ -516,9 +514,8 @@ sub writeandclean_ldsoconf { uniq cat_($file), "/usr/X11R6/lib\n"; } -sub shells { - my ($prefix) = @_; - grep { -x "$prefix$_" } chomp_(cat_("$prefix/etc/shells")); +sub shells() { + grep { -x "$::prefix$_" } chomp_(cat_("$::prefix/etc/shells")); } sub inspect { @@ -548,11 +545,11 @@ sub inspect { } sub ask_users { - my ($prefix, $in, $users, $security) = @_; + my ($in, $users, $security) = @_; my $u if 0; $u ||= {}; - my @icons = facesnames($prefix); + my @icons = facesnames(); my %high_security_groups = ( xgrp => N("access to X programs"), @@ -598,9 +595,9 @@ sub ask_users { { 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($prefix) ], not_edit => !$::expert, advanced => 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 => sub { face2png($_[0], $prefix) }, format => \&translate }, + { label => N("Icon"), val => \ ($u->{icon} ||= 'man'), list => \@icons, icon2f => \&face2png, format => \&translate }, ), if_($security > 3, map { @@ -728,7 +725,7 @@ sub selectCountry { } sub write_passwd_user { - my ($prefix, $u, $isMD5) = @_; + my ($u, $isMD5) = @_; $u->{pw} = $u->{password} ? &crypt($u->{password}, $isMD5) : $u->{pw} || ''; $u->{shell} ||= '/bin/bash'; @@ -743,7 +740,7 @@ sub write_passwd_user { if (eof && $u->{name}) { $_ .= pack_passwd($u); } - } "$prefix/etc/passwd"; + } "$::prefix/etc/passwd"; } sub set_login_serial_console { diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm index d5154f17a..e9bb89d04 100644 --- a/perl-install/install_any.pm +++ b/perl-install/install_any.pm @@ -985,10 +985,9 @@ sub remove_advertising { @advertising_images = (); } -sub disable_user_view { - my ($prefix) = @_; - substInFile { s/^UserView=.*/UserView=true/ } "$prefix/usr/share/config/kdm/kdmrc"; - substInFile { s/^Browser=.*/Browser=0/ } "$prefix/etc/X11/gdm/gdm.conf"; +sub disable_user_view() { + substInFile { s/^UserView=.*/UserView=true/ } "$::prefix/usr/share/config/kdm/kdmrc"; + substInFile { s/^Browser=.*/Browser=0/ } "$::prefix/etc/X11/gdm/gdm.conf"; } sub set_security { diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm index 488fd89df..3d1b83e23 100644 --- a/perl-install/install_steps.pm +++ b/perl-install/install_steps.pm @@ -501,7 +501,7 @@ EOF } "$o->{prefix}/usr/share/config/kdm/kdmrc"; } - install_any::disable_user_view($o->{prefix}) if $o->{security} >= 3 || $o->{authentication}{NIS}; + install_any::disable_user_view() if $o->{security} >= 3 || $o->{authentication}{NIS}; run_program::rooted($o->{prefix}, "kdeDesktopCleanup"); foreach (list_skels($o->{prefix}, '.kde/share/config/kfmrc')) { @@ -782,7 +782,7 @@ sub setRootPassword { my ($o) = @_; $o->{superuser} ||= {}; $o->{superuser}{name} = 'root'; - any::write_passwd_user($o->{prefix}, $o->{superuser}, $o->{authentication}{md5}); + any::write_passwd_user($o->{superuser}, $o->{authentication}{md5}); delete $o->{superuser}{name}; install_any::set_authentication($o); } @@ -791,17 +791,16 @@ sub setRootPassword { sub addUser { my ($o) = @_; - my $p = $o->{prefix}; my $users = $o->{users} ||= []; my (%uids, %gids); - foreach (glob_("$p/home")) { my ($u, $g) = (stat($_))[4,5]; $uids{$u} = 1; $gids{$g} = 1 } + foreach (glob_("$::prefix/home")) { my ($u, $g) = (stat($_))[4,5]; $uids{$u} = 1; $gids{$g} = 1 } foreach (@$users) { $_->{home} ||= "/home/$_->{name}"; - my $u = $_->{uid} || ($_->{oldu} = (stat("$p$_->{home}"))[4]) || int getpwnam($_->{name}); - my $g = $_->{gid} || ($_->{oldg} = (stat("$p$_->{home}"))[5]) || int getgrnam($_->{name}); + my $u = $_->{uid} || ($_->{oldu} = (stat("$::prefix$_->{home}"))[4]) || int getpwnam($_->{name}); + my $g = $_->{gid} || ($_->{oldg} = (stat("$::prefix$_->{home}"))[5]) || int getgrnam($_->{name}); #- search for available uid above 501 else initscripts may fail to change language for KDE. if (!$u || getpwuid($u)) { for ($u = 501; getpwuid($u) || $uids{$u}; $u++) {} } if (!$g) { for ($g = 501; getgrgid($g) || $gids{$g}; $g++) {} } @@ -810,34 +809,34 @@ sub addUser { $_->{gid} = $g; $gids{$g} = 1; } - any::write_passwd_user($p, $_, $o->{authentication}{md5}) foreach @$users; + any::write_passwd_user($_, $o->{authentication}{md5}) foreach @$users; - append_to_file("$p/etc/group", + append_to_file("$::prefix/etc/group", map { "$_->{name}:x:$_->{gid}:\n" } grep { ! getgrgid($_->{gid}) } @$users); foreach my $u (@$users) { - if (! -d "$p$u->{home}") { + if (! -d "$::prefix$u->{home}") { my $mode = $o->{security} < 2 ? 0755 : 0750; - eval { cp_af("$p/etc/skel", "$p$u->{home}") }; + eval { cp_af("$::prefix/etc/skel", "$::prefix$u->{home}") }; if ($@) { - log::l("copying of skel failed: $@"); mkdir("$p$u->{home}", $mode); + log::l("copying of skel failed: $@"); mkdir("$::prefix$u->{home}", $mode); } else { - chmod $mode, "$p$u->{home}"; + chmod $mode, "$::prefix$u->{home}"; } } require commands; - eval { commands::chown_("-r", "$u->{uid}.$u->{gid}", "$p$u->{home}") } + eval { commands::chown_("-r", "$u->{uid}.$u->{gid}", "$::prefix$u->{home}") } if $u->{uid} != $u->{oldu} || $u->{gid} != $u->{oldg}; } #- since we wrote the password in /etc/passwd, we must convert to shadow run_program::rooted($::prefix, 'pwconv') if $o->{authentication}{shadow}; - any::addUsers($p, $users); + any::addUsers($users); $o->pkg_install("autologin") if $o->{autologin}; any::set_autologin($o->{autologin}, $o->{desktop}); - install_any::disable_user_view($p) if @$users == (); + install_any::disable_user_view() if @$users == (); } #------------------------------------------------------------------------------ diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm index 96ecd18ad..6c7ba0e49 100644 --- a/perl-install/install_steps_interactive.pm +++ b/perl-install/install_steps_interactive.pm @@ -1163,7 +1163,7 @@ sub addUser { if !member('mandrake', map { $_->{name} } @{$o->{users}}); } if ($o->{security} >= 1 || $clicked) { - any::ask_users($o->{prefix}, $o, $o->{users}, $o->{security}); + any::ask_users($o, $o->{users}, $o->{security}); } add2hash($o, any::get_autologin()); any::autologin($o, $o); diff --git a/perl-install/standalone/adduserdrake b/perl-install/standalone/adduserdrake index 4bbad2fa3..e5c1fc611 100755 --- a/perl-install/standalone/adduserdrake +++ b/perl-install/standalone/adduserdrake @@ -9,7 +9,7 @@ use interactive; use any; 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 @shells = any::shells(); my $isMD5 = cat_("/etc/pam.d/system-auth") =~ /md5/; my $isShadow = cat_("/etc/pam.d/system-auth") =~ /shadow/; @@ -21,13 +21,13 @@ if (my @l = grep { ! /^-/ } @ARGV) { $users = [ map { { name => $_, realname => $_ } } @l ]; } else { $in = 'interactive'->vnew('su'); - any::ask_users('', $in, $users, $ENV{SECURE_LEVEL}); + any::ask_users($in, $users, $ENV{SECURE_LEVEL}); } system("adduser", $_->{name}) foreach @$users; any::write_passwd_user('', $_, $isMD5) foreach @$users; system("pwconv") if $isShadow; -any::addUsers('', $users); +any::addUsers($users); $in->exit(0) if $in; |