summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2002-06-07 17:05:45 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2002-06-07 17:05:45 +0000
commit6a71fd6cbac0694e2f5ab24ab65a4628c9be3835 (patch)
tree56cf4b271d952497985c658f2ac2e1544f39f656
parent071b49a866f2c6e4220330dc3e8b4a3214e2cfac (diff)
downloaddrakx-6a71fd6cbac0694e2f5ab24ab65a4628c9be3835.tar
drakx-6a71fd6cbac0694e2f5ab24ab65a4628c9be3835.tar.gz
drakx-6a71fd6cbac0694e2f5ab24ab65a4628c9be3835.tar.bz2
drakx-6a71fd6cbac0694e2f5ab24ab65a4628c9be3835.tar.xz
drakx-6a71fd6cbac0694e2f5ab24ab65a4628c9be3835.zip
split ask_browse_tree_info from interactive_gtk
to my_gtk between widgets creation and real stuff so that we can now call it with widgets places differently
-rw-r--r--perl-install/interactive_gtk.pm197
-rw-r--r--perl-install/my_gtk.pm206
2 files changed, 208 insertions, 195 deletions
diff --git a/perl-install/interactive_gtk.pm b/perl-install/interactive_gtk.pm
index 3abdb065e..6717d0149 100644
--- a/perl-install/interactive_gtk.pm
+++ b/perl-install/interactive_gtk.pm
@@ -587,201 +587,8 @@ sub ask_fromW {
sub ask_browse_tree_info_refW {
my ($o, $common) = @_;
- my ($curr, $parent, $info_widget, $w_size, $prev_label, $go, $idle);
- my (%wtree, %ptree, %pix);
-
- my $w = my_gtk->new($common->{title});
- my $tree = Gtk::CTree->new(3, 0);
- $tree->set_selection_mode('browse');
- $tree->set_column_width(0, 200);
- $tree->set_column_auto_resize($_, 1) foreach 1..2;
-
- gtkadd($w->{window},
- gtkpack_(new Gtk::VBox(0,5),
- 0, $common->{message},
- 1, gtkpack(new Gtk::HBox(0,0),
- createScrolledWindow($tree),
- gtkadd(gtkset_usize(new Gtk::Frame(_("Info")), $::windowwidth - 490, 0),
- createScrolledWindow($info_widget = new Gtk::Text),
- )),
- 0, my $l = new Gtk::HBox(0,15),
- 0, gtkpack(new Gtk::HBox(0,10),
- $go = gtksignal_connect(new Gtk::Button($common->{ok}), "clicked" => sub { $w->{retval} = 1; Gtk->main_quit }),
- $common->{cancel} ? (gtksignal_connect(new Gtk::Button($common->{cancel}), "clicked" => sub { $w->{retval} = 0; Gtk->main_quit })) : (),
- )
- ));
- gtkpack__($l, my $toolbar = new Gtk::Toolbar('horizontal', 'icons'));
- if ($common->{auto_deps}) {
- gtkpack__($l, gtksignal_connect(gtkset_active(new Gtk::CheckButton($common->{auto_deps}), $common->{state}{auto_deps}), clicked => sub { invbool \$common->{state}{auto_deps} }));
- }
- $l->pack_end($w_size = new Gtk::Label($prev_label = $common->{state}{status_label}), 0, 1, 20);
-
- $w->{window}->set_usize(map { $_ - 2 * $my_gtk::border - 4 } $::windowwidth, $::windowheight);
- $go->grab_focus;
- $w->{rwindow}->show_all;
-
- my $update_size = sub {
- my $new_label = $common->{get_status}();
- $prev_label ne $new_label and $w_size->set($prev_label = $new_label);
- };
-
- my $set_node_state_flat = sub {
- my ($node, $state) = @_;
- unless ($pix{$state}) {
- foreach ("$ENV{SHARE_PATH}/$state.png", "$ENV{SHARE_PATH}/rpm-$state.png") {
- if (-e $_) {
- $pix{$state} = [ gtkcreate_png($_) ];
- last;
- }
- }
- $pix{$state} or die "unable to find a pixmap for state $state";
- }
- $tree->node_set_pixmap($node, 1, $pix{$state}[0], $pix{$state}[1]);
- };
- my $set_node_state_tree; $set_node_state_tree = sub {
- my ($node, $state) = @_;
- unless ($pix{$state}) {
- foreach ("$ENV{SHARE_PATH}/$state.png", "$ENV{SHARE_PATH}/rpm-$state.png") {
- if (-e $_) {
- $pix{$state} = [ gtkcreate_png($_) ];
- last;
- }
- }
- $pix{$state} or die "unable to find a pixmap for state $state";
- }
- if ($node->{state} ne $state) {
- if ($node->row->is_leaf) {
- my $parent = $node->row->parent;
- my $stats = $parent->{state_stats} ||= {}; --$stats->{$node->{state}}; ++$stats->{$state};
- my @list = grep { $stats->{$_} > 0 } keys %$stats;
- my $new_state = @list == 1 ? $list[0] : 'semiselected';
- $parent->{state} ne $new_state and $set_node_state_tree->($parent, $new_state);
- }
- $tree->node_set_pixmap($node, 1, $pix{$state}[0], $pix{$state}[1]);
- $node->{state} = $state; #- hack to to get this features efficiently.
- }
- };
- my $set_node_state = $common->{state}{flat} ? $set_node_state_flat : $set_node_state_tree;
-
- my $set_leaf_state = sub {
- my ($leaf, $state) = @_;
- $set_node_state->($_, $state) foreach @{$ptree{$leaf}};
- };
- my $add_parent; $add_parent = sub {
- my ($root, $state) = @_;
- $root or return undef;
- if (my $w = $wtree{$root}) { return $w }
- my $s; foreach (split '\|', $root) {
- my $s2 = $s ? "$s|$_" : $_;
- $wtree{$s2} ||= do {
- my $n = $tree->insert_node($s ? $add_parent->($s, $state) : undef, undef, [$_, '', ''], 5, (undef) x 4, 0, 0);
- $n;
- };
- $s = $s2;
- }
- $set_node_state->($wtree{$s}, $state); #- use this state by default as tree is building.
- $wtree{$s};
- };
- my $add_node = sub {
- my ($leaf, $root) = @_;
- my $state = $common->{node_state}($leaf) or return;
- my $node = $tree->insert_node($add_parent->($root, $state), undef, [$leaf, '', ''], 5, (undef) x 4, 1, 0);
- $set_node_state->($node, $state);
- push @{$ptree{$leaf}}, $node;
- };
- my $add_nodes = sub {
- foreach (values %ptree) {
- delete $_->{state} foreach @$_;
- }
- foreach (values %wtree) {
- delete $_->{state};
- delete $_->{state_stats};
- }
- %ptree = %wtree = ();
-
- $tree->freeze;
- while (1) { $tree->remove_node($tree->node_nth(0) || last) }
-
- $common->{state}{flat} = $_[0];
- $set_node_state = $common->{state}{flat} ? $set_node_state_flat : $set_node_state_tree;
- $common->{build_tree}($add_node, $common->{state}{flat});
-
- $tree->thaw;
- &$update_size;
- };
- $add_nodes->($common->{state}{flat});
-
- my @toolbar = (ftout => [ _("Expand Tree") , sub { $tree->expand_recursive(undef) } ],
- ftin => [ _("Collapse Tree") , sub { $tree->collapse_recursive(undef) } ],
- reload => [ _("Toggle between flat and group sorted"), sub { $add_nodes->(!$common->{state}{flat}) } ]);
- foreach my $ic (@{$common->{icons} || []}) {
- push @toolbar, ( $ic->{icon} => [ $ic->{help}, sub {
- if ($ic->{code}) {
- my $w = $ic->{wait_message} && $o->wait_message('', $ic->{wait_message});
- $ic->{code}();
- $add_nodes->($common->{state}{flat});
- }
- } ]);
- }
- my %toolbar = @toolbar;
- $toolbar->set_button_relief("none");
- foreach (grep_index { $::i % 2 == 0 } @toolbar) {
- gtksignal_connect($toolbar->append_item(undef, $toolbar{$_}[0], undef, gtkpng("$ENV{SHARE_PATH}/$_.png")),
- clicked => $toolbar{$_}[1]);
- }
- $toolbar->set_style("icons");
-
- my $display_info = sub { gtktext_insert($info_widget, $common->{get_info}($curr)); 0 };
- my $children = sub { map { ($tree->node_get_pixtext($_, 0))[0] } gtkctree_children($_[0]) };
- my $toggle = sub {
- if (ref $curr && ! $_[0]) {
- $tree->toggle_expansion($curr);
- } else {
- if (ref $curr) {
- my @l = $common->{grep_allowed_to_toggle}($children->($curr)) or return;
- my @unsel = $common->{grep_unselected}(@l);
- my @p = @unsel ?
- @unsel : # not all is selected, select all
- @l;
- $common->{toggle_nodes}($set_leaf_state, @p);
- &$update_size;
- $parent = $curr;
- } else {
- $common->{check_interactive_to_toggle}($curr) and $common->{toggle_nodes}($set_leaf_state, $curr);
- &$update_size;
- }
- }
- };
-
- $tree->signal_connect(key_press_event => sub {
- my ($w, $e) = @_;
- my $c = chr($e->{keyval} & 0xff);
- $toggle->(0) if $e->{keyval} >= 0x100 ? $c eq "\r" || $c eq "\x8d" : $c eq ' ';
- 1;
- });
- $tree->signal_connect(tree_select_row => sub {
- Gtk->timeout_remove($idle) if $idle;
-
- if ($_[1]->row->is_leaf) {
- ($curr) = $tree->node_get_pixtext($_[1], 0);
- $parent = $_[1]->row->parent;
- $idle = Gtk->timeout_add(100, $display_info);
- } else {
- $curr = $_[1];
- }
- $toggle->(1) if $_[2] == 1;
- });
- &$update_size;
- my $b = before_leaving { #- ensure cleaning here.
- foreach (values %ptree) {
- delete $_->{state} foreach @$_;
- }
- foreach (values %wtree) {
- delete $_->{state};
- delete $_->{state_stats};
- }
- };
- $w->main;
+ add2hash($common, { wait_message => sub { $o->wait_message(@_) } });
+ my_gtk::ask_browse_tree_info($common);
}
sub wait_messageW($$$) {
diff --git a/perl-install/my_gtk.pm b/perl-install/my_gtk.pm
index 888d7b8dd..b9f7ecbe9 100644
--- a/perl-install/my_gtk.pm
+++ b/perl-install/my_gtk.pm
@@ -1081,6 +1081,212 @@ sub _ask_file {
$f->hide_fileop_buttons;
}
+sub ask_browse_tree_info {
+ my ($common) = @_;
+
+ my $w = my_gtk->new($common->{title});
+ my $tree = Gtk::CTree->new(3, 0);
+ $tree->set_selection_mode('browse');
+ $tree->set_column_auto_resize($_, 1) foreach 1..2;
+ $tree->set_column_width(0, 200);
+
+ gtkadd($w->{window},
+ gtkpack_(new Gtk::VBox(0,5),
+ 0, $common->{message},
+ 1, gtkpack(new Gtk::HBox(0,0),
+ createScrolledWindow($tree),
+ gtkadd(gtkset_usize(new Gtk::Frame(_("Info")), $::windowwidth - 490, 0),
+ createScrolledWindow(my $info = new Gtk::Text),
+ )),
+ 0, my $l = new Gtk::HBox(0,15),
+ 0, gtkpack(new Gtk::HBox(0,10),
+ my $go = gtksignal_connect(new Gtk::Button($common->{ok}), "clicked" => sub { $w->{retval} = 1; Gtk->main_quit }),
+ $common->{cancel} ? (gtksignal_connect(new Gtk::Button($common->{cancel}), "clicked" => sub { $w->{retval} = 0; Gtk->main_quit })) : (),
+ )
+ ));
+ gtkpack__($l, my $toolbar = new Gtk::Toolbar('horizontal', 'icons'));
+
+ if ($common->{auto_deps}) {
+ gtkpack__($l, gtksignal_connect(gtkset_active(new Gtk::CheckButton($common->{auto_deps}), $common->{state}{auto_deps}),
+ clicked => sub { invbool \$common->{state}{auto_deps} }));
+ }
+ $l->pack_end(my $status = new Gtk::Label, 0, 1, 20);
+
+ $w->{window}->set_usize(map { $_ - 2 * $my_gtk::border - 4 } $::windowwidth, $::windowheight);
+ $go->grab_focus;
+ $w->{rwindow}->show_all;
+
+ my @toolbar = (ftout => [ _("Expand Tree") , sub { $tree->expand_recursive(undef) } ],
+ ftin => [ _("Collapse Tree") , sub { $tree->collapse_recursive(undef) } ],
+ reload => [ _("Toggle between flat and group sorted"), sub { invbool(\$common->{state}{flat}); $common->{rebuild_tree}->() } ]);
+ foreach my $ic (@{$common->{icons} || []}) {
+ push @toolbar, ( $ic->{icon} => [ $ic->{help}, sub {
+ if ($ic->{code}) {
+ my $w = $ic->{wait_message} && $common->{wait_message}->('', $ic->{wait_message});
+ $ic->{code}();
+ $common->{rebuild_tree}->();
+ }
+ } ]);
+ }
+ my %toolbar = @toolbar;
+ $toolbar->set_button_relief("none");
+ foreach (grep_index { $::i % 2 == 0 } @toolbar) {
+ gtksignal_connect($toolbar->append_item(undef, $toolbar{$_}[0], undef, gtkpng("$ENV{SHARE_PATH}/$_.png")),
+ clicked => $toolbar{$_}[1]);
+ }
+ $toolbar->set_style("icons");
+
+ my $widgets = { w => $w, tree => $tree, info => $info, status => $status};
+ ask_browse_tree_info_given_widgets($common, $widgets);
+}
+
+sub ask_browse_tree_info_given_widgets {
+ my ($common, $w) = @_;
+ my ($curr, $parent, $prev_label, $idle);
+ my (%wtree, %ptree, %pix);
+ my $update_size = sub {
+ my $new_label = $common->{get_status}();
+ $prev_label ne $new_label and $w->{status}->set($prev_label = $new_label);
+ };
+
+ my $set_node_state_flat = sub {
+ my ($node, $state) = @_;
+ unless ($pix{$state}) {
+ foreach ("$ENV{SHARE_PATH}/$state.png", "$ENV{SHARE_PATH}/rpm-$state.png") {
+ if (-e $_) {
+ $pix{$state} = [ gtkcreate_png($_) ];
+ last;
+ }
+ }
+ $pix{$state} or die "unable to find a pixmap for state $state";
+ }
+ $w->{tree}->node_set_pixmap($node, 1, $pix{$state}[0], $pix{$state}[1]);
+ };
+ my $set_node_state_tree; $set_node_state_tree = sub {
+ my ($node, $state) = @_;
+ unless ($pix{$state}) {
+ foreach ("$ENV{SHARE_PATH}/$state.png", "$ENV{SHARE_PATH}/rpm-$state.png") {
+ if (-e $_) {
+ $pix{$state} = [ gtkcreate_png($_) ];
+ last;
+ }
+ }
+ $pix{$state} or die "unable to find a pixmap for state $state";
+ }
+ if ($node->{state} ne $state) {
+ if ($node->row->is_leaf) {
+ my $parent = $node->row->parent;
+ my $stats = $parent->{state_stats} ||= {}; --$stats->{$node->{state}}; ++$stats->{$state};
+ my @list = grep { $stats->{$_} > 0 } keys %$stats;
+ my $new_state = @list == 1 ? $list[0] : 'semiselected';
+ $parent->{state} ne $new_state and $set_node_state_tree->($parent, $new_state);
+ }
+ $w->{tree}->node_set_pixmap($node, 1, $pix{$state}[0], $pix{$state}[1]);
+ $node->{state} = $state; #- hack to to get this features efficiently.
+ }
+ };
+ my $set_node_state = $common->{state}{flat} ? $set_node_state_flat : $set_node_state_tree;
+
+ my $set_leaf_state = sub {
+ my ($leaf, $state) = @_;
+ $set_node_state->($_, $state) foreach @{$ptree{$leaf}};
+ };
+ my $add_parent; $add_parent = sub {
+ my ($root, $state) = @_;
+ $root or return undef;
+ if (my $w = $wtree{$root}) { return $w }
+ my $s; foreach (split '\|', $root) {
+ my $s2 = $s ? "$s|$_" : $_;
+ $wtree{$s2} ||= do {
+ my $n = $w->{tree}->insert_node($s ? $add_parent->($s, $state) : undef, undef, [$_, '', ''], 5, (undef) x 4, 0, 0);
+ $n;
+ };
+ $s = $s2;
+ }
+ $set_node_state->($wtree{$s}, $state); #- use this state by default as tree is building.
+ $wtree{$s};
+ };
+ my $add_node = sub {
+ my ($leaf, $root) = @_;
+ my $state = $common->{node_state}($leaf) or return;
+ my $node = $w->{tree}->insert_node($add_parent->($root, $state), undef, [$leaf, '', ''], 5, (undef) x 4, 1, 0);
+ $set_node_state->($node, $state);
+ push @{$ptree{$leaf}}, $node;
+ };
+ $common->{rebuild_tree} = sub {
+ foreach (values %ptree) {
+ delete $_->{state} foreach @$_;
+ }
+ foreach (values %wtree) {
+ delete $_->{state};
+ delete $_->{state_stats};
+ }
+ %ptree = %wtree = ();
+
+ $w->{tree}->freeze;
+ while (1) { $w->{tree}->remove_node($w->{tree}->node_nth(0) || last) }
+
+ $set_node_state = $common->{state}{flat} ? $set_node_state_flat : $set_node_state_tree;
+ $common->{build_tree}($add_node, $common->{state}{flat}, $common->{tree_mode});
+
+ $w->{tree}->thaw;
+ &$update_size;
+ };
+ $common->{rebuild_tree}->();
+
+ my $display_info = sub { gtktext_insert($w->{info}, $common->{get_info}($curr)); 0 };
+ my $children = sub { map { ($w->{tree}->node_get_pixtext($_, 0))[0] } gtkctree_children($_[0]) };
+ my $toggle = sub {
+ if (ref $curr && ! $_[0]) {
+ $w->{tree}->toggle_expansion($curr);
+ } else {
+ if (ref $curr) {
+ my @l = $common->{grep_allowed_to_toggle}($children->($curr)) or return;
+ my @unsel = $common->{grep_unselected}(@l);
+ my @p = @unsel ?
+ @unsel : # not all is selected, select all
+ @l;
+ $common->{toggle_nodes}($set_leaf_state, @p);
+ &$update_size;
+ $parent = $curr;
+ } else {
+ $common->{check_interactive_to_toggle}($curr) and $common->{toggle_nodes}($set_leaf_state, $curr);
+ &$update_size;
+ }
+ }
+ };
+
+ $w->{tree}->signal_connect(key_press_event => sub {
+ my ($w, $e) = @_;
+ my $c = chr($e->{keyval} & 0xff);
+ $toggle->(0) if $e->{keyval} >= 0x100 ? $c eq "\r" || $c eq "\x8d" : $c eq ' ';
+ 1;
+ });
+ $w->{tree}->signal_connect(tree_select_row => sub {
+ Gtk->timeout_remove($idle) if $idle;
+
+ if ($_[1]->row->is_leaf) {
+ ($curr) = $w->{tree}->node_get_pixtext($_[1], 0);
+ $parent = $_[1]->row->parent;
+ $idle = Gtk->timeout_add(100, $display_info);
+ } else {
+ $curr = $_[1];
+ }
+ $toggle->(1) if $_[2] == 1;
+ });
+ &$update_size;
+ my $b = before_leaving { #- ensure cleaning here.
+ foreach (values %ptree) {
+ delete $_->{state} foreach @$_;
+ }
+ foreach (values %wtree) {
+ delete $_->{state};
+ delete $_->{state_stats};
+ }
+ };
+ $w->{w}->main;
+}
+
1;
#-###############################################################################
/a> 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003
package authentication; # $Id: authentication.pm 269894 2010-06-05 20:50:23Z tv $

use common;

my ($authentication) = @_;

sub kinds { 
    my $no_para = @_ == 0;
    my ($do_pkgs, $_meta_class) = @_;
    my $allow_SmartCard = $no_para || $do_pkgs->is_available('castella-pam');
    (
	'LDAP',
	'KRB5',
	'winbind', 
	'NIS', 
	if_($allow_SmartCard, 'SmartCard'), 
	'local',
    );
}

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"), 
    KRB5 => N("Kerberos 5") }}{$kind};
}

