summaryrefslogtreecommitdiffstats
path: root/samba_wizard
diff options
context:
space:
mode:
Diffstat (limited to 'samba_wizard')
-rwxr-xr-xsamba_wizard/scripts/Smbconf.pm56
1 files changed, 35 insertions, 21 deletions
diff --git a/samba_wizard/scripts/Smbconf.pm b/samba_wizard/scripts/Smbconf.pm
index 1d493c72..b44c61e9 100755
--- a/samba_wizard/scripts/Smbconf.pm
+++ b/samba_wizard/scripts/Smbconf.pm
@@ -1,10 +1,28 @@
-#! /usr/bin/perl -w
+#!/usr/bin/perl
+
+# Drakwizard
+
+# Copyright (C) 2002 MandrakeSoft Arnaud Desmons (adesmons@mandrakesoft.com)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package Smbconf;
require "__WIZ_HOME__/common/scripts/Vareqval.pm";
-require "__WIZ_HOME__/common/scripts/DrakconnectConf.pm";
+require "__WIZ_HOME__/common/scripts/IFCFG.pm";
use MDK::Common;
-#use strict;
+use strict;
use Data::Dumper;
# All possibilies in the config file must be precedeed by ";"
@@ -12,7 +30,7 @@ use Data::Dumper;
# but can not add anything.
# so one variable cannot be commented and not in the same file.
-my $o = DrakconnectConf->new();
+my $o = IFCFG->new();
sub check {
$> and return 1;
@@ -41,7 +59,7 @@ sub read_conf {
my $menu;
my @tab;
my %conf;
-
+
open(FH, $file) or die "$! ($file)";
while (<FH>) {
if (/^(\s*\;?\s*)\[(.*)\].*/) {
@@ -65,7 +83,7 @@ sub write_conf {
my $self = shift;
my ($file) = @_;
my $menu;
-
+
open(FH, "> $file") or die "$!";
foreach (@{$self->{tab}}) {
if (/^\s*\;?\s*\[(.*)\].*/) {
@@ -85,7 +103,7 @@ sub write_conf {
sub add_printer {
my $self = shift;
my ($printer) = @_;
-
+
if (exists $self->{conf}->{$printer}) {
$self->comment_menu($printer, " ");
}
@@ -102,7 +120,7 @@ sub add_printer {
sub list_printers {
my @list if 0;
-
+
return @list if @list;
@list = sort grep /^(?!\#).*/, map {
my ($printer) = split(':', $_);
@@ -118,7 +136,7 @@ sub check_users {
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}}) {
@@ -130,35 +148,32 @@ sub comment_menu {
sub comment_var {
my $self = shift;
my ($menu, $var, $str) = @_;
-
+
$self->{conf}->{$menu}{$var}{comment} = $str;
}
sub chg_var {
my $self = shift;
my ($menu, $var, $str) = @_;
-
+
$self->{conf}->{$menu}{$var}{value} = $str;
}
# all or selected printers
sub printer_sharing {
my $self = shift;
- my $printer;
if ($ENV{wiz_all_printers}) {
$self->comment_menu("printers", " ");
- foreach $printer (keys (%::bool)) {
+ foreach my $printer (keys (%::bool)) {
$self->comment_menu($printer, ";");
}
}
else {
$self->comment_menu("printers", ";");
- foreach $printer (keys (%::bool)) {
- print "$printer\n";
+ foreach my $printer (keys (%::bool)) {
if (int($::bool{$printer})) {
$self->comment_menu($printer, " ");
- print "$printer\n";
$self->add_printer($printer);
}
else {
@@ -169,9 +184,8 @@ sub printer_sharing {
}
sub get_printers {
- my $string;
-
if ($ENV{wiz_do_printer_sharing}) {
+ my $string;
$ENV{wiz_all_printers} and return "all printers";
foreach (keys (%::bool)) {
$string .= "$_, " if int($::bool{$_});
@@ -276,7 +290,7 @@ sub do_it {
$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");
+ my $ip = $o->itf_get("IPADDR");
if ($ENV{wiz_do_file_sharing}) {
standalone->explanations("Enabling $ENV{wiz_dir} samba file sharing");
$conf->comment_menu("public", " ");
@@ -298,14 +312,14 @@ sub do_it {
standalone->explanations("Samba allow $ENV{wiz_hosts_allow}");
# $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)) {
+ foreach my $printer (keys (%::bool)) {
if (!int($::bool{$printer})) {
$conf->comment_menu("$printer", ";");
}