diff options
author | Till Kamppeter <tkamppeter@mandriva.com> | 2003-02-04 19:05:42 +0000 |
---|---|---|
committer | Till Kamppeter <tkamppeter@mandriva.com> | 2003-02-04 19:05:42 +0000 |
commit | cb8c8c4d4b04fc9601b7db400aeeff65430c2a04 (patch) | |
tree | 882474309813c750ee3b930b4afcb59e85a101cc /perl-install | |
parent | a32d31373f9198b23459518bcde8a333e643f7f7 (diff) | |
download | drakx-cb8c8c4d4b04fc9601b7db400aeeff65430c2a04.tar drakx-cb8c8c4d4b04fc9601b7db400aeeff65430c2a04.tar.gz drakx-cb8c8c4d4b04fc9601b7db400aeeff65430c2a04.tar.bz2 drakx-cb8c8c4d4b04fc9601b7db400aeeff65430c2a04.tar.xz drakx-cb8c8c4d4b04fc9601b7db400aeeff65430c2a04.zip |
- "Out-sourced" functions for config file handling into handle_configs.pm,
it is used by both printerdrake and scannerdrake.
- Improvements and fixes on CUPS daemon configuration by printerdrake.
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/handle_configs.pm | 168 | ||||
-rw-r--r-- | perl-install/printer/main.pm | 293 | ||||
-rw-r--r-- | perl-install/printer/printerdrake.pm | 19 |
3 files changed, 304 insertions, 176 deletions
diff --git a/perl-install/handle_configs.pm b/perl-install/handle_configs.pm new file mode 100644 index 000000000..2f2fa3ffc --- /dev/null +++ b/perl-install/handle_configs.pm @@ -0,0 +1,168 @@ +package handle_configs; + +# $Id$ + +use diagnostics; +use strict; + +use common; + +sub read_directives { + + # Read one or more occurences of a directive + + my ($lines_ptr, $directive) = @_; + + my @result = (); + my $searchdirective = $directive; + $searchdirective =~ s/([\\\/\(\)\[\]\|\.\$\@\%\*\?])/\\$1/g; + ($_ =~ /^\s*$searchdirective\s+(\S.*)$/ and push(@result, $1)) + foreach @{$lines_ptr}; + (chomp) foreach @result; + return @result; +} + +sub read_unique_directive { + + # Read a directive, if the directive appears more than once, use + # the last occurence and remove all the others, if it does not + # occur, return the default value + + my ($lines_ptr, $directive, $default) = @_; + + if ((my @d = read_directives($lines_ptr, $directive)) > 0) { + my $value = @d[$#d]; + set_directive($lines_ptr, "$directive $value"); + return $value; + } else { + return $default; + } +} + +sub insert_directive { + + # Insert a directive only if it is not already there + + my ($lines_ptr, $directive) = @_; + + my $searchdirective = $directive; + $searchdirective =~ s/([\\\/\(\)\[\]\|\.\$\@\%\*\?])/\\$1/g; + ($_ =~ /^\s*$searchdirective$/ and return 0) foreach @{$lines_ptr}; + splice(@{$lines_ptr}, -1, 0, "$directive\n"); + return 1; +} + +sub remove_directive { + + # Remove a directive + + my ($lines_ptr, $directive) = @_; + + my $success = 0; + my $searchdirective = $directive; + $searchdirective =~ s/([\\\/\(\)\[\]\|\.\$\@\%\*\?])/\\$1/g; + ($_ =~ /^\s*$searchdirective/ and $_ = "" and $success = 1) + foreach @{$lines_ptr}; + return $success; +} + +sub comment_directive { + + # Comment out a directive + + my ($lines_ptr, $directive) = @_; + + my $success = 0; + my $searchdirective = $directive; + $searchdirective =~ s/([\\\/\(\)\[\]\|\.\$\@\%\*\?])/\\$1/g; + ($_ =~ s/^(\s*$searchdirective)/\#$1/ and $success = 1) + foreach @{$lines_ptr}; + return $success; +} + +sub replace_directive { + + # Replace a directive, if it appears more than once, remove + # the additional occurences. + + my ($lines_ptr, $olddirective, $newdirective) = @_; + + my $success = 0; + $newdirective = "$newdirective\n"; + my $searcholddirective = $olddirective; + $searcholddirective =~ s/([\\\/\(\)\[\]\|\.\$\@\%\*\?])/\\$1/g; + ($_ =~ /^\s*$searcholddirective/ and $_ = $newdirective and + $success = 1 and $newdirective = "") foreach @{$lines_ptr}; + return $success; +} + + +sub move_directive_to_version_commented_out { + + # If there is a version of the directive "commentedout" which is + # commented out, the directive "directive" will be moved in its place. + + my ($lines_ptr, $commentedout, $directive, $exactmatch) = @_; + + my $success = 0; + my $searchcommentedout = $commentedout; + $searchcommentedout =~ s/([\\\/\(\)\[\]\|\.\$\@\%\*\?])/\\$1/g; + $searchcommentedout .= ".*" if (!$exactmatch); + ($_ =~ /^\s*\#$searchcommentedout$/ and + $success = 1 and last) foreach @{$lines_ptr}; + if ($success) { + remove_directive($lines_ptr, $directive); + ($_ =~ s/^\s*\#($searchcommentedout)$/$directive/ and + $success = 1 and last) foreach @{$lines_ptr}; + } + return $success; +} + +sub set_directive { + + # Set a directive in the cupsd.conf, replace the old definition or + # a commented definition + + my ($lines_ptr, $directive) = @_; + + my $searchdirective = $directive; + $searchdirective =~ s/([\\\/\(\)\[\]\|\.\$\@\%\*\?])/\\$1/g; + my $olddirective = $searchdirective; + $olddirective =~ s/^\s*(\S+)\s+.*$/$1/s; + + my $success = (replace_directive($lines_ptr, $olddirective, + $directive) or + insert_directive($lines_ptr, $directive)); + if ($success) { + move_directive_to_version_commented_out($lines_ptr, + "$directive\$", + $directive) or + move_directive_to_version_commented_out($lines_ptr, + $olddirective, $directive); + } + return $success; +} + +sub add_directive { + + # Set a directive in the cupsd.conf, replace the old definition or + # a commented definition + + my ($lines_ptr, $directive) = @_; + + my $searchdirective = $directive; + $searchdirective =~ s/([\\\/\(\)\[\]\|\.\$\@\%\*\?])/\\$1/g; + my $olddirective = $searchdirective; + $olddirective =~ s/^\s*(\S+)\s+.*$/$1/s; + + my $success = insert_directive($lines_ptr, $directive); + if ($success) { + move_directive_to_version_commented_out($lines_ptr, $directive, + $directive, 1) or + move_directive_to_version_commented_out($lines_ptr, + $olddirective, $directive); + } + return $success; +} + +1; diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm index 2ee75ba04..d3699491c 100644 --- a/perl-install/printer/main.pm +++ b/perl-install/printer/main.pm @@ -13,6 +13,7 @@ use printer::gimp; use printer::cups; use printer::office; use printer::detect; +use handle_configs; use services; use vars qw(@ISA @EXPORT); @@ -674,95 +675,6 @@ sub write_cupsd_conf { printer::services::restart("cups"); } -sub read_directives { - - # Read one or more occurences of a directive from the cupsd.conf file - # or from a ripped-out location block - - my ($lines_ptr, $directive) = @_; - - my @result = (); - ($_ =~ /^\s*$directive\s+(\S.*)$/ and push(@result, $1)) - foreach @{$lines_ptr}; - (chomp) foreach @result; - return @result; -} - -sub read_unique_directive { - - # Read a directive from the from the cupsd.conf file or from a - # ripped-out location block, if the directive appears more than once, - # use the last occurence and remove all the others, if it does not - # occur, return the default value - - my ($lines_ptr, $directive, $default) = @_; - - if ((my @d = read_directives($lines_ptr, $directive)) > 0) { - my $value = @d[$#d]; - set_directive($lines_ptr, "$directive $value"); - return $value; - } else { - return $default; - } -} - -sub insert_directive { - - # Insert a directive into the cupsd.conf file or into a ripped-out - # location block (but only if it is not already there) - - my ($lines_ptr, $directive) = @_; - - ($_ =~ /^\s*$directive$/ and return 0) foreach @{$lines_ptr}; - splice(@{$lines_ptr}, -1, 0, "$directive\n"); - return 1; -} - -sub remove_directive { - - # Remove a directive from the cupsd.conf file or from a ripped-out - # location block - - my ($lines_ptr, $directive) = @_; - - my $success = 0; - ($_ =~ /^\s*$directive/ and $_ = "" and $success = 1) - foreach @{$lines_ptr}; - return $success; -} - -sub replace_directive { - - # Replace a directive in the cupsd.conf file or from a ripped-out - # location block, if the directive appears more than once, remove - # the additional occurences - - my ($lines_ptr, $olddirective, $newdirective) = @_; - - $newdirective = "$newdirective\n"; - my $success = 0; - ($_ =~ /^\s*$olddirective/ and $_ = $newdirective and - $success = 1 and $newdirective = "") foreach @{$lines_ptr}; - return $success; -} - -sub set_directive { - - # Set a directive in the cupsd.conf, replace the old definition or - # a commented definition - - my ($cupsd_conf_ptr, $directive) = @_; - - my $olddirective = $directive; - $olddirective =~ s/^\s*(\S+)\s+.*$/$1/s; - - return (replace_directive($cupsd_conf_ptr, $olddirective, - $directive) or - replace_directive($cupsd_conf_ptr, "\#$olddirective", - $directive) or - insert_directive($cupsd_conf_ptr, $directive)); -} - sub read_location { # Return the lines inside the [path] location block @@ -866,7 +778,7 @@ sub add_to_location { my ($cupsd_conf_ptr, $path, $directive) = @_; my ($location_start, @location) = rip_location($cupsd_conf_ptr, $path); - my $success = insert_directive(\@location, $directive); + my $success = handle_configs::insert_directive(\@location, $directive); insert_location($cupsd_conf_ptr, $location_start, @location); return $success; } @@ -878,7 +790,7 @@ sub remove_from_location { my ($cupsd_conf_ptr, $path, $directive) = @_; my ($location_start, @location) = rip_location($cupsd_conf_ptr, $path); - my $success = remove_directive(\@location, $directive); + my $success = handle_configs::remove_directive(\@location, $directive); insert_location($cupsd_conf_ptr, $location_start, @location); return $success; } @@ -890,8 +802,9 @@ sub replace_in_location { my ($cupsd_conf_ptr, $path, $olddirective, $newdirective) = @_; my ($location_start, @location) = rip_location($cupsd_conf_ptr, $path); - my $success = replace_directive(\@location, $olddirective, - $newdirective); + my $success = handle_configs::replace_directive(\@location, + $olddirective, + $newdirective); insert_location($cupsd_conf_ptr, $location_start, @location); return $success; } @@ -901,7 +814,8 @@ sub add_allowed_host { # Add a host or network which should get access to the local printer(s) my ($cupsd_conf_ptr, $host) = @_; - return (insert_directive($cupsd_conf_ptr, "BrowseAddress $host") and + return (handle_configs::insert_directive($cupsd_conf_ptr, + "BrowseAddress $host") and add_to_location($cupsd_conf_ptr, "/", "Allow From $host")); } @@ -911,8 +825,9 @@ sub remove_allowed_host { # printer(s) my ($cupsd_conf_ptr, $host) = @_; - return (remove_directive($cupsd_conf_ptr, "BrowseAddress $host") and - remove_from_location($cupsd_conf_ptr, "/", "Allow From $host")); + return (handle_configs::remove_directive($cupsd_conf_ptr, "BrowseAddress $host") and + remove_from_location($cupsd_conf_ptr, "/", + "Allow From $host")); } sub replace_allowed_host { @@ -921,8 +836,9 @@ sub replace_allowed_host { # printer(s) my ($cupsd_conf_ptr, $oldhost, $newhost) = @_; - return (replace_directive($cupsd_conf_ptr, "BrowseAddress $oldhost", - "BrowseAddress $newhost") and + return (handle_configs::replace_directive($cupsd_conf_ptr, + "BrowseAddress $oldhost", + "BrowseAddress $newhost") and replace_in_location($cupsd_conf_ptr, "/", "Allow From $newhost", "Allow From $newhost")); } @@ -1049,17 +965,27 @@ sub clientnetworks { # Check for a "Deny From All" line my $havedenyfromall = (join('', @{$printer->{cupsconfig}{root}{DenyFrom}}) =~ - /All/im); + /All/im ? 1 : 0); + + # Check for "Deny From XXX" with XXX != All + my $havedenyfromnotall = + ($#{$printer->{cupsconfig}{root}{DenyFrom}} - $havedenyfromall < 0 ? + 0 : 1); + + # Check for a "BrowseDeny All" line + my $havebrowsedenyall = + (join('', @{$printer->{cupsconfig}{keys}{BrowseDeny}}) =~ + /All/im ? 1 : 0); - # Check for "Order Deny,Allow" - my $orderdenyallow = - ($printer->{cupsconfig}{root}{Order} =~ - /deny\s*,\s*allow/i); + # Check for "BrowseDeny XXX" with XXX != All + my $havebrowsedenynotall = + ($#{$printer->{cupsconfig}{keys}{BrowseDeny}} - + $havebrowsedenyall < 0 ? 0 : 1); my @sharehosts; my $haveallowfromlocalhost = 0; my $haveallowedhostwithoutbrowseaddress = 0; - + my $haveallowedhostwithoutbrowseallow = 0; # Go through all "Allow From" lines for my $line (@{$printer->{cupsconfig}{root}{AllowFrom}}) { if ($line =~ /^\s*(localhost|0*127\.0+\.0+\.0*1)\s*$/i) { @@ -1074,6 +1000,10 @@ sub clientnetworks { @{$printer->{cupsconfig}{keys}{BrowseAddress}})) { $haveallowedhostwithoutbrowseaddress = 1; } + if (!member($line, + @{$printer->{cupsconfig}{keys}{BrowseAllow}})) { + $haveallowedhostwithoutbrowseallow = 1; + } } } my $havebrowseaddresswithoutallowedhost = 0; @@ -1089,11 +1019,28 @@ sub clientnetworks { $havebrowseaddresswithoutallowedhost = 1; } } + my $havebrowseallowwithoutallowedhost = 0; + # Go through all "BrowseAllow" lines + for my $line (@{$printer->{cupsconfig}{keys}{BrowseAllow}}) { + if ($line =~ /^\s*(localhost|0*127\.0+\.0+\.0*1)\s*$/i) { + # Skip lines pointing to localhost + } elsif ($line =~ /^\s*(none)\s*$/i) { + # Skip "BrowseAllow None" lines + } elsif (!member($line, @sharehosts)) { + # Line pointing to remote server + push(@sharehosts, $line); + $havebrowseallowwithoutallowedhost = 1; + } + } - my $configunsupported = (!$havedenyfromall || !$orderdenyallow || + print "##### (!$havedenyfromall || $havedenyfromnotall || !$havebrowsedenyall || $havebrowsedenynotall || !$haveallowfromlocalhost || $haveallowedhostwithoutbrowseaddress || $havebrowseaddresswithoutallowedhost || $haveallowedhostwithoutbrowseallow || $havebrowseallowwithoutallowedhost)\n"; + my $configunsupported = (!$havedenyfromall || $havedenyfromnotall || + !$havebrowsedenyall || $havebrowsedenynotall || !$haveallowfromlocalhost || $haveallowedhostwithoutbrowseaddress || - $havebrowseaddresswithoutallowedhost); + $havebrowseaddresswithoutallowedhost || + $haveallowedhostwithoutbrowseallow || + $havebrowseallowwithoutallowedhost); return ($configunsupported, @sharehosts); } @@ -1151,33 +1098,33 @@ sub read_cups_config { # Keyword "Browsing" $printer->{cupsconfig}{keys}{Browsing} = - read_unique_directive($printer->{cupsconfig}{cupsd_conf}, - 'Browsing', 'On'); + handle_configs::read_unique_directive($printer->{cupsconfig}{cupsd_conf}, + 'Browsing', 'On'); # Keyword "BrowseInterval" $printer->{cupsconfig}{keys}{BrowseInterval} = - read_unique_directive($printer->{cupsconfig}{cupsd_conf}, - 'BrowseInterval', '30'); + handle_configs::read_unique_directive($printer->{cupsconfig}{cupsd_conf}, + 'BrowseInterval', '30'); # Keyword "BrowseAddress" @{$printer->{cupsconfig}{keys}{BrowseAddress}} = - read_directives($printer->{cupsconfig}{cupsd_conf}, - 'BrowseAddress'); + handle_configs::read_directives($printer->{cupsconfig}{cupsd_conf}, + 'BrowseAddress'); # Keyword "BrowseAllow" @{$printer->{cupsconfig}{keys}{BrowseAllow}} = - read_directives($printer->{cupsconfig}{cupsd_conf}, - 'BrowseAllow'); + handle_configs::read_directives($printer->{cupsconfig}{cupsd_conf}, + 'BrowseAllow'); # Keyword "BrowseDeny" @{$printer->{cupsconfig}{keys}{BrowseDeny}} = - read_directives($printer->{cupsconfig}{cupsd_conf}, - 'BrowseDeny'); + handle_configs::read_directives($printer->{cupsconfig}{cupsd_conf}, + 'BrowseDeny'); # Keyword "BrowseOrder" $printer->{cupsconfig}{keys}{BrowseOrder} = - read_unique_directive($printer->{cupsconfig}{cupsd_conf}, - 'BrowseOrder', 'deny,allow'); + handle_configs::read_unique_directive($printer->{cupsconfig}{cupsd_conf}, + 'BrowseOrder', 'deny,allow'); # Root location @{$printer->{cupsconfig}{rootlocation}} = @@ -1185,18 +1132,18 @@ sub read_cups_config { # Keyword "Allow from" @{$printer->{cupsconfig}{root}{AllowFrom}} = - read_directives($printer->{cupsconfig}{rootlocation}, - 'Allow From'); + handle_configs::read_directives($printer->{cupsconfig}{rootlocation}, + 'Allow From'); # Keyword "Deny from" @{$printer->{cupsconfig}{root}{DenyFrom}} = - read_directives($printer->{cupsconfig}{rootlocation}, - 'Deny From'); + handle_configs::read_directives($printer->{cupsconfig}{rootlocation}, + 'Deny From'); # Keyword "Order" $printer->{cupsconfig}{root}{Order} = - read_unique_directive($printer->{cupsconfig}{rootlocation}, - 'Order', 'Deny,Allow'); + handle_configs::read_unique_directive($printer->{cupsconfig}{rootlocation}, + 'Order', 'Deny,Allow'); # Widget settings @@ -1224,51 +1171,43 @@ sub write_cups_config { # Local printers available to other machines? if ($printer->{cupsconfig}{localprintersshared}) { - set_directive($printer->{cupsconfig}{cupsd_conf}, - 'Browsing On'); + handle_configs::set_directive($printer->{cupsconfig}{cupsd_conf}, + 'Browsing On'); if ($printer->{cupsconfig}{keys}{BrowseInterval} == 0) { - set_directive($printer->{cupsconfig}{cupsd_conf}, - 'BrowseInterval 30'); + handle_configs::set_directive($printer->{cupsconfig}{cupsd_conf}, + 'BrowseInterval 30'); } } else { - set_directive($printer->{cupsconfig}{cupsd_conf}, - 'BrowseInterval 0'); + handle_configs::set_directive($printer->{cupsconfig}{cupsd_conf}, + 'BrowseInterval 0'); } # This machine is accepting printers shared by remote machines? if ($printer->{cupsconfig}{remotebroadcastsaccepted}) { - set_directive($printer->{cupsconfig}{cupsd_conf}, - 'Browsing On'); - if (($printer->{cupsconfig}{localprintersshared}) && - ($#{$printer->{cupsconfig}{clientnetworks}} > 0) && - (!$printer->{cupsconfig}{customsharingsetup})) { + handle_configs::set_directive($printer->{cupsconfig}{cupsd_conf}, + 'Browsing On'); + if (!$printer->{cupsconfig}{customsharingsetup}) { # If we broadcast our printers, let's accept the broadcasts # from the machines to which we broadcast - set_directive($printer->{cupsconfig}{cupsd_conf}, - 'BrowseDeny All'); - set_directive($printer->{cupsconfig}{cupsd_conf}, - 'BrowseOrder Deny,Allow'); - set_directive($printer->{cupsconfig}{cupsd_conf}, - 'BrowseAllow ' . - join ("\nBrowseAllow ", - @{$printer->{cupsconfig}{clientnetworks}})); - } elsif (!remotebroadcastsaccepted($printer)) { - # Use default settings if the "BrowseDeny"/"BrowseAllow" - # configuration does not accept broadcasts - set_directive($printer->{cupsconfig}{cupsd_conf}, - 'BrowseDeny All'); - set_directive($printer->{cupsconfig}{cupsd_conf}, - 'BrowseOrder Deny,Allow'); - set_directive($printer->{cupsconfig}{cupsd_conf}, - 'BrowseOrder @LOCAL'); + handle_configs::set_directive($printer->{cupsconfig}{cupsd_conf}, + 'BrowseDeny All'); + handle_configs::set_directive($printer->{cupsconfig}{cupsd_conf}, + 'BrowseOrder Deny,Allow'); } } else { - # Deny all broadcasts, but leave all "BrowseAllow" lines - # untouched - set_directive($printer->{cupsconfig}{cupsd_conf}, - 'BrowseDeny All'); - set_directive($printer->{cupsconfig}{cupsd_conf}, - 'BrowseOrder Allow,Deny'); + if ($printer->{cupsconfig}{localprintersshared}) { + # Deny all broadcasts, but leave all "BrowseAllow" lines + # untouched + handle_configs::set_directive($printer->{cupsconfig}{cupsd_conf}, + 'BrowseDeny All'); + handle_configs::set_directive($printer->{cupsconfig}{cupsd_conf}, + 'BrowseOrder Allow,Deny'); + } else { + # We also do not share printers, so we turn browsing off to + # do not need to deal with any addresses + handle_configs::set_directive($printer->{cupsconfig}{cupsd_conf}, + 'Browsing Off'); + } } # To which machines are the local printers available? @@ -1276,24 +1215,42 @@ sub write_cups_config { # root location block @{$printer->{cupsconfig}{rootlocation}} = "<Location />\n" . - "Order Deny,Allow\n" . + ($printer->{cupsconfig}{localprintersshared} ? + "Order Deny,Allow\n" : + "Order Allow,Deny\n") . "Deny From All\n" . "Allow From 127.0.0.1\n" . - "Allow From " . - join ("\nAllow From ", - @{$printer->{cupsconfig}{clientnetworks}}) . - "\n" . + ($#{$printer->{cupsconfig}{clientnetworks}} >= 0 ? + "Allow From " . + join ("\nAllow From ", + @{$printer->{cupsconfig}{clientnetworks}}) . + "\n" : ""). "</Location>\n"; my ($location_start, @location) = rip_location($printer->{cupsconfig}{cupsd_conf}, "/"); insert_location($printer->{cupsconfig}{cupsd_conf}, $location_start, @{$printer->{cupsconfig}{rootlocation}}); # "BrowseAddress" lines - set_directive($printer->{cupsconfig}{cupsd_conf}, - 'BrowseAddress ' . - join ("\nBrowseAddress ", - map {broadcastaddress($_)} - @{$printer->{cupsconfig}{clientnetworks}})); + if ($#{$printer->{cupsconfig}{clientnetworks}} >= 0) { + handle_configs::set_directive($printer->{cupsconfig}{cupsd_conf}, + 'BrowseAddress ' . + join ("\nBrowseAddress ", + map {broadcastaddress($_)} + @{$printer->{cupsconfig}{clientnetworks}})); + } else { + handle_configs::comment_directive($printer->{cupsconfig}{cupsd_conf}, + 'BrowseAddress') + } + # Set "BrowseAllow" lines + if ($#{$printer->{cupsconfig}{clientnetworks}} >= 0) { + handle_configs::set_directive($printer->{cupsconfig}{cupsd_conf}, + 'BrowseAllow ' . + join ("\nBrowseAllow ", + @{$printer->{cupsconfig}{clientnetworks}})); + } else { + handle_configs::comment_directive($printer->{cupsconfig}{cupsd_conf}, + 'BrowseAllow'); + } } } diff --git a/perl-install/printer/printerdrake.pm b/perl-install/printer/printerdrake.pm index e5b028fd1..2389dac79 100644 --- a/perl-install/printer/printerdrake.pm +++ b/perl-install/printer/printerdrake.pm @@ -84,7 +84,9 @@ sub config_cups { [ { text => N("The printers on this machine are available to other computers"), type => 'bool', val => \$printer->{cupsconfig}{localprintersshared} }, - { val => N("Local printers available on: ") . + { text => N("Automatically find available printers on remote machines"), type => 'bool', + val => \$printer->{cupsconfig}{remotebroadcastsaccepted} }, + { val => N("Printer sharing on hosts/networks: ") . ($printer->{cupsconfig}{customsharingsetup} ? N("Custom configuration") : ($#{$sharehosts->{list}} >= 0 ? @@ -98,10 +100,9 @@ sub config_cups { 1; }, disabled => sub { - (!$printer->{cupsconfig}{localprintersshared}); + (!$printer->{cupsconfig}{localprintersshared} && + !$printer->{cupsconfig}{remotebroadcastsaccepted}); } }, - { text => N("Automatically find available printers on remote machines"), type => 'bool', - val => \$printer->{cupsconfig}{remotebroadcastsaccepted} }, if_($::expert, { text => N("Automatic correction of CUPS configuration"), type => 'bool', @@ -288,10 +289,12 @@ N("192.168.100.0/255.255.255.0\n") # We have modified the configuration now $printer->{cupsconfig}{customsharingsetup} = 0; } - # If we have no entry in the list, we do not - # share the local printers, mark this - $printer->{cupsconfig}{localprintersshared} = - ($#{$printer->{cupsconfig}{clientnetworks}} >= 0); + } + # If we have no entry in the list, we do not + # share the local printers, mark this + if ($#{$printer->{cupsconfig}{clientnetworks}} < 0) { + $printer->{cupsconfig}{localprintersshared} = 0; + $printer->{cupsconfig}{remotebroadcastsaccepted} = 0; } } else { # We have clicked "OK" |