my %kind2pam_kind = (
    local     => [],
    SmartCard => ['castella'],
    LDAP      => ['ldap'], 
    NIS       => [],
    KRB5        => ['krb5'],
    winbind   => ['winbind'], 
);

my %kind2nsswitch = (
    local     => [],
    SmartCard => [],
    LDAP      => ['ldap'], 
    NIS       => ['nis'],
    KRB5        => ['ldap'],
    winbind   => ['winbind'], 
);

my $lib = (arch() =~ /x86_64/ ? 'lib64' : 'lib');

my %kind2packages = (
    local     => [],
    SmartCard => [ 'castella-pam' ],
    LDAP      => [ 'openldap-clients', 'nss_ldap', 'pam_ldap', 'autofs', 'nss_updatedb' ],
    KRB5       => [ 'nss_ldap', 'pam_krb5', "${lib}sasl2-plug-gssapi", 'nss_updatedb' ],
    NIS       => [ 'ypbind', 'autofs' ],
    winbind   => [ 'samba-winbind', 'nss_ldap', 'pam_krb5', "${lib}sasl2-plug-gssapi" ],
);


sub kind2description_raw {
    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."), ],
	KRB5        => [ N("Kerberos 5 :"), N("With Kerberos and LDAP for authentication in Active Directory Server "), ],
    );
    join('', map { $_ ? qq($_->[0]\n$_->[1]) : '' } map { $kind2description{$_} } @kinds);
}

