summaryrefslogtreecommitdiffstats
path: root/samba_wizard
diff options
context:
space:
mode:
authorFlorent Villard <warly@mandriva.com>2003-12-11 11:14:11 +0000
committerFlorent Villard <warly@mandriva.com>2003-12-11 11:14:11 +0000
commit6f199b631eda1a4f7e3957d807b3bc2278cdd6e4 (patch)
tree02e76712d4758432a72a4330cea5b538c2ad5741 /samba_wizard
parentba17e692c5065c129b49045dbd3bc957477e6476 (diff)
downloaddrakwizard-2_8_1mdk.tar
drakwizard-2_8_1mdk.tar.gz
drakwizard-2_8_1mdk.tar.bz2
drakwizard-2_8_1mdk.tar.xz
drakwizard-2_8_1mdk.zip
2.8, samba wizards fixesV2_8_1mdk
Diffstat (limited to 'samba_wizard')
-rwxr-xr-xsamba_wizard/Samba.pm45
1 files changed, 32 insertions, 13 deletions
diff --git a/samba_wizard/Samba.pm b/samba_wizard/Samba.pm
index d2b72c42..68d4144a 100755
--- a/samba_wizard/Samba.pm
+++ b/samba_wizard/Samba.pm
@@ -28,6 +28,7 @@ use services;
use MDK::Wizard::Wizcommon;
my $wiz = new MDK::Wizard::Wizcommon;
+my $old;
my $o = {
name => N("Samba wizard"),
@@ -49,10 +50,16 @@ my $o = {
list_printers => ''
},
needed_rpm => [ 'samba-server' ],
- defaultimage => "$ENV{__WIZ_HOME__}samba_wizard/images/samba.png"
- };
-
-my $old = read_conf("/etc/samba/smb.conf");
+ defaultimage => "/usr/share/wizards/samba_wizard/images/samba.png",
+ init => sub {
+ my $file = "/etc/samba/smb.conf";
+ if (-f $file) {
+ $old = read_conf($file);
+ } else {
+ return (0, N("%s does not exist.", $file))
+ }
+ }
+};
my %level = (
1 => N("All - No access restriction"),
@@ -100,7 +107,7 @@ $o->{pages} = {
ask_net => {
name => N("Access control") . "\n\n" . "\n\n",
pre => sub {
- $o->{var}{wiz_level} ||= 1
+ $o->{var}{wiz_level} ||= defined $old->{conf}{global}{'hosts allow'} ? 2 : 1
},
post => sub { return 'ask_netmask' if $o->{var}{wiz_level} == 2 },
data => [
@@ -112,12 +119,12 @@ $o->{pages} = {
name => N("Access control") . "\n\n" . N("* Example 1: allow all IPs in 150.203.*.*; except one\nhosts allow = 150.203. EXCEPT 150.203.6.66") . "\n\n" . N("* Example 2: allow hosts that match the given network/netmask\nhosts allow = 150.203.15.0/255.255.255.0") . "\n\n" . N("* Example 3: allow a couple of hosts\nhosts allow = lapland, arvidsjaur") . "\n\n" . N("* Example 4: allow only hosts in NIS netgroup \"foonet\", but deny access from one particular host\nhosts allow = \@foonet\nhosts deny = pirate") . "\n\n" . N("Note that access still requires suitable user-level passwords."),
pre => sub {
$o->{var}{wiz_hosts_allow} ||= get_allow_host();
- $o->{var}{wiz_hosts_allow} ||= get_deny_host()
+ $o->{var}{wiz_hosts_deny} ||= get_deny_host()
},
post => \&check,
data => [
- { label => N("Allow hosts:"), val => \$o->{var}{wiz_allow_host} },
- { label => N("Deny hosts:"), val => \$o->{var}{wiz_deny_host} },
+ { label => N("Allow hosts:"), val => \$o->{var}{wiz_hosts_allow} },
+ { label => N("Deny hosts:"), val => \$o->{var}{wiz_hosts_deny} },
],
next => 'ask_services'
},
@@ -175,7 +182,7 @@ $o->{pages} = {
name => N("Select which printers you want to be accessible from known users"),
pre => sub {
$o->{var}{list_printers} ||= [ list_printers() ];
- $o->{var}{wiz_box_list} ||= []
+ $o->{var}{wiz_box_list} ||= get_previous_printers($o->{var}{list_printers})
},
post => \&check,
data => [
@@ -248,7 +255,7 @@ sub check_dir {
}
# the "__" before comment is to avoid conflicts with possible "comment" variable
-# for variables value is in value key and comment idem (no risque of conflict)
+# for variables value is in value key and comment idem (no risk of conflict)
sub read_conf {
my $self = {};
@@ -260,10 +267,12 @@ sub read_conf {
if (/^(\s*;?\s*)\[(.*)\]/) {
$menu = $2;
$conf{$menu}{__comment} = $1;
+ print "$menu COMMENT $1\n";
}
elsif (/^(?!#)(\s*;*\s*)(.*?)\s*=\s*(.*)\s*$/) {
$conf{$menu}{$2}{value} = $3;
$conf{$menu}{$2}{comment} = $1;
+ print "$menu $2 VALUE $3 COMMENT $1\n";
}
push @tab, $_;
}
@@ -374,6 +383,16 @@ sub printer_sharing {
}
}
+sub get_previous_printers {
+ my ($list_printers) = @_;
+ my $previous = [];
+ foreach my $p (grep { defined $old->{conf}{$_}{printer} } keys %{$old->{conf}}) {
+ my $test = grep { /\Q$p/ } @$list_printers;
+ push @$previous, $test
+ }
+ $previous
+}
+
sub get_printers {
if ($o->{var}{wiz_do_printer_sharing}) {
my $string;
@@ -450,7 +469,7 @@ sub get_deny_host {
# remember one variable cannot be commented and not in the same file.
sub do_it {
$::testing and return;
- my $file = "__WIZ_HOME__/samba_wizard/scripts/smb.conf.default";
+ my $file = "/usr/share/wizards//samba_wizard/scripts/smb.conf.default";
my $conf = read_conf($file);
$conf->chg_var("global", "workgroup", $o->{var}{wiz_workgroup});
@@ -477,8 +496,8 @@ sub do_it {
}
standalone->explanations("Samba deny $o->{var}{wiz_hosts_deny}");
standalone->explanations("Samba allow $o->{var}{wiz_hosts_allow}");
-# $conf->chg_var("global", "hosts deny", $o->{var}{wiz_hosts_deny});
-# $conf->chg_var("global", "hosts allow", $o->{var}{wiz_hosts_allow});
+ $conf->chg_var("global", "hosts deny", $o->{var}{wiz_hosts_deny});
+ $conf->chg_var("global", "hosts allow", $o->{var}{wiz_hosts_allow});
if ($o->{var}{wiz_do_printer_sharing}) {
standalone->explanations("Enabling printer sharing");