summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2004-07-26 08:29:31 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2004-07-26 08:29:31 +0000
commit916224e6ac6736c6b468b2f7cf3b3628645d6f5c (patch)
treea6bb27c7114729dfe283728cee36ecf1183f7c7e
parent2b32eb8ec4e95a7ece4a6fec6d0aa1026a210fbe (diff)
downloaddrakx-backup-do-not-use-916224e6ac6736c6b468b2f7cf3b3628645d6f5c.tar
drakx-backup-do-not-use-916224e6ac6736c6b468b2f7cf3b3628645d6f5c.tar.gz
drakx-backup-do-not-use-916224e6ac6736c6b468b2f7cf3b3628645d6f5c.tar.bz2
drakx-backup-do-not-use-916224e6ac6736c6b468b2f7cf3b3628645d6f5c.tar.xz
drakx-backup-do-not-use-916224e6ac6736c6b468b2f7cf3b3628645d6f5c.zip
merge auth fixes from HEAD
-rw-r--r--perl-install/authentication.pm468
-rw-r--r--perl-install/network/smb.pm32
-rwxr-xr-xperl-install/standalone/drakauth4
3 files changed, 413 insertions, 91 deletions
diff --git a/perl-install/authentication.pm b/perl-install/authentication.pm
index bde5ed6fd..0b64ca17d 100644
--- a/perl-install/authentication.pm
+++ b/perl-install/authentication.pm
@@ -2,20 +2,48 @@ package authentication; # $Id$
use common;
use any;
-
+use Net::DNS;
sub kinds() {
- ('local', 'LDAP', 'NIS', 'winbind');
+ ('local', 'LDAP', 'NIS', 'winbind', 'AD', 'SMBKRB');
}
-sub kind2description {
+
+sub kind2name {
my ($kind) = @_;
- ${{ local => N("Local files"), LDAP => N("LDAP"), NIS => N("NIS"), winbind => N("Windows Domain") }}{$kind};
+ # Keep the following strings in sync with kind2description ones!!!
+ ${{ local => N("Local file"),
+ LDAP => N("LDAP"),
+ NIS => N("NIS"),
+ winbind => N("Windows Domain"),
+ AD => N("Active Directory with SFU"),
+ SMBKRB => N("Active Directory with Winbind") }}{$kind};
+}
+
+sub kind2description() {
+ join('',
+ map {
+ qq($_->[0]\n$_->[1]\n\n)
+ }
+ (
+ [ N("Local file:"), N("Use local for all authentication and information user tell in local file"), ],
+ [ N("LDAP:"), N("Tells your computer to use LDAP for some or all authentication. LDAP consolidates certain types of information within your organization."), ],
+ [ 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."), ],
+ [ N("Windows Domain:"), N("Winbind allows a system to retrieve information about users and to authenticate users by using in an Windows domain."), ],
+ [ N("Active Directory with SFU:"), N("Kerberos is a secure system for providing network authentication services."), ],
+ [ N("Active Directory with Winbind:"), N("Kerberos is a secure system for providing network authentication services.") ],
+ )
+ );
}
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) = @_;
@@ -24,35 +52,78 @@ sub ask_parameters {
delete $authentication->{$_} if $_ ne $kind;
}
- my $val = $authentication->{$kind} ||= '';
-
if ($kind eq 'LDAP') {
- $val ||= 'ldap.' . $netc->{DOMAINNAME};
- $netc->{LDAPDOMAIN} ||= join(',', map { "dc=$_" } split /\./, $netc->{DOMAINNAME});
+ $authentication->{LDAP_server} ||= 'ldap.' . $netc->{DOMAINNAME};
+ $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 => \$val },
+ { 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});
+
+ find_srv_name($authentication->{AD_domain});
+ $authentication->{AD_server} ||= $data[0] if @data;
+
+ 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 => \@data , 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') {
- $val ||= 'broadcast';
+ $authentication->{NIS_server} ||= 'broadcast';
+ $netc->{NISDOMAIN} ||= $netc->{DOMAINNAME};
$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 },
+ [ { 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') {
+ } 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 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_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."))
+ 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};
$in->ask_from('',
- N("Authentication Windows Domain"),
- [ { label => N("Windows Domain"), val => \ ($netc->{WINDOMAIN} ||= $netc->{DOMAINNAME}) },
- { label => N("Domain Admin User Name"), val => \$val },
+ $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;
}
- $authentication->{$kind} = $val;
+ $authentication->{$kind} ||= 1;
1;
}
@@ -62,29 +133,92 @@ sub set {
any::enableShadow() if $authentication->{shadow};
my $kind = authentication::to_kind($authentication);
- my $val = $authentication->{$kind};
- log::l("authentication::set $kind with $val");
+ log::l("authentication::set $kind");
if ($kind eq 'LDAP') {
$in->do_pkgs->install(qw(openldap-clients nss_ldap pam_ldap autofs));
my $domain = $netc->{LDAPDOMAIN} || do {
- my $s = run_program::rooted_get_stdout($::prefix, 'ldapsearch', '-x', '-h', $val, '-b', '', '-s', 'base', '+');
+ my $s = run_program::rooted_get_stdout($::prefix, 'ldapsearch', '-x', '-h', $authentication->{LDAP_server}, '-b', '', '-s', 'base', '+');
first($s =~ /namingContexts: (.+)/);
- } or log::l("no ldap domain found on server $val"), return;
+ } or log::l("no ldap domain found on server $authentication->{LDAP_server}"), return;
set_nsswitch_priority('ldap');
set_pam_authentication('ldap');
- set_ldap_conf($domain, $val, 1);
+
+ update_ldap_conf(
+ host => $authentication->{LDAP_server},
+ base => $domain,
+ port => 636,
+ ssl => 'on',
+ nss_base_shadow => "ou=People,$domain",
+ nss_base_passwd => "ou=People,$domain",
+ nss_base_group => "ou=Group,$domain",
+ );
+ } elsif ($kind eq 'AD') {
+ $in->do_pkgs->install(qw(nss_ldap pam_krb5 libsasl2-plug-gssapi));
+ my $port = "389";
+
+ set_nsswitch_priority('ldap');
+ set_pam_authentication('krb5');
+
+ my $ssl = {
+ anonymous => 'off',
+ simple => 'off',
+ tls => 'start_tls',
+ ssl => 'on',
+ kerberos => 'off',
+ }->{$authentication->{sub_kind}};
+
+ if ($ssl eq 'on') {
+ $port = '636';
+ };
+
+
+
+ update_ldap_conf(
+ host => $authentication->{AD_server},
+ base => domain_to_ldap_domain($authentication->{AD_domain}),
+ nss_base_shadow => "$authentication->{AD_users_db}?sub",
+ nss_base_passwd => "$authentication->{AD_users_db}?sub",
+ nss_base_group => "$authentication->{AD_users_db}?sub",
+
+ ssl => $ssl,
+ sasl_mech => $authentication->{sub_kind} eq 'kerberos' ? 'GSSAPI' : '',
+ port => $port,
+
+ binddn => $authentication->{AD_user},
+ bindpw => $authentication->{AD_password},
+
+ (map_each { "nss_map_objectclass_$::a" => $::b }
+ posixAccount => 'User',
+ shadowAccount => 'User',
+ posixGroup => 'Group',
+ ),
+ (map_each { "nss_map_attribute_$::a" => $::b }
+ uid => 'sAMAccountName',
+ uidNumber => 'msSFU30UidNumber',
+ gidNumber => 'msSFU30GidNumber',
+ cn => 'sAMAccountName',
+ uniqueMember => 'member',
+ userPassword => 'msSFU30Password',
+ homeDirectory => 'msSFU30HomeDirectory',
+ LoginShell => 'msSFU30LoginShell',
+ gecos => 'name',
+ ),
+ );
+
+ configure_krb5_for_AD($authentication);
+
} elsif ($kind eq 'NIS') {
$in->do_pkgs->install(qw(ypbind autofs));
my $domain = $netc->{NISDOMAIN};
- $domain || $val ne "broadcast" or die N("Can't use broadcast with no NIS domain");
- my $t = $domain ? "domain $domain" . ($val ne "broadcast" && " server") : "ypserver";
+ $domain || $authentication->{NIS_server} ne "broadcast" or die N("Can't use broadcast with no NIS domain");
+ my $t = $domain ? "domain $domain" . ($authentication->{NIS_server} ne "broadcast" && " server") : "ypserver";
substInFile {
$_ = "#~$_" unless /^#/;
- $_ .= "$t $val\n" if eof;
+ $_ .= "$t $authentication->{NIS_server}\n" if eof;
} "$::prefix/etc/yp.conf";
set_nsswitch_priority('nis');
@@ -94,28 +228,59 @@ sub set {
run_program::rooted($::prefix, 'nisdomainname', $domain);
run_program::rooted($::prefix, 'service', 'ypbind', 'restart');
}) if !$::isInstall; #- TODO: also do it during install since nis can be useful to resolve domain names. Not done because 9.2-RC
+# } elsif ($kind eq 'winbind' || $kind eq 'AD' && $authentication->{subkind} eq 'winbind') {
+
+# }) if !$::isInstall;
+#- TODO: also do it during install since nis can be useful to resolve domain names. Not done because 9.2-RC
} elsif ($kind eq 'winbind') {
- my $domain = $netc->{WINDOMAIN};
- $domain =~ tr/a-z/A-Z/;
- $in->do_pkgs->install(qw(samba-winbind samba-common));
+ my $domain = uc $netc->{WINDOMAIN};
+
+ $in->do_pkgs->install('samba-winbind');
+ set_nsswitch_priority('winbind');
set_pam_authentication('winbind');
require network::smb;
network::smb::write_smb_conf($domain);
run_program::rooted($::prefix, "chkconfig", "--level", "35", "winbind", "on");
mkdir_p("$::prefix/home/$domain");
+ run_program::rooted($::prefix, 'service', 'smb', 'restart');
+ run_program::rooted($::prefix, 'service', 'winbind', 'restart');
#- defer running smbpassword until the network is up
+
$when_network_is_up->(sub {
- run_program::rooted($::prefix, 'smbpasswd', '-j', $domain, '-U', $val . '%' . $authentication->{winpass});
+ run_program::rooted($::prefix, 'net','join', '-j', $domain, '-U', $authentication->{winuser} . '%' . $authentication->{winpass});
+ });
+ } elsif ($kind eq 'SMBKRB') {
+ $authentication->{AD_server} ||= 'ads.' . $authentication->{AD_domain};
+ my $domain = uc $netc->{WINDOMAIN};
+ my $realm = $authentication->{AD_domain};
+ my $srvtime = $authentication->{AD_server};
+
+ configure_krb5_for_AD($authentication);
+ $in->do_pkgs->install('samba-winbind', 'pam_krb5','samba-server', 'samba-client');
+ set_nsswitch_priority('winbind');
+ set_pam_authentication('winbind');
+
+
+ require network::smb;
+ network::smb::write_smb_ads_conf($domain,$realm);
+ run_program::rooted($::prefix, "chkconfig", "--level", "35", "winbind", "on");
+ mkdir_p("$::prefix/home/$domain");
+ run_program::rooted($::prefix, 'net','time','set','-S',$authentication->{AD_server});
+ run_program::rooted($::prefix, 'service', 'smb', 'restart');
+ run_program::rooted($::prefix, 'service', 'winbind', 'restart');
+
+ $when_network_is_up->(sub {
+ run_program::rooted($::prefix, 'net', 'ads', 'join', '-U', $authentication->{winuser} . '%' . $authentication->{winpass});
});
}
}
sub pam_modules() {
- 'pam_ldap', 'pam_winbind', 'pam_mkhomedir';
+ 'pam_ldap', 'pam_winbind', 'pam_krb5', 'pam_mkhomedir';
}
sub pam_module_from_path {
$_[0] && $_[0] =~ m|(/lib/security/)?(pam_.*)\.so| && $2;
@@ -139,41 +304,56 @@ sub get_raw_pam_authentication() {
\%before_deny;
}
-sub set_raw_pam_authentication {
- my ($before_deny, $before_first) = @_;
+sub set_pam_authentication {
+ my (@authentication_kinds) = @_;
+
+ my %special = (
+ auth => \@authentication_kinds,
+ account => \@authentication_kinds,
+ password => [ intersection(\@authentication_kinds, [ 'ldap', 'krb5' ]) ],
+ );
+ my %before_first = (
+ session => intersection(\@authentication_kinds, [ 'winbind', 'krb5' ]) ? pam_format_line('session', 'optional', 'pam_mkhomedir', 'skel=/etc/skel/', 'umask=0022') : '',
+ );
+ my %after_deny = (
+ session => member('krb5', @authentication_kinds) ? pam_format_line('session', 'optional', 'pam_krb5') : '',
+ );
+
substInFile {
my ($type, $control, $module, @para) = split;
- my $added_pre_line = '';
if ($module = pam_module_from_path($module)) {
- if ($module eq 'pam_unix' && member($type, 'auth', 'account')) {
- #- remove likeauth, nullok and use_first_pass
- $_ = pam_format_line($type, 'sufficient', $module, grep { !member($_, qw(likeauth nullok use_first_pass)) } @para);
+ if (member($module, pam_modules())) {
+ #- first removing previous config
+ $_ = '';
+ }
+ if ($module eq 'pam_unix' && $special{$type} && @{$special{$type}}) {
+ my @para_for_last =
+ $type eq 'auth' ? qw(likeauth nullok use_first_pass) :
+ $type eq 'account' ? qw(use_first_pass) : @{[]};
+ @para = difference2(\@para, \@para_for_last);
+
+ my ($before, $after) = partition { $_ eq 'krb5' } @{$special{$type}};
+ my @l = ((map { [ "pam_$_" ] } @$before),
+ [ 'pam_unix', @para ],
+ (map { [ "pam_$_" ] } @$after),
+ );
+ push @{$l[-1]}, @para_for_last;
+ $_ = join('', map { pam_format_line($type, 'sufficient', @$_) } @l);
+
if ($control eq 'required') {
#- ensure a pam_deny line is there
($control, $module, @para) = ('required', 'pam_deny');
- ($added_pre_line, $_) = ($_, pam_format_line($type, $control, $module));
+ $_ .= pam_format_line($type, $control, $module);
}
}
- if (member($module, pam_modules())) {
- #- first removing previous config
- warn "dropping line $_";
- $_ = '';
- } else {
- if ($before_first->{$type}) {
- foreach my $module (keys %{$before_first->{$type}}) {
- $_ = pam_format_line($type, 'required', $module, @{$before_first->{$type}{$module}}) . $_;
- }
- delete $before_first->{$type};
- }
- if ($control eq 'required' && $module eq 'pam_deny') {
- if ($before_deny->{$type}) {
- foreach my $module (keys %{$before_deny->{$type}}) {
- $_ = pam_format_line($type, 'sufficient', $module, @{$before_deny->{$type}{$module}}) . $_;
- }
- }
+ if (my $s = delete $before_first{$type}) {
+ $_ = $s . $_;
+ }
+ if ($control eq 'required' && member($module, 'pam_deny', 'pam_unix')) {
+ if (my $s = delete $after_deny{$type}) {
+ $_ .= $s;
}
}
- $_ = $added_pre_line . $_;
}
} "$::prefix/etc/pam.d/system-auth";
}
@@ -183,20 +363,6 @@ sub get_pam_authentication_kinds() {
map { s/pam_//; $_ } keys %{$before_deny->{auth}};
}
-sub set_pam_authentication {
- my (@authentication_kinds) = @_;
- my $before_deny = {};
- my $before_first = {};
- foreach (@authentication_kinds) {
- my $module = 'pam_' . $_;
- $before_deny->{auth}{$module} = [ 'likeauth', 'nullok', 'use_first_pass' ];
- $before_deny->{account}{$module} = [ 'use_first_pass' ];
- $before_deny->{password}{$module} = [] if $_ eq 'ldap';
- $before_first->{session}{pam_mkhomedir} = [ 'skel=/etc/skel/', 'umask=0022' ] if $_ eq 'winbind';
- }
- set_raw_pam_authentication($before_deny, $before_first);
-}
-
sub set_nsswitch_priority {
my (@kinds) = @_;
# allowed: files nis ldap dns
@@ -207,33 +373,159 @@ sub set_nsswitch_priority {
} "$::prefix/etc/nsswitch.conf";
}
+my $special_ldap_cmds = join('|', 'nss_map_attribute', 'nss_map_objectclass');
+sub _after_read_ldap_line {
+ my ($s) = @_;
+ $s =~ s/\b($special_ldap_cmds)\s*/$1 . '_'/e;
+ $s;
+}
+sub _pre_write_ldap_line {
+ my ($s) = @_;
+ $s =~ s/\b($special_ldap_cmds)_/$1 . ' '/e;
+ $s;
+}
+
sub read_ldap_conf() {
- my %conf = map { s/^\s*#.*//; if_(/(\S+)\s+(.*)/, $1 => $2) } cat_("$::prefix/etc/ldap.conf");
+ my %conf = map {
+ s/^\s*#.*//;
+ if_(_after_read_ldap_line($_) =~ /(\S+)\s+(.*)/, $1 => $2);
+ } cat_("$::prefix/etc/ldap.conf");
\%conf;
}
-sub set_ldap_conf {
- my ($domain, $servers, $b_ssl) = @_;
-
- my %wanted_conf = (
- host => $servers,
- base => $domain,
- port => $b_ssl ? 636 : 389,
- ssl => $b_ssl ? 'on' : 'off',
- nss_base_shadow => "ou=People,$domain",
- nss_base_passwd => "ou=People,$domain",
- nss_base_group => "ou=Group,$domain",
- );
+sub update_ldap_conf {
+ my (%conf) = @_;
substInFile {
- my ($cmd) = /^#?\s*(\w+)\s/;
- if ($cmd && exists $wanted_conf{$cmd}) {
- my $val = $wanted_conf{$cmd};
- $wanted_conf{$cmd} = '';
- $_ = $val ? "$cmd $val\n" : '';
+ my ($cmd) = _after_read_ldap_line($_) =~ /^\s*#?\s*(\w+)\s/;
+ if ($cmd && exists $conf{$cmd}) {
+ my $val = $conf{$cmd};
+ $conf{$cmd} = '';
+ $_ = $val ? _pre_write_ldap_line("$cmd $val\n") : /^\s*#/ ? $_ : "#$_";
}
+ if (eof) {
+ foreach my $cmd (keys %conf) {
+ my $val = $conf{$cmd} or next;
+ $_ .= _pre_write_ldap_line("$cmd $val\n");
+ }
+ }
} "$::prefix/etc/ldap.conf";
}
+sub configure_krb5_for_AD {
+ my ($authentication) = @_;
+
+ my $uc_domain = uc $authentication->{AD_domain};
+ my $krb5_conf_file = "$::prefix/etc/krb5.conf";
+
+ krb5_conf_update($krb5_conf_file,
+ libdefaults => (
+ default_realm => $uc_domain,
+ dns_lookup_realm => $authentication->{AD_server} ? 'false' : 'true',
+ dns_lookup_kdc => $authentication->{AD_server} ? 'false' : 'true',
+ ));
+
+ my @sections = (
+ realms => <<EOF,
+ $uc_domain = {
+ kdc = $authentication->{AD_server}:88
+ admin_server = $authentication->{AD_server}:749
+ default_domain = $authentication->{AD_domain}
+ }
+EOF
+ domain_realm => <<EOF,
+ .$authentication->{AD_domain} = $uc_domain
+EOF
+ kdc => <<'EOF',
+ profile = /etc/kerberos/krb5kdc/kdc.conf
+EOF
+ pam => <<'EOF',
+ debug = false
+ ticket_lifetime = 36000
+ renew_lifetime = 36000
+ forwardable = true
+ krb4_convert = false
+EOF
+ login => <<'EOF',
+ krb4_convert = false
+ krb4_get_tickets = false
+EOF
+ );
+ foreach (group_by2(@sections)) {
+ my ($section, $txt) = @$_;
+ krb5_conf_overwrite_category($krb5_conf_file, $section => $authentication->{AD_server} ? $txt : '');
+ }
+}
+
+sub krb5_conf_overwrite_category {
+ my ($file, $category, $new_val) = @_;
+
+ my $done;
+ substInFile {
+ if (my $i = /^\s*\[\Q$category\E\]/i ... /^\[/) {
+ if ($new_val) {
+ if ($i == 1) {
+ $_ .= $new_val;
+ $done = 1;
+ } elsif ($i =~ /E/) {
+ $_ = "\n$_";
+ } else {
+ $_ = '';
+ }
+ } else {
+ $_ = '' if $i !~ /E/;
+ }
+ }
+ #- if category has not been found above.
+ if (eof && $new_val && !$done) {
+ $_ .= "\n[$category]\n$new_val";
+ }
+ } $file;
+}
+
+sub krb5_conf_update {
+ my ($file, $category, %subst_) = @_;
+
+ my %subst = map { lc($_) => [ $_, $subst_{$_} ] } keys %subst_;
+
+ my $s;
+ foreach (MDK::Common::File::cat_($file), "[NOCATEGORY]\n") {
+ if (my $i = /^\s*\[\Q$category\E\]/i ... /^\[/) {
+ if ($i =~ /E/) { #- for last line of category
+ chomp $s; $s .= "\n";
+ $s .= " $_->[0] = $_->[1]\n" foreach values %subst;
+ %subst = ();
+ } elsif (/^\s*([^=]*?)\s*=/) {
+ if (my $e = delete $subst{lc($1)}) {
+ $_ = " $1 = $e->[1]\n";
+ }
+ }
+ }
+ $s .= $_ if !/^\Q[NOCATEGORY]/;
+ }
+
+ #- if category has not been found above.
+ if (keys %subst) {
+ chomp $s;
+ $s .= "\n[$category]\n";
+ $s .= " $_->[0] = $_->[1]\n" foreach values %subst;
+ }
+
+ MDK::Common::File::output($file, $s);
+
+}
+
+sub find_srv_name {
+
+ my ($domain) = @_;
+ my $res = Net::DNS::Resolver->new;
+ my $dom = "_ldap._tcp.".$domain;
+ my $query = $res->query("$dom", "srv");
+ foreach ($query->answer) {
+ my $srv = ($query->answer)[$_];
+ push (@data,$_->target);
+ }
+ return @data;
+}
1;
diff --git a/perl-install/network/smb.pm b/perl-install/network/smb.pm
index 941463c65..4ef3f45a4 100644
--- a/perl-install/network/smb.pm
+++ b/perl-install/network/smb.pm
@@ -42,7 +42,7 @@ sub smbclient {
my $group = $server->{group} ? " -W $server->{group}" : '';
my $U = $server->{username} ? sprintf("%s/%s%%%s", @$server{'domain', 'username', 'password'}) : '%';
- `smbclient -U $U -L $name $ip$group`;
+ `smbclient -U $U -L $name $ip$group 2>/dev/null`;
}
sub find_servers {
@@ -178,4 +178,34 @@ sub write_smb_conf {
");
}
+sub write_smb_ads_conf {
+ my ($domain, $realm) = @_;
+
+ #- was going to just have a canned config in samba-winbind
+ #- and replace the domain, but sylvestre/buchan didn't bless it yet
+
+ my $f = "$::prefix/etc/samba/smb.conf";
+ rename $f, "$f.orig";
+ output($f, "
+[global]
+ workgroup = $domain
+ realm = $realm
+ server string = Samba Member %v
+ security = ads
+ encrypt passwords = Yes
+ password server = *
+ log file = /var/log/samba/log.%m
+ max log size = 50
+ socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
+ os level = 18
+ local master = No
+ dns proxy = No
+ winbind uid = 10000-20000
+ winbind gid = 10000-20000
+ winbind separator = +
+ template homedir = /home/%D/%U
+ template shell = /bin/bash
+ winbind use default domain = yes
+");
+}
1;
diff --git a/perl-install/standalone/drakauth b/perl-install/standalone/drakauth
index f091a3000..8fdb40896 100755
--- a/perl-install/standalone/drakauth
+++ b/perl-install/standalone/drakauth
@@ -21,9 +21,9 @@ my $authentication = {}; # TODO
my $kind = authentication::to_kind($authentication);
main:
-$in->ask_from('', '',
+$in->ask_from(N("Authentication"), authentication::kind2description(),
[
- { label => N("Authentication"), val => \$kind, list => [ authentication::kinds() ], format => \&authentication::kind2description },
+ { label => N("Authentication"), val => \$kind, type => 'list' , list => [ authentication::kinds() ], format => \&authentication::kind2name },
]) or $in->exit;
authentication::ask_parameters($in, $netc, $authentication, $kind) or goto main;