package authentication; # $Id$ use common; use any; sub kinds { my $no_para = @_ == 0; my ($do_pkgs, $meta_class) = @_; my $allow_SmartCard = $no_para || $do_pkgs->is_available('castella-pam'); my $allow_AD = $no_para || $meta_class =~ /corporate/; ( 'local', 'LDAP', 'NIS', if_($allow_SmartCard, 'SmartCard'), 'winbind', if_($allow_AD, 'AD', 'SMBKRB'), ); } sub kind2name { my ($kind) = @_; # Keep the following strings in sync with kind2description ones!!! ${{ local => N("Local file"), LDAP => N("LDAP"), NIS => N("NIS"), SmartCard => N("Smart Card"), winbind => N("Windows Domain"), AD => N("Active Directory with SFU"), SMBKRB => N("Active Directory with Winbind") }}{$kind}; } my %kind2pam_kind = ( local => [], SmartCard => ['castella'], LDAP => ['ldap'], NIS => [], AD => ['krb5'], winbind => ['winbind'], SMBKRB => ['winbind'], ); my %kind2nsswitch = ( local => [], SmartCard => [], LDAP => ['ldap'], NIS => ['nis'], AD => ['ldap'], winbind => ['winbind'], SMBKRB => ['winbind'], ); sub kind2description { my (@kinds) = @_; my %kind2description = ( local => [ N("Local file:"), N("Use local for all authentication and information user tell in local file"), ], LDAP => [ N("LDAP:"), N("Tells your computer to use LDAP for some or all authentication. LDAP consolidates certain types of information within your organization."), ], NIS => [ N("NIS:"), N("Allows you to run a group of computers in the same Network Information Service domain with a common password and group file."), ], winbind => [ N("Windows Domain:"), N("Winbind allows the system to retrieve information and authenticate users in a Windows domain."), ], AD => [ N("Active Directory with SFU:"), N("Kerberos is a secure system for providing network authentication services."), ], SMBKRB => [ N("Active Directory with Winbind:"), N("Kerberos is a secure system for providing network authentication services.") ], ); join('', map { $_ ? qq($_->[0]\n$_->[1]\n\n) : '' } map { $kind2description{$_} } @kinds); } sub to_kind { my ($authentication) = @_; (find { exists $authentication->{$_} } kinds()) || 'local'; } sub domain_to_ldap_domain { my ($domain) = @_; join(',', map { "dc=$_" } split /\./, $domain); } sub ask_parameters { my ($in, $netc, $authentication, $kind) = @_; #- keep only this authentication kind foreach (kinds()) { delete $authentication->{$_} if $_ ne $kind; } if ($kind eq 'LDAP') { $netc->{LDAPDOMAIN} ||= domain_to_ldap_domain($netc->{DOMAINNAME}); $in->ask_from('', N("Authentication LDAP"), [ { label => N("LDAP Base dn"), val => \$netc->{LDAPDOMAIN} }, { label => N("LDAP Server"), val => \$authentication->{LDAP_server} }, ]) or return; } elsif ($kind eq 'AD') { $authentication->{AD_domain} ||= $netc->{DOMAINNAME}; $authentication->{AD_users_db} ||= 'cn=users,' . domain_to_ldap_domain($authentication->{AD_domain}); $in->do_pkgs->install(qw(perl-Net-DNS)); my @srvs = query_srv_names($authentication->{AD_domain}); $authentication->{AD_server} ||= $srvs[0] if @srvs; my %sub_kinds = my @sub_kinds = ( simple => N("simple"), tls => N("TLS"), ssl => N("SSL"), kerberos => N("security layout (SASL/Kerberos)"), ); my $AD_user = $authentication->{AD_user} =~ /(.*)\@\Q$authentication->{AD_domain}\E$/ ? $1 : $authentication->{AD_user}; my $anonymous = $AD_user; $in->ask_from('', N("Authentication Active Directory"), [ { label => N("Domain"), val => \$authentication->{AD_domain} }, #{ label => N("Server"), val => \$authentication->{AD_server} }, { label => N("Server"), type => 'combo', val => \$authentication->{AD_server}, list => \@srvs , not_edit => 0 }, { label => N("LDAP users database"), val => \$authentication->{AD_users_db} }, { label => N("Use Anonymous BIND "), val => \$anonymous, type => 'bool' }, { label => N("LDAP user allowed to browse the Active Directory"), val => \$AD_user, disabled => sub { $anonymous } }, { label => N("Password for user"), val => \$authentication->{AD_password}, disabled => sub { $anonymous } }, { label => N("Encryption"), val => \$authentication->{sub_kind}, list => [ map { $_->[0] } group_by2(@sub_kinds) ], format => sub { $sub_kinds{$_[0]} } }, ]) or return; $authentication->{AD_user} = !$AD_user || $authentication->{sub_kind} eq 'anonymous' ? '' : $AD_user =~ /@/ ? $AD_user : "$AD_user\@$authentication->{AD_domain}"; $authentication->{AD_password} = '' if !$authentication->{AD_user}; } elsif ($kind eq 'NIS') { $authentication->{NIS_server} ||= 'broadcast'; $netc->{NISDOMAIN} ||= $netc->{DOMAINNAME}; $in->ask_from('', N("Authentication NIS"), [ { label => N("NIS Domain"), val => \$netc->{NISDOMAIN} }, { label => N("NIS Server"), val => \$authentication->{NIS_server}, list => ["broadcast"], not_edit => 0 }, ]) or return; } elsif ($kind eq 'winbind' || $kind eq 'SMBKRB') { #- maybe we should browse the network like diskdrake --smb and get the 'doze server names in a list #- but networking is not 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. You will also need the username/password of a Domain Admin to join the machine to the Windows(TM) domain. If networking is not yet enabled, Drakx will attempt to join the domain after the network setup step. Should 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. The command 'wbinfo -t' will test whether your authentication secrets are good.")) if $kind eq 'winbind'; $authentication->{AD_domain} ||= $netc->{DOMAINNAME} if $kind eq 'SMBKRB'; $authentication->{AD_users_idmap} ||= 'ou=idmap,' . domain_to_ldap_domain($authentication->{AD_domain}) if $kind eq 'SMBKRB'; $netc->{WINDOMAIN} ||= $netc->{DOMAINNAME}; my $anonymous; $in->ask_from('', $kind eq 'SMBKRB' ? N("Authentication Active Directory") : N("Authentication Windows Domain"), [ if_($kind eq 'SMBKRB', { label => N("Domain"), val => \$authentication->{AD_domain} } ), { label => N("Windows Domain"), val => \$netc->{WINDOMAIN} }, { label => N("Domain Admin User Name"), val => \$authentication->{winuser} }, { label => N("Domain Admin Password"), val => \$authentication->{winpass}, hidden => 1 }, { label => N("Use Idmap for store UID/SID "), val => \$anonymous, type => 'bool' }, { label => N("Default Idmap "), val => \$authentication->{AD_users_idmap}, disabled => sub { $anonymous } }, ]) or return; } $authe