summaryrefslogtreecommitdiffstats
path: root/perl-install/any.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2003-08-01 22:19:44 +0000
committerPascal Rigaux <pixel@mandriva.com>2003-08-01 22:19:44 +0000
commit58ef253941a439f8c880bc9bffd83790e6eccd21 (patch)
tree9f2efadd02b7dea07d5c7f9a07f0bc48319d3bf2 /perl-install/any.pm
parenta6f8275a74dd684e2b35010b0ba28a1d3b9cca23 (diff)
downloaddrakx-58ef253941a439f8c880bc9bffd83790e6eccd21.tar
drakx-58ef253941a439f8c880bc9bffd83790e6eccd21.tar.gz
drakx-58ef253941a439f8c880bc9bffd83790e6eccd21.tar.bz2
drakx-58ef253941a439f8c880bc9bffd83790e6eccd21.tar.xz
drakx-58ef253941a439f8c880bc9bffd83790e6eccd21.zip
- move write_smb_conf() from install_any to network::smb
- rename setAuthentication() to set_authentication() - move the work of set_authentication() from install_any to any - move the per-authentification kind questions from install_steps_interactive::setRootPassword() to any::ask_authentification_parameters() - various cleanup in code prompting authentification questions - call install_any::set_authentication() in install_steps::setRootPassword() instead of waiting for the installPackages step to be done (since setRootPassword occurs *after* packages installation) - don't call set_authentification() in install_steps::addUser() (why was this done there??) => these changes will allow drakauth
Diffstat (limited to 'perl-install/any.pm')
-rw-r--r--perl-install/any.pm92
1 files changed, 92 insertions, 0 deletions
diff --git a/perl-install/any.pm b/perl-install/any.pm
index 83083afa1..b404b621c 100644
--- a/perl-install/any.pm
+++ b/perl-install/any.pm
@@ -973,4 +973,96 @@ sub config_mtools {
} $file;
}
+
+sub authentication_kinds() {
+ ('local', 'LDAP', 'NIS', 'winbind');
+}
+sub authentication_kind2description {
+ my ($kind) = @_;
+ ${{ local => N("Local files"), LDAP => N("LDAP"), NIS => N("NIS"), winbind => N("Windows Domain") }}{$kind};
+}
+sub authentication2authentication_kind {
+ my ($authentication) = @_;
+ (find { $authentication->{$_} } authentication_kinds()) || 'local';
+}
+
+sub ask_authentification_parameters {
+ my ($in, $netc, $authentication, $authentication_kind) = @_;
+
+ my $val = $authentication->{$authentication_kind};
+
+ if ($authentication_kind eq 'LDAP') {
+ $val ||= 'ldap.' . $netc->{DOMAINNAME};
+ $netc->{LDAPDOMAIN} ||= join(',', map { "dc=$_" } split /\./, $netc->{DOMAINNAME});
+ $in->ask_from('',
+ N("Authentication LDAP"),
+ [ { label => N("LDAP Base dn"), val => \$netc->{LDAPDOMAIN} },
+ { label => N("LDAP Server"), val => \$val },
+ ]) or return;
+ } elsif ($authentication_kind eq 'NIS') {
+ $val ||= 'broadcast';
+ $in->ask_from('',
+ N("Authentication NIS"),
+ [ { label => N("NIS Domain"), val => \ ($netc->{NISDOMAIN} ||= $netc->{DOMAINNAME}) },
+ { label => N("NIS Server"), val => \$val, list => ["broadcast"], not_edit => 0 },
+ ]) or return;
+ } elsif ($authentication_kind eq 'winbind') {
+ #- maybe we should browse the network like diskdrake --smb and get the 'doze server names in a list
+ #- but networking isn't setup yet necessarily
+ $in->ask_warn('', N("For this to work for a W2K PDC, you will probably need to have the admin run: C:\\>net localgroup \"Pre-Windows 2000 Compatible Access\" everyone /add and reboot the server.\nYou will also need the username/password of a Domain Admin to join the machine to the Windows(TM) domain.\nIf networking is not yet enabled, Drakx will attempt to join the domain after the network setup step.\nShould this setup fail for some reason and domain authentication is not working, run 'smbpasswd -j DOMAIN -U USER%%PASSWORD' using your Windows(tm) Domain, and Admin Username/Password, after system boot.\nThe command 'wbinfo -t' will test whether your authentication secrets are good."));
+ $in->ask_from('',
+ N("Authentication Windows Domain"),
+ [ { label => N("Windows Domain"), val => \ ($netc->{WINDOMAIN} ||= $netc->{DOMAINNAME}) },
+ { label => N("Domain Admin User Name"), val => \$val },
+ { label => N("Domain Admin Password"), val => \$authentication->{winpass}, hidden => 1 },
+ ]) or return;
+ }
+ #- keep only one authentication
+ delete $authentication->{$_} foreach authentication_kinds();
+ $authentication->{$authentication_kind} = $val;
+ 1;
+}
+
+sub set_authentication {
+ my ($in, $netc, $authentication, $when_network_is_up) = @_;
+ my ($shadow, $ldap, $nis, $winbind, $winpass) = @$authentication{qw(shadow LDAP NIS winbind winpass)};
+ enableShadow() if $shadow;
+ if ($ldap) {
+ $in->do_pkgs->install(qw(chkauth openldap-clients nss_ldap pam_ldap));
+ run_program::rooted($::prefix, "/usr/sbin/chkauth", "ldap", "-D", $netc->{LDAPDOMAIN}, "-s", $ldap);
+ } elsif ($nis) {
+ #$o->pkg_install(qw(chkauth ypbind yp-tools net-tools));
+ #run_program::rooted($::prefix, "/usr/sbin/chkauth", "yp", $domain, "-s", $nis);
+ $in->do_pkgs->install("ypbind");
+ my $domain = $netc->{NISDOMAIN};
+ $domain || $nis ne "broadcast" or die \N("Can't use broadcast with no NIS domain");
+ my $t = $domain ? "domain $domain" . ($nis ne "broadcast" && " server") : "ypserver";
+ substInFile {
+ $_ = "#~$_" unless /^#/;
+ $_ .= "$t $nis\n" if eof;
+ } "$::prefix/etc/yp.conf";
+ require network;
+ network::write_conf("$::prefix/etc/sysconfig/network", $netc);
+ } elsif ($winbind) {
+ my $domain = $netc->{WINDOMAIN};
+ $domain =~ tr/a-z/A-Z/;
+
+ $in->do_pkgs->install(qw(samba-winbind samba-common));
+ { #- setup pam
+ my $f = "$::prefix/etc/pam.d/system-auth";
+ cp_af($f, "$f.orig");
+ cp_af("$f-winbind", $f);
+ }
+ require network::smb;
+ network::smb::write_smb_conf($domain);
+ run_program::rooted($::prefix, "chkconfig", "--level", "35", "winbind", "on");
+ mkdir_p("$::prefix/home/$domain");
+
+ #- defer running smbpassword until the network is up
+ $when_network_is_up->(sub {
+ run_program::rooted($::prefix, "/usr/bin/smbpasswd", "-j", $domain, "-U", $winbind . "%" . $winpass);
+ });
+ }
+}
+
1;