sub kind2description {
    my (@kinds) = @_;
    join('', map { $_ ? qq($_\n\n) : '' } map { kind2description_raw($_) } @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, $net, $authentication, $kind) = @_;

    #- keep only this authentication kind
    foreach (kinds()) {
	delete $authentication->{$_} if $_ ne $kind;
    }
    # do not enable ccreds unless required
    undef $authentication->{ccreds};

    if ($kind eq 'LDAP') {
	$authentication->{LDAPDOMAIN} ||= domain_to_ldap_domain($net->{resolv}{DOMAINNAME});
	#$authentication->{anonymous} = "0";
	#$authentication->{cafile} = "0";
	#$authentication->{nssgrp} = "0";
	$authentication->{ccreds} = 1;

    # this package must be installed for 'Fetch DN' button to actually work
    $in->do_pkgs->ensure_are_installed([ 'openldap-clients' ], 1) or return;
    
	$in->ask_from('', N(" "),
		     [ { label => N("Welcome to the Authentication Wizard"), title => 1 },
                     {},
                     { label => N("You have selected LDAP authentication. Please review the configuration options below "), },
                     {},
		     { label => N("LDAP Server"), val => \$authentication->{LDAP_server} },
		     { label => N("Base dn"), val => \$authentication->{LDAPDOMAIN} },
                     { val => N("Fetch base Dn "), type  => button , clicked_may_quit => sub { $authentication->{LDAPDOMAIN} = fetch_dn($authentication->{LDAP_server}); 0 } },
		     {},
		     { text => N("Use encrypt connection with TLS "), val => \$authentication->{cafile}, type => 'bool' },
                     { val => N("Download CA Certificate "), type  => button , disabled => sub { !$authentication->{cafile} }, clicked_may_quit => sub { $authentication->{file} = add_cafile(); 0 }  },
		     
		     { text => N("Use Disconnect mode "), val => \$authentication->{ccreds}, type => 'bool' },
		     { text => N("Use anonymous BIND "), val => \$authentication->{anonymous}, type => 'bool' , advanced => 1 },
		     { text => N("  "), advanced => 1 },
                     { label => N("Bind DN "), val => \$authentication->{LDAP_binddn}, disabled => sub { !$authentication->{anonymous} }, advanced => 1  },
                     { label => N("Bind Password "), val => \$authentication->{LDAP_bindpwd}, disabled => sub { !$authentication->{anonymous} }, advanced => 1 },
		     { text => N("  "), advanced => 1 },
		     { text => N("Advanced path for group "), val => \$authentication->{nssgrp}, type => 'bool' , advanced => 1 },
		     { text => N("  "), advanced => 1 },
                     { label => N("Password base"), val => \$authentication->{nss_pwd},  disabled => sub { !$authentication->{nssgrp} }, advanced => 1 },
                     { label => N("Group base"), val => \$authentication->{nss_grp},  disabled => sub { !$authentication->{nssgrp} }, advanced => 1 },
                     { label => N("Shadow base"), val => \$authentication->{nss_shadow},  disabled => sub { !$authentication->{nssgrp} }, advanced => 1 },
		     { text => N("  "), advanced => 1 },
		     ]) or return;
    } elsif ($kind eq 'KRB5') {
	
	$authentication->{AD_domain} ||= $net->{resolv}{DOMAINNAME};
	$in->do_pkgs->ensure_are_installed([ 'perl-Net-DNS' ], 1) or return;
	my @srvs = query_srv_names($authentication->{AD_domain}); #FIXME: update this list if the REALM has changed
	$authentication->{AD_server} ||= $srvs[0] if @srvs;
	my $AD_user = $authentication->{AD_user} =~ /(.*)\@\Q$authentication->{AD_domain}\E$/ ? $1 : $authentication->{AD_user};
	$authentication->{ccreds} = 1;

	$in->ask_from('', N(" "),
                        [ { label => N("Welcome to the Authentication Wizard"), title => 1 },
                        {},
                        { label => N("You have selected Kerberos 5 authentication. Please review the configuration options below "), },
                        {},
		       { label => N("Realm "),  val => \$authentication->{AD_domain} },
                       {},
		       { label => N("KDCs Servers"), title => 1, val => \$authentication->{AD_server} , list => \@srvs , not_edit => 0,  title => 1 },
                       {},
		       { text => N("Use DNS to locate KDC for the realm"), val => \$authentication->{KRB_host_lookup}, type => 'bool' },
		       { text => N("Use DNS to locate realms"), val => \$authentication->{KRB_dns_lookup}, type => 'bool' },
		       { text => N("Use Disconnect mode "), val => \$authentication->{ccreds}, type => 'bool' },
		     ]) or return;

my %level = (
             1 => N("Use local file for users information"),
             2 => N("Use LDAP for users information"),
            );

 $in->ask_from('', N(" "),
                        [ { label => N(" "), title => 1 },
                        {},
                        { label => N("You have selected Kerberos 5 for authentication, now you must choose the type of users information "), },
                        {},
			{ label => "" , val => \$authentication->{nsskrb}, type => 'list', list => [ keys %level ], format => sub { $level{$_[0]} } },
			{},	
			{ label => N("LDAP Server"), val => \$authentication->{LDAP_server}, disabled => sub { $authentication->{nsskrb} eq "1"  } },
                     	{ label => N("Base dn"), val => \$authentication->{LDAPDOMAIN} , disabled => sub { $authentication->{nsskrb} eq "1"  } },
                     	{ val => N("Fecth base Dn "), type  => button , clicked_may_quit => sub { $authentication->{LDAPDOMAIN} = fetch_dn($authentication->{LDAP_server}); 0 }, disabled => sub { $authentication->{nsskrb} eq "1"  } },
			{},
                     	{ text => N("Use encrypt connection with TLS "), val => \$authentication->{cafile}, type => 'bool',, disabled => sub { $authentication->{nsskrb} eq "1"  } },
                     	{ val => N("Download CA Certificate "), type  => button , disabled => sub { !$authentication->{cafile} }, clicked_may_quit => sub { $authentication->{file} = add_cafile(); 0 }  },
                     	{ text => N("Use anonymous BIND "), val => \$authentication->{anonymous}, type => 'bool', disabled => sub { $authentication->{nsskrb} eq "1"  } },
                     	{ label => N("Bind DN "), val => \$authentication->{LDAP_binddn}, disabled => sub { !$authentication->{anonymous} } },
                     	{ label => N("Bind Password "), val => \$authentication->{LDAP_bindpwd}, disabled => sub { !$authentication->{anonymous} } },
                     	{},
			]) 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';
	$net->{network}{NISDOMAIN} ||= $net->{resolv}{DOMAINNAME};
	$in->ask_from('', N(" "),
		[ { label => N("Welcome to the Authentication Wizard"), title => 1 },
		{},
		{ label => N("You have selected NIS authentication. Please review the configuration options below "), },
		{},
		{ label => N("NIS Domain"), val => \$net->{network}{NISDOMAIN} },
		{ label => N("NIS Server"), val => \$authentication->{NIS_server}, list => ["broadcast"], not_edit => 0 },
		{},
		     ]) or return;
    } elsif ($kind eq 'winbind') {
	#- 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
	#
	my @sec_domain = (
		"Windows Active Directory Domain",
		"Windows NT4 Domain",
);


	$authentication->{DNS_domain} ||= $net->{resolv}{DOMAINNAME};
	$authentication->{WINDOMAIN} ||= $net->{resolv}{DOMAINNAME};
	$in->do_pkgs->ensure_are_installed([ 'samba-client' ], 1) or return;
	my @domains=list_domains();

	$in->ask_from('', N(" "),
			[ { label => N("Welcome to the Authentication Wizard"), title => 1 },
			{},
			{ label => N("You have selected Windows Domain authentication. Please review the configuration options below "), },
		        {},
			{ label => N("Windows Domain"), val => \$authentication->{WINDOMAIN}, list => \@domains, not_edit => 1 },
		        {},
		        { label => N("Domain Model "), val => \$authentication->{model}, list => \@sec_domain , not_edit => 1 },
		        {},
			{ label => N("Active Directory Realm "), val => \$authentication->{AD_domain} , disabled => sub { $authentication->{model} eq "Windows NT4 Domain"  } },
			{ label => N("DNS Domain"), val => \$authentication->{DNS_domain} , disabled => sub { $authentication->{model} eq "Windows NT4 Domain"  } },
			{ label => N("DC Server"), val => \$authentication->{AD_server} , disabled => sub { $authentication->{model} eq "Windows NT4 Domain"  } },
		        {},
			]) or return;
    }
    $authentication->{$kind} ||= 1;
    1;
}
sub ask_root_password_and_authentication {
    my ($in, $net, $superuser, $authentication, $meta_class, $security) = @_;

    my $kind = to_kind($authentication);
    my @kinds = kinds($in->do_pkgs, $meta_class);

    $in->ask_from_({
	 title => N("Authentication"),