summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/drakgw
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2001-03-26 15:29:01 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2001-03-26 15:29:01 +0000
commitf28b15bb8f1a13b0fd11e328d21233ab40815f33 (patch)
tree743d26266f3faf06a3113d480526b59956c08077 /perl-install/standalone/drakgw
parentc4394411a2aac97d518b52bb6e14a6bedc394916 (diff)
downloaddrakx-f28b15bb8f1a13b0fd11e328d21233ab40815f33.tar
drakx-f28b15bb8f1a13b0fd11e328d21233ab40815f33.tar.gz
drakx-f28b15bb8f1a13b0fd11e328d21233ab40815f33.tar.bz2
drakx-f28b15bb8f1a13b0fd11e328d21233ab40815f33.tar.xz
drakx-f28b15bb8f1a13b0fd11e328d21233ab40815f33.zip
first attempt at pixelization of code (till's cups patches)
Diffstat (limited to 'perl-install/standalone/drakgw')
-rwxr-xr-xperl-install/standalone/drakgw58
1 files changed, 58 insertions, 0 deletions
diff --git a/perl-install/standalone/drakgw b/perl-install/standalone/drakgw
index 56986f864..866af8ee2 100755
--- a/perl-install/standalone/drakgw
+++ b/perl-install/standalone/drakgw
@@ -499,14 +499,69 @@ substInFile { s/^DHCP.interface.*\n//; $_ .= "DHCP.interface $device\n" if eof }
#- 2. BrowseAddress <server's Broadcast IP> # broadcast printer info into
#- # the local network.
#-
+#- 3. BrowseOrder Deny,Allow
+#- BrowseDeny All
+#- BrowseAllow <IP mask for local net> # Only accept broadcast signals
+#- # coming from local network
+#-
+#- 4. <Location />
+#- Order Deny,Allow
+#- Deny From All
+#- Allow From <IP mask for local net> # Allow only machines of local
+#- </Location> # network to access the server
+#-
#- These steps are only done when the CUPS package is installed.
substInFile {
s/^ServerName[^:].*\n//; $_ .= "ServerName $lan_address.1\n" if eof;
s/^BrowseAddress.*\n//; $_ .= "BrowseAddress $lan_address.255\n" if eof;
+ s/^BrowseOrder.*\n//; $_ .= "BrowseOrder Deny,Allow\n" if eof;
+ s/^BrowseDeny.*\n//; $_ .= "BrowseDeny All\n" if eof;
+ s/^BrowseAllow.*\n//; $_ .= "BrowseAllow $lan_address.*\n" if eof;
} $cups_conf;
+#- Modify the root location block in /etc/cups/cupsd.conf
+
+if (-f $cups_conf) {
+ my @cups_conf_content = cat_($cups_conf);
+ my @root_location; my $root_location_start; my $root_location_end;
+
+ # Cut out the root location block so that it can be treated seperately
+ # without affecting the rest of the file
+ if (grep(m|^\s*<Location\s+/\s*>|, @cups_conf_content)) {
+ $root_location_start = -1;
+ $root_location_end = -1;
+ # Go through all the lines, bail out when start and end line found
+ for (my $i = 0; $i < @cups_conf_content && $root_location_end == -1; $i++) {
+ if ($cups_conf_content[$i] =~ m|^\s*<\s*Location\s+/\s*>|) {
+ $root_location_start = $i;
+ } elsif (($cups_conf_content[$i] =~ m|^\s*<\s*/Location\s*>|) && ($root_location_start != -1)) {
+ $root_location_end = $i;
+ }
+ }
+ # Rip out the block and store it seperately
+ @root_location = splice(@cups_conf_content, $root_location_start, $root_location_end - $root_location_start + 1);
+ } else {
+ # If there is no root location block, create one
+ $root_location_start = @cups_conf_content;
+ @root_location = ("<Location />\n", "</Location>\n");
+ }
+
+ # Delete all former "Order", "Allow", and "Deny" lines from the root location block
+ s/^\s*Order.*//, s/^\s*Allow.*//, s/^\s*Deny.*// foreach @root_location;
+
+ # Add the new "Order" and "Deny" lines, add an "Allow" line for the local network
+ splice(@root_location, -1, 0, $_) foreach ("Order Deny,Allow\n", "Deny From All\n", "Allow From 127.0.0.1\n",
+ "Allow From $lan_address.*\n");
+
+ # Put the changed root location block back into the file
+ splice(@cups_conf_content, $root_location_start, 0, @root_location);
+
+ output $cups_conf, @cups_conf_content;
+}
+
+
#- start the daemons
start_daemons();
@@ -537,6 +592,9 @@ sub quit_global {
#-------------------------------------------------
#- $Log$
+#- Revision 1.29 2001/03/26 15:29:01 gc
+#- first attempt at pixelization of code (till's cups patches)
+#-
#- Revision 1.28 2001/03/21 18:07:36 gc
#- honour embedded mode
#-