Mageia Bugzilla – Attachment 2779 Details for
Bug 207
can't mount NFS servers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
Revised nmap patch
bug207.patch (text/plain), 2.45 KB, created by
Derek Jennings
on 2012-09-10 15:12:56 CEST
(
hide
)
Description:
Revised nmap patch
Filename:
MIME Type:
Creator:
Derek Jennings
Created:
2012-09-10 15:12:56 CEST
Size:
2.45 KB
patch
obsolete
>--- /usr/lib/libDrakX/fs/remote/nfs.pm 2012-09-10 13:31:01.893544945 +0100 >+++ nfs.pm 2012-09-10 13:27:38.000000000 +0100 >@@ -5,6 +5,8 @@ > > use common; > use fs::remote; >+use Nmap::Parser; >+use network::tools; > use log; > > our @ISA = 'fs::remote'; >@@ -28,33 +30,40 @@ > > sub check { > my ($_class, $in) = @_; >- $in->do_pkgs->ensure_binary_is_installed('nfs-utils-clients', 'showmount') or return; >+ $in->do_pkgs->ensure_files_are_installed([ [ 'nfs-utils-clients' , '/usr/sbin/showmount' ] , [ 'nmap' , '/usr/bin/nmap' ] ]); > require services; >- services::start_not_running_service('portmap'); >+ services::start_not_running_service('rpcbind'); > services::start('nfs-common'); #- TODO: once nfs-common is fixed, it could use start_not_running_service() > 1; > } > >-sub find_servers { >- open(my $F2, "rpcinfo-flushed -b mountd 2 |"); >- open(my $F3, "rpcinfo-flushed -b mountd 3 |"); > >- common::nonblock($F2); >- common::nonblock($F3); >- my $domain = chomp_(`domainname`); >- my ($s, %servers); >- my $quit; >- while (!$quit) { >- $quit = 1; >- sleep 1; >- while ($s = <$F2> || <$F3>) { >- $quit = 0; >- my ($ip, $name) = $s =~ /(\S+)\s+(\S+)/ or log::explanations("bad line in rpcinfo output"), next; >- $name =~ s/\.$//; >- $domain && $name =~ s/\Q.$domain\E$// >- || $name =~ s/^([^.]*)\.local$/$1/; >- $servers{$ip} ||= { ip => $ip, if_($name ne '(unknown)', name => $name) }; >+sub find_servers { >+ my @hosts; >+ my %routes; >+ my @routes = cat_("/proc/net/route"); >+ @routes = reverse(@routes) if common::cmp_kernel_versions(c::kernel_version(), "2.6.39") >= 0; >+ foreach (@routes) { >+ if (/^(\S+)\s+([0-9A-F]+)\s+([0-9A-F]+)\s+[0-9A-F]+\s+\d+\s+\d+\s+(\d+)\s+([0-9A-F]+)/) { >+ my $net = network::tools::host_hex_to_dotted($2); >+ my $gateway = $3; >+# get the netmask in binary and remove leading zeros >+ my $mask = unpack('B*', pack('h*', $5)); >+ $mask =~ s/^0*//; >+ if ($gateway eq '00000000' && $net ne '169.254.0.0') { push(@hosts, $net . "/" . length($mask)) } > } >+ } >+ >+ my $np = new Nmap::Parser; >+ #runs the nmap command on the local subnet >+ $np->parsescan('/usr/bin/nmap', '-p 111 --open --system-dns',@hosts); >+ >+ foreach my $host ($np->all_hosts) { >+ my $svc = $host->tcp_service(111); >+ my $ip = $host->addr; >+ my $name = $host->hostname; >+ if ($name eq '(unknown)') { $name=$ip } >+ $servers{$ip} ||= { ip => $ip, name => $name }; > } > values %servers; > }
--- /usr/lib/libDrakX/fs/remote/nfs.pm 2012-09-10 13:31:01.893544945 +0100 +++ nfs.pm 2012-09-10 13:27:38.000000000 +0100 @@ -5,6 +5,8 @@ use common; use fs::remote; +use Nmap::Parser; +use network::tools; use log; our @ISA = 'fs::remote'; @@ -28,33 +30,40 @@ sub check { my ($_class, $in) = @_; - $in->do_pkgs->ensure_binary_is_installed('nfs-utils-clients', 'showmount') or return; + $in->do_pkgs->ensure_files_are_installed([ [ 'nfs-utils-clients' , '/usr/sbin/showmount' ] , [ 'nmap' , '/usr/bin/nmap' ] ]); require services; - services::start_not_running_service('portmap'); + services::start_not_running_service('rpcbind'); services::start('nfs-common'); #- TODO: once nfs-common is fixed, it could use start_not_running_service() 1; } -sub find_servers { - open(my $F2, "rpcinfo-flushed -b mountd 2 |"); - open(my $F3, "rpcinfo-flushed -b mountd 3 |"); - common::nonblock($F2); - common::nonblock($F3); - my $domain = chomp_(`domainname`); - my ($s, %servers); - my $quit; - while (!$quit) { - $quit = 1; - sleep 1; - while ($s = <$F2> || <$F3>) { - $quit = 0; - my ($ip, $name) = $s =~ /(\S+)\s+(\S+)/ or log::explanations("bad line in rpcinfo output"), next; - $name =~ s/\.$//; - $domain && $name =~ s/\Q.$domain\E$// - || $name =~ s/^([^.]*)\.local$/$1/; - $servers{$ip} ||= { ip => $ip, if_($name ne '(unknown)', name => $name) }; +sub find_servers { + my @hosts; + my %routes; + my @routes = cat_("/proc/net/route"); + @routes = reverse(@routes) if common::cmp_kernel_versions(c::kernel_version(), "2.6.39") >= 0; + foreach (@routes) { + if (/^(\S+)\s+([0-9A-F]+)\s+([0-9A-F]+)\s+[0-9A-F]+\s+\d+\s+\d+\s+(\d+)\s+([0-9A-F]+)/) { + my $net = network::tools::host_hex_to_dotted($2); + my $gateway = $3; +# get the netmask in binary and remove leading zeros + my $mask = unpack('B*', pack('h*', $5)); + $mask =~ s/^0*//; + if ($gateway eq '00000000' && $net ne '169.254.0.0') { push(@hosts, $net . "/" . length($mask)) } } + } + + my $np = new Nmap::Parser; + #runs the nmap command on the local subnet + $np->parsescan('/usr/bin/nmap', '-p 111 --open --system-dns',@hosts); + + foreach my $host ($np->all_hosts) { + my $svc = $host->tcp_service(111); + my $ip = $host->addr; + my $name = $host->hostname; + if ($name eq '(unknown)') { $name=$ip } + $servers{$ip} ||= { ip => $ip, name => $name }; } values %servers; }
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 207
:
2281
|
2282
|
2315
|
2475
|
2537
|
2779
|
3385