summaryrefslogtreecommitdiffstats
path: root/samba_wizard
diff options
context:
space:
mode:
Diffstat (limited to 'samba_wizard')
-rw-r--r--samba_wizard/samba.wiz345
-rwxr-xr-xsamba_wizard/scripts/Smbconf.pm137
2 files changed, 306 insertions, 176 deletions
diff --git a/samba_wizard/samba.wiz b/samba_wizard/samba.wiz
index 00c075c2..e715a8df 100644
--- a/samba_wizard/samba.wiz
+++ b/samba_wizard/samba.wiz
@@ -19,7 +19,12 @@
name="doFileSharing"
comment="true if we do file sharing, false otherwise"
shellVariable="wiz_do_file_sharing"
- >
+ >
+ </Variable>
+ <Variable
+ name="wiz_samba_net"
+ shellVariable="wiz_samba_net"
+ >
</Variable>
<Variable
name="all_printers"
@@ -27,6 +32,11 @@
>
</Variable>
<Variable
+ name="wiz_printers"
+ shellVariable="wiz_printers"
+ >
+ </Variable>
+ <Variable
name="doPrinterSharing"
comment="true if samba do printer sharing"
shellVariable="wiz_do_printer_sharing"
@@ -104,6 +114,156 @@
<Page
helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-samba.html"
+ name="ask_workgroup"
+ func="check_workgroup"
+ executionLevel="NORMAL"
+ nextFinish="false"
+ canBack="true"
+ canCancel="true"
+ >
+
+ <Target
+ targetName="error_in_workgroup"
+ jumpIndex="1"
+ >
+ </Target>
+
+ <Target
+ targetName="ask_banner"
+ jumpIndex="10"
+ >
+ </Target>
+
+ <Info
+ helpText="Workgroup"
+ >
+ </Info>
+
+
+ <Info
+ helpText="Samba need to know the Windows Workgroup it will serve."
+ >
+ </Info>
+ <Freetext
+ name="freetext2"
+ variableName="workgroup"
+ helpText="Workgroup:"
+ editable="true"
+ fillfunc="get_workgroup"
+ >
+ </Freetext>
+ </Page>
+
+ <Page
+ helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-samba.html"
+ name="error_in_workgroup"
+ jumpPage="ask_workgroup"
+ nextButtonText="Fix it"
+ executionLevel="NORMAL"
+ nextFinish="false"
+ canBack="true"
+ canCancel="true"
+ >
+ <Info
+ helpText="The Workgroup is wrong"
+ >
+ </Info>
+ </Page>
+
+
+ <Page
+ helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-samba.html"
+ name="ask_banner"
+ func="check_banner"
+ executionLevel="NORMAL"
+ nextFinish="false"
+ canBack="true"
+ canCancel="true"
+ >
+
+ <Target
+ targetName="error_in_banner"
+ jumpIndex="1"
+ >
+ </Target>
+
+ <Target
+ targetName="ask_net"
+ jumpIndex="10"
+ >
+ </Target>
+
+ <Info
+ helpText="Server Banner."
+ >
+ </Info>
+
+
+ <Info
+ helpText="The banner is the way this server will be described in the Windows workstations."
+ >
+ </Info>
+
+
+ <Freetext
+ name="serverBannerInput"
+ variableName="banner"
+ helpText="Banner:"
+ editable="true"
+ fillfunc="get_banner"
+ >
+ </Freetext>
+ </Page>
+
+ <Page
+ helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-samba.html"
+ name="error_in_banner"
+ jumpPage="ask_banner"
+ nextButtonText="Fix It"
+ executionLevel="NORMAL"
+ nextFinish="false"
+ canBack="true"
+ canCancel="true"
+ >
+
+ <Info
+ helpText="The Server Banner is incorrect"
+ >
+ </Info>
+ </Page>
+ <Page
+ name="ask_net"
+ jumpPage="ask_services"
+ executionLevel="NORMAL"
+ nextFinish="false"
+ canBack="true"
+ canCancel="true"
+ >
+ <Info
+ helpText="Access control"
+ >
+ </Info>
+
+ <Chooser
+ name="chooser1"
+ variableName="wiz_samba_net"
+ >
+ <Option
+ value="1"
+ description="All - No access restriction"
+ >
+ </Option>
+
+ <Option
+ value="2"
+ description="Local Network - access for local network (recommended)"
+ >
+ </Option>
+ </Chooser>
+ </Page>
+
+ <Page
+ helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-samba.html"
name="ask_services"
func="check_services"
executionLevel="NORMAL"
@@ -131,7 +291,7 @@
</Target>
<Target
- targetName="ask_workgroup"
+ targetName="doit"
jumpIndex="0"
>
</Target>
@@ -154,6 +314,7 @@
forceEnabled="true"
forceDisabled="false"
helpText="Enable file sharing area"
+ fillfunc="get_file_sharing"
>
</Boolean>
@@ -171,6 +332,7 @@
forceEnabled="true"
forceDisabled="false"
helpText="Make home directories available for their owners"
+ fillfunc="get_home_sharing"
>
</Boolean>
@@ -200,7 +362,7 @@
</Target>
<Target
- targetName="ask_workgroup"
+ targetName="doit"
jumpIndex="0"
>
</Target>
@@ -260,7 +422,7 @@
helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-samba.html"
name="ask_access"
is="doFileSharing"
- func="check_user"
+ func="check_users"
executionLevel="NORMAL"
nextFinish="false"
canBack="true"
@@ -281,7 +443,7 @@
<Target
- targetName="ask_workgroup"
+ targetName="doit"
jumpIndex="0"
>
</Target>
@@ -319,90 +481,30 @@
<Page
helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-samba.html"
name="ask_printers"
- jumpPage="ask_workgroup"
- func="check_printers"
+ jumpPage="doit"
is="doPrinterSharing"
executionLevel="NORMAL"
nextFinish="false"
canBack="true"
canCancel="true"
>
- <Info
- helpText="toto"
- >
- </Info>
- <Boolean
- variableName="all_printers"
- helpText="Enable all printer"
- >
- </Boolean>
- <Boolean
- is="all_printers=0"
- variableName="box_list"
- listfunc="list_printers"
- >
- </Boolean>
- </Page>
-
- <Page
- helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-samba.html"
- name="ask_workgroup"
- func="check_workgroup"
- executionLevel="NORMAL"
- nextFinish="false"
- canBack="true"
- canCancel="true"
- >
-
- <Target
- targetName="error_in_workgroup"
- jumpIndex="1"
- >
- </Target>
-
- <Target
- targetName="ask_banner"
- jumpIndex="10"
- >
- </Target>
-
- <Info
- helpText="Workgroup"
- >
- </Info>
-
-
<Info
- helpText="Samba need to know the Windows Workgroup it will serve."
+ helpText="Select which printers you want to be accessible from known users"
>
</Info>
- <Freetext
- name="freetext2"
- variableName="workgroup"
- helpText="Workgroup:"
- editable="true"
- fillfunc="get_workgroup"
+ <Boolean
+ variableName="all_printers"
+ helpText="Enable all printer"
>
- </Freetext>
- </Page>
-
- <Page
- helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-samba.html"
- name="error_in_workgroup"
- jumpPage="ask_workgroup"
- nextButtonText="Fix it"
- executionLevel="NORMAL"
- nextFinish="false"
- canBack="true"
- canCancel="true"
- >
- <Info
- helpText="The Workgroup is wrong"
+ </Boolean>
+ <Boolean
+ is="all_printers=0"
+ variableName="box_list"
+ listfunc="list_printers"
>
- </Info>
+ </Boolean>
</Page>
-
<Page
helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-samba.html"
name="error_in_dir"
@@ -422,67 +524,6 @@
<Page
helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-samba.html"
- name="ask_banner"
- func="check_banner"
- executionLevel="NORMAL"
- nextFinish="false"
- canBack="true"
- canCancel="true"
- >
-
- <Target
- targetName="error_in_banner"
- jumpIndex="1"
- >
- </Target>
-
- <Target
- targetName="doit"
- jumpIndex="10"
- >
- </Target>
-
- <Info
- helpText="Server Banner."
- >
- </Info>
-
-
- <Info
- helpText="The banner is the way this server will be described in the Windows workstations."
- >
- </Info>
-
-
- <Freetext
- name="serverBannerInput"
- variableName="banner"
- helpText="Banner:"
- editable="true"
- fillfunc="get_banner"
- >
- </Freetext>
- </Page>
-
- <Page
- helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-samba.html"
- name="error_in_banner"
- jumpPage="ask_banner"
- nextButtonText="Fix It"
- executionLevel="NORMAL"
- nextFinish="false"
- canBack="true"
- canCancel="true"
- >
-
- <Info
- helpText="The Server Banner is incorrect"
- >
- </Info>
- </Page>
-
- <Page
- helpURL="file:/usr/share/doc/mandrake/${LANG}/ref.html/wiz-samba.html"
name="doit"
func="do_it"
nextButtonText="Configure"
@@ -517,6 +558,22 @@ needed to configure Samba."
</Info>
<Freetext
+ name="freetext3"
+ variableName="workgroup"
+ helpText="Workgroup:"
+ editable="false"
+ >
+ </Freetext>
+
+ <Freetext
+ name="freetext4"
+ variableName="banner"
+ helpText="Server Banner:"
+ editable="false"
+ >
+ </Freetext>
+
+ <Freetext
name="freetext"
variableName="doFileSharing"
helpText="File Sharing:"
@@ -549,23 +606,15 @@ needed to configure Samba."
>
</Freetext>
- <Freetext
- name="freetext3"
- variableName="workgroup"
- helpText="Workgroup:"
- editable="false"
- >
- </Freetext>
<Freetext
- name="freetext4"
- variableName="banner"
- helpText="Server Banner:"
+ name="freetext5"
+ helpText="Printers:"
editable="false"
+ fillfunc="get_printers"
>
</Freetext>
-
<Info
helpText="To accept these values, and configure your server, click the Next button or use the Back button to correct them."
>
diff --git a/samba_wizard/scripts/Smbconf.pm b/samba_wizard/scripts/Smbconf.pm
index 1466caf0..4f2ab90d 100755
--- a/samba_wizard/scripts/Smbconf.pm
+++ b/samba_wizard/scripts/Smbconf.pm
@@ -4,8 +4,9 @@ package Smbconf;
require "__WIZ_HOME__/common/scripts/Vareqval.pm";
require "__WIZ_HOME__/common/scripts/DrakconnectConf.pm";
use MDK::Common;
-use strict;
+#use strict;
use Data::Dumper;
+
# All possibilies in the config file must be precedeed by ";"
# This script can just comment, uncomment or/and change values
# but can not add anything.
@@ -31,6 +32,9 @@ sub check_dir {
1;
}
+# 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)
+
sub read_conf {
my $self = {};
my ($file) = @_;
@@ -55,6 +59,8 @@ sub read_conf {
bless $self;
}
+# we parse @tab to check for values in the struct.
+
sub write_conf {
my $self = shift;
my ($file) = @_;
@@ -74,7 +80,26 @@ sub write_conf {
}
}
}
-
+
+#section has the name of the printer
+sub add_printer {
+ my $self = shift;
+ my ($printer) = @_;
+
+ if (exists $self->{conf}->{$printer}) {
+ $self->comment_menu($printer, "");
+ }
+ else {
+ $self->{conf}->{$printer}{printable}{comment} = "";
+ $self->{conf}->{$printer}{printer}{comment} = "";
+ push @{$self->{tab}}, "[$printer]\n";
+ push @{$self->{tab}}, "printer = \n";
+ push @{$self->{tab}}, "printable = \n";
+ $self->{conf}->{$printer}{printer}{value} = $printer;
+ $self->{conf}->{$printer}{printable}{value} = "yes";
+ }
+}
+
sub list_printers {
my $file = "/etc/printcap";
my $i;
@@ -95,6 +120,7 @@ sub comment_menu {
my $self = shift;
my ($menu, $str) = @_;
+ return if (!$menu or !exists $self->{conf}->{$menu});
$self->{conf}->{$menu}{__comment} = $str;
foreach (keys %{$self->{conf}->{$menu}}) {
($_ eq "__comment") and next;
@@ -116,24 +142,47 @@ sub chg_var {
$self->{conf}->{$menu}{$var}{value} = $str;
}
-sub file_sharing {
+sub printer_sharing {
my $self = shift;
- standalone->explanations("Enabling $ENV{wiz_dir} samba file sharing");
- $self->comment_menu("public", "");
- $self->chg_var("global", "security", "share");
-}
+ my $printer;
-sub homes {
- my $self = shift;
- standalone->explanations("Enabling samba homes access");
- $self->comment_menu("homes", "");
- $self->chg_var("global", "security", "share");
+ if ($ENV{wiz_all_printers}) {
+ $self->comment_menu("printers", "");
+ foreach $printer (keys (%::bool)) {
+ $self->comment_menu($printer, ";");
+ }
+ }
+ else {
+ $self->comment_menu("printers", ";");
+ foreach $printer (keys (%::bool)) {
+ if (int($::bool{$printer})) {
+ $self->comment_menu($printer, "");
+ $self->add_printer($printer);
+ }
+ else {
+ $self->comment_menu($printer, ";");
+ }
+ }
+ }
}
-sub printer_sharing {
- my $self = shift;
- standalone->explanations("Enabling samba printer sharing");
- $self->comment_menu("printers", "");
+sub get_printers {
+ my $printers;
+
+ if ($ENV{wiz_do_printer_sharing}) {
+ $ENV{wiz_all_printers} and return "all printers";
+ foreach (keys (%::bool)) {
+ $printers .= "$_, " if int($::bool{$_});
+ }
+ $/ = " ";
+ chomp $printers;
+ $/ = ",";
+ chomp $printers;
+ "$printers";
+ }
+ else {
+ "disabled";
+ }
}
sub check_workgroup {
@@ -145,12 +194,6 @@ sub ask_acces {
10;
}
-sub check_printers {
- foreach (keys %::bool) {
- print "$::bool{$_}\n";
- }
-}
-
my $old = read_conf("/etc/samba/smb.conf");
sub get_write {
@@ -183,18 +226,57 @@ sub ask_dir {
sub get_dir {
$old->{conf}->{public}{path}{value};
}
-# remember one variable cannot be commented and not in the same file.
+sub get_file_sharing {
+ return 0 if ($old->{conf}->{public}{__comment} =~ /\;|\#/);
+ 1;
+}
+
+sub get_home_sharing {
+ return 0 if ($old->{conf}->{homes}{__comment} =~ /\;|\#/);
+ 1;
+}
+
+# remember one variable cannot be commented and not in the same file.
sub do_it {
- my $conf = read_conf("__WIZ_HOME__/samba_wizard/scripts/smb.conf.default");
+ my $file = "__WIZ_HOME__/samba_wizard/scripts/smb.conf.default";
+
+ my $conf = read_conf($file);
+ $conf->chg_var("global", "security", "share");
$conf->chg_var("global", "workgroup", $ENV{wiz_workgroup});
$conf->chg_var("global", "server string", $ENV{wiz_banner});
$conf->chg_var("public", "write list", $ENV{wiz_write_list}) if $ENV{wiz_do_file_sharing};
$conf->chg_var("public", "read list", $ENV{wiz_read_list}) if $ENV{wiz_do_file_sharing};
my $ip = $o->get_from_known_dev("IP");
- $conf->file_sharing() if $ENV{wiz_do_file_sharing};
- $conf->printer_sharing() if $ENV{wiz_do_printer_sharing};
- $conf->homes() if $ENV{wiz_do_homes};
+ if ($ENV{wiz_do_printer_sharing}) {
+ standalone->explanations("Enabling printer sharing");
+ $conf->printer_sharing();
+ }
+ else {
+ standalone->explanations("Disabling printer sharing");
+ foreach $printer (keys (%::bool)) {
+ if (!int($::bool{$printer})) {
+ $conf->comment_menu("$printer", ";");
+ }
+ }
+ $conf->comment_menu("printers", ";");
+ }
+ if ($ENV{wiz_do_file_sharing}) {
+ standalone->explanations("Enabling $ENV{wiz_dir} samba file sharing");
+ $conf->comment_menu("public", "");
+ }
+ else {
+ standalone->explanations("Disabling samba file sharing");
+ $conf->comment_menu("public", ";");
+ }
+ if ($ENV{wiz_do_homes}) {
+ standalone->explanations("Enabling samba homes sharing");
+ $conf->comment_menu("homes", " ");
+ }
+ else {
+ standalone->explanations("Disabling samba homes sharing");
+ $conf->comment_menu("homes", ";");
+ }
$conf->chg_var("global", "hosts allow", $ip);
$conf->chg_var("global", "security", "share");
$conf->chg_var("public", "path", $ENV{wiz_dir}) if $ENV{wiz_dir};
@@ -203,4 +285,3 @@ sub do_it {
10;
}
1;
-