diff options
author | Till Kamppeter <tkamppeter@mandriva.com> | 2002-09-13 17:35:40 +0000 |
---|---|---|
committer | Till Kamppeter <tkamppeter@mandriva.com> | 2002-09-13 17:35:40 +0000 |
commit | 48f444aaf23bb5fe4758d141a87456f256be179b (patch) | |
tree | a18133cd687724b9b5807ee097996457bb539a53 | |
parent | 455b9cf08ff0028286d47e8e56387eb38701888a (diff) | |
download | drakx-48f444aaf23bb5fe4758d141a87456f256be179b.tar drakx-48f444aaf23bb5fe4758d141a87456f256be179b.tar.gz drakx-48f444aaf23bb5fe4758d141a87456f256be179b.tar.bz2 drakx-48f444aaf23bb5fe4758d141a87456f256be179b.tar.xz drakx-48f444aaf23bb5fe4758d141a87456f256be179b.zip |
Added timeouts to network scan with "nmap" so that scan does not take
too long when there are machines running a firewall.
To find running machines in the network, do not only a broadcast ping
but also an "nmblookup" to also catch Windows machines which do not
answer to ping.
-rw-r--r-- | perl-install/printer.pm | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/perl-install/printer.pm b/perl-install/printer.pm index 3276f3314..ccb42a65e 100644 --- a/perl-install/printer.pm +++ b/perl-install/printer.pm @@ -460,14 +460,23 @@ sub getIPsInLocalNetworks { close(IFCONFIG_OUT); my @addresses; - # Now ping all broadcast addresses + # Now ping all broadcast addresses and additionally "nmblookup" the + # networks (to find Windows servers which do not answer to ping) for my $bcast (@local_bcasts) { local *F; open F, ($::testing ? "" : "chroot $prefix/ ") . - "/bin/sh -c \"export LC_ALL=C; ping -w 1 -b -n $bcast | cut -f 4 -d ' ' | sed s/:// | egrep '^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+' | uniq\" |" + "/bin/sh -c \"export LC_ALL=C; ping -w 1 -b -n $bcast | cut -f 4 -d ' ' | sed s/:// | egrep '^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+' | uniq | sort\" |" or next; while (<F>) { chomp; push @addresses, $_ } close F; + if (-x "/usr/bin/nmblookup") { + open F, ($::testing ? "" : "chroot $prefix/ ") . + "/bin/sh -c \"export LC_ALL=C; nmblookup -B $bcast \\* | cut -f 1 -d ' ' | egrep '^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+' | uniq | sort\" |" + or next; + while (<F>) { chomp; + push @addresses, $_ if !(member($_,@addresses)) } + close F; + } } @addresses; @@ -500,10 +509,11 @@ sub whatNetPrinter { return () if $#hostips < 0; my $hostlist = join (" ", @hostips); - # Scan network for printers + # Scan network for printers, the timeout settings are there to avoid + # delays caused by machines blocking their ports with a firewall local *F; open F, ($::testing ? "" : "chroot $prefix/ ") . - "/bin/sh -c \"export LC_ALL=C; nmap -r -P0 -p $portlist $hostlist\" |" + "/bin/sh -c \"export LC_ALL=C; nmap -r -P0 --host_timeout 400 --initial_rtt_timeout 200 -p $portlist $hostlist\" |" or return @res; my $host = ""; my $ip = ""; |