summaryrefslogtreecommitdiffstats
path: root/samba_wizard
diff options
context:
space:
mode:
Diffstat (limited to 'samba_wizard')
-rwxr-xr-xsamba_wizard/scripts/Smbconf.pm70
1 files changed, 31 insertions, 39 deletions
diff --git a/samba_wizard/scripts/Smbconf.pm b/samba_wizard/scripts/Smbconf.pm
index ed065f55..1d493c72 100755
--- a/samba_wizard/scripts/Smbconf.pm
+++ b/samba_wizard/scripts/Smbconf.pm
@@ -78,7 +78,6 @@ sub write_conf {
else {
print FH $_;
}
- print "$_\n";
}
}
@@ -86,32 +85,31 @@ sub write_conf {
sub add_printer {
my $self = shift;
my ($printer) = @_;
-
+
if (exists $self->{conf}->{$printer}) {
- $self->comment_menu($printer, "");
+ $self->comment_menu($printer, " ");
}
else {
- $self->{conf}->{$printer}{printable}{comment} = "";
- $self->{conf}->{$printer}{printer}{comment} = "";
+ $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";
+ push @{$self->{tab}}, "printer = $printer\n";
+ push @{$self->{tab}}, "printable = yes\n";
$self->{conf}->{$printer}{printer}{value} = $printer;
$self->{conf}->{$printer}{printable}{value} = "yes";
}
}
sub list_printers {
- my $file = "/etc/printcap";
- my $i;
-
- sort grep /^(?!\#).*/, map {
- my @toto = split(':', $_);
- $i++;
- $toto[0];
- } cat_($file);
+ my @list if 0;
+
+ return @list if @list;
+ @list = sort grep /^(?!\#).*/, map {
+ my ($printer) = split(':', $_);
+ } cat_("/etc/printcap");
}
+
sub check_users {
return 1 if $ENV{wiz_do_printer_sharing};
0;
@@ -149,7 +147,7 @@ sub printer_sharing {
my $printer;
if ($ENV{wiz_all_printers}) {
- $self->comment_menu("printers", "");
+ $self->comment_menu("printers", " ");
foreach $printer (keys (%::bool)) {
$self->comment_menu($printer, ";");
}
@@ -157,8 +155,10 @@ sub printer_sharing {
else {
$self->comment_menu("printers", ";");
foreach $printer (keys (%::bool)) {
+ print "$printer\n";
if (int($::bool{$printer})) {
- $self->comment_menu($printer, "");
+ $self->comment_menu($printer, " ");
+ print "$printer\n";
$self->add_printer($printer);
}
else {
@@ -169,18 +169,14 @@ sub printer_sharing {
}
sub get_printers {
- my $printers;
+ my $string;
if ($ENV{wiz_do_printer_sharing}) {
$ENV{wiz_all_printers} and return "all printers";
foreach (keys (%::bool)) {
- $printers .= "$_, " if int($::bool{$_});
+ $string .= "$_, " if int($::bool{$_});
}
- $/ = " ";
- chomp $printers;
- $/ = ",";
- chomp $printers;
- "$printers";
+ "$string";
}
else {
"disabled";
@@ -276,16 +272,15 @@ sub do_it {
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});
- print "$ENV{wiz_workgroup}\n";
$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");
if ($ENV{wiz_do_file_sharing}) {
standalone->explanations("Enabling $ENV{wiz_dir} samba file sharing");
- $conf->comment_menu("public", "");
+ $conf->comment_menu("public", " ");
+ $conf->chg_var("public", "path", $ENV{wiz_dir});
}
else {
standalone->explanations("Disabling samba file sharing");
@@ -297,29 +292,26 @@ sub do_it {
}
else {
standalone->explanations("Disabling samba homes sharing");
- $conf->comment_menu("homes", ";");
+ $conf->comment_menu("homes", ";");
}
standalone->explanations("Samba deny $ENV{wiz_hosts_deny}");
standalone->explanations("Samba allow $ENV{wiz_hosts_allow}");
- $conf->chg_var("global", "hosts deny", $ENV{wiz_hosts_deny});
- $conf->comment_var("global", "hosts deny", "");
- $conf->chg_var("global", "hosts allow", $ENV{wiz_hosts_allow});
- $conf->comment_var("global", "hosts allow", "");
- $conf->chg_var("global", "security", "share");
- $conf->chg_var("public", "path", $ENV{wiz_dir}) if $ENV{wiz_dir};
+# $conf->chg_var("global", "hosts deny", $ENV{wiz_hosts_deny});
+# $conf->chg_var("global", "hosts allow", $ENV{wiz_hosts_allow});
+
if ($ENV{wiz_do_printer_sharing}) {
standalone->explanations("Enabling printer sharing");
$conf->printer_sharing();
}
else {
- standalone->explanations("Disabling printer sharing");
- foreach $printer (keys (%::bool)) {
+ standalone->explanations("Disabling printer sharing");
+ foreach $printer (keys (%::bool)) {
if (!int($::bool{$printer})) {
$conf->comment_menu("$printer", ";");
- }
- }
+ }
+ }
$conf->comment_menu("printers", ";");
- }
+ }
$conf->write_conf("/etc/samba/smb.conf");
system("/etc/rc.d/init.d/smb restart");
10;