summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drakwizard.spec5
-rwxr-xr-xsamba_wizard/Samba.pm45
2 files changed, 36 insertions, 14 deletions
diff --git a/drakwizard.spec b/drakwizard.spec
index 82cbd6cd..74403d82 100644
--- a/drakwizard.spec
+++ b/drakwizard.spec
@@ -1,5 +1,5 @@
%define name drakwizard
-%define version 2.7
+%define version 2.8
%define release 1mdk
Name: %{name}
@@ -49,6 +49,9 @@ rm -rf $RPM_BUILD_DIR/$RPM_PACKAGE_NAME
%{perl_vendorlib}/MDK/
%changelog
+* Tue Dec 09 2003 Warly <warly@mandrakesoft.com> 2.8-1mdk
+- fix samba wizard reading of old conf (printers and denied and allowed hosts)
+
* Mon Nov 17 2003 Thierry Vignaud <tvignaud@mandrakesoft.com> 2.7-1mdk
- fix a few remaining i18n/l10n issues (also know as the infamous
xgettext vs perl escaped strings fight)
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");