Mageia Bugzilla – Attachment 2537 Details for
Bug 207
can't mount NFS servers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
Updated NFS patch with nmap
bug207.patch (text/plain), 2.49 KB, created by
Derek Jennings
on 2012-07-09 13:48:35 CEST
(
hide
)
Description:
Updated NFS patch with nmap
Filename:
MIME Type:
Creator:
Derek Jennings
Created:
2012-07-09 13:48:35 CEST
Size:
2.49 KB
patch
obsolete
>--- /usr/lib/libDrakX/fs/remote/nfs.pm 2012-06-19 13:56:57.071976867 +0100 >+++ nfs.pm 2012-06-19 13:55:59.000000000 +0100 >@@ -5,6 +5,8 @@ > > use common; > use fs::remote; >+use Nmap::Parser; >+use network::tools; > use log; > > our @ISA = 'fs::remote'; >@@ -28,34 +30,48 @@ > > sub check { > my ($_class, $in) = @_; >- $in->do_pkgs->ensure_binary_is_installed('nfs-utils-clients', 'showmount') or return; >+ $in->do_pkgs->ensure_binary_is_installed('nfs-utils-clients', 'showmount', 'nmap') or return; > 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 |"); >+sub rfc1918 { >+ my $ip = shift; >+ my ($a,$b,$c,$d) = split(/\./,$ip); >+ if ( $a == 10 ) { return 1; } >+ if ( $a == 192 and $b == 168 ) { return 1; } >+ if ( $a == 172 and ($b <= 31 and $b >= 16 ) ) >+ { return 1; } >+ return 0; >+} > >- 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 $net; >+ 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]+)/) { >+ $net = network::tools::host_hex_to_dotted($2); >+ if ( rfc1918($net) and $3 eq '00000000') { push(@hosts,$net."/24") }; > } > } >+ >+ my $np = new Nmap::Parser; >+ #runs the nmap command on the local subnet >+ $np->parsescan('/usr/bin/nmap','-p 111 --open --system-dns',@hosts); >+ >+ for my $host ($np->all_hosts()){ >+ my $svc = $host->tcp_service(111); >+ my $ip = $host->addr; >+ print $ip."\n"; >+ 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-06-19 13:56:57.071976867 +0100 +++ nfs.pm 2012-06-19 13:55:59.000000000 +0100 @@ -5,6 +5,8 @@ use common; use fs::remote; +use Nmap::Parser; +use network::tools; use log; our @ISA = 'fs::remote'; @@ -28,34 +30,48 @@ sub check { my ($_class, $in) = @_; - $in->do_pkgs->ensure_binary_is_installed('nfs-utils-clients', 'showmount') or return; + $in->do_pkgs->ensure_binary_is_installed('nfs-utils-clients', 'showmount', 'nmap') or return; 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 |"); +sub rfc1918 { + my $ip = shift; + my ($a,$b,$c,$d) = split(/\./,$ip); + if ( $a == 10 ) { return 1; } + if ( $a == 192 and $b == 168 ) { return 1; } + if ( $a == 172 and ($b <= 31 and $b >= 16 ) ) + { return 1; } + return 0; +} - 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 $net; + 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]+)/) { + $net = network::tools::host_hex_to_dotted($2); + if ( rfc1918($net) and $3 eq '00000000') { push(@hosts,$net."/24") }; } } + + my $np = new Nmap::Parser; + #runs the nmap command on the local subnet + $np->parsescan('/usr/bin/nmap','-p 111 --open --system-dns',@hosts); + + for my $host ($np->all_hosts()){ + my $svc = $host->tcp_service(111); + my $ip = $host->addr; + print $ip."\n"; + 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