summaryrefslogtreecommitdiffstats
path: root/perl-install/printer/detect.pm
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2003-03-11 18:34:39 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2003-03-11 18:34:39 +0000
commit6a9ef211bf8411e78a52c641848e4fa827ffcaf8 (patch)
treeef781e9a2beaa0470947a373aa7591ae96112770 /perl-install/printer/detect.pm
parentd3e2e1e996620479eb270d88d8ab706dd86d76a0 (diff)
downloaddrakx-backup-do-not-use-6a9ef211bf8411e78a52c641848e4fa827ffcaf8.tar
drakx-backup-do-not-use-6a9ef211bf8411e78a52c641848e4fa827ffcaf8.tar.gz
drakx-backup-do-not-use-6a9ef211bf8411e78a52c641848e4fa827ffcaf8.tar.bz2
drakx-backup-do-not-use-6a9ef211bf8411e78a52c641848e4fa827ffcaf8.tar.xz
drakx-backup-do-not-use-6a9ef211bf8411e78a52c641848e4fa827ffcaf8.zip
Made sure that all IP addresses of the local machine are in 'Allow
From' lines in the /etc/cups/cupsd.conf, otherwise one can have certain configurations with which one cannot access to the options of the local printer(s).
Diffstat (limited to 'perl-install/printer/detect.pm')
-rw-r--r--perl-install/printer/detect.pm42
1 files changed, 42 insertions, 0 deletions
diff --git a/perl-install/printer/detect.pm b/perl-install/printer/detect.pm
index 72568ee47..61c39522d 100644
--- a/perl-install/printer/detect.pm
+++ b/perl-install/printer/detect.pm
@@ -269,6 +269,48 @@ sub getNetworkInterfaces {
@interfaces;
}
+sub getIPsOfLocalMachine {
+
+ # subroutine determines all IPs which point to the local machine,
+ # except 127.0.0.1 (localhost).
+
+ # Return an empty list if no network is running
+ return () unless network_running();
+
+ # Read the output of "ifconfig" to determine the broadcast addresses of
+ # the local networks
+ my $dev_is_realnet = 0;
+ my @local_ips;
+ my $current_ip = "";
+
+ local *IFCONFIG_OUT;
+ open IFCONFIG_OUT, ($::testing ? "" : "chroot $::prefix/ ") .
+ "/bin/sh -c \"export LC_ALL=C; ifconfig\" |" or return ();
+ while (my $readline = <IFCONFIG_OUT>) {
+ # New entry ...
+ if ($readline =~ /^(\S+)\s/) {
+ my $dev = $1;
+ # ... for a real network (not lo = localhost)
+ $dev_is_realnet = ($dev ne 'lo');
+ # delete previous address
+ $current_ip = "";
+ }
+ # Are we in the important line now?
+ if ($readline =~ /\sinet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s/) {
+ # Rip out the IP address
+ $current_ip = $1;
+
+ # Are we in an entry for a real network?
+ if ($dev_is_realnet) {
+ # Store current IP address
+ push @local_ips, $current_ip;
+ }
+ }
+ }
+ close(IFCONFIG_OUT);
+ @local_ips;
+}
+
sub getIPsInLocalNetworks {
# subroutine determines the list of all hosts reachable in the local