Mageia Bugzilla – Attachment 12072 Details for
Bug 11940
drakwizards dhcpd and dns only provide eth0 interface
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
IFCFG.pm patch
file_11940.txt (text/plain), 2.42 KB, created by
Nicolas Nicolas
on 2020-12-13 09:05:51 CET
(
hide
)
Description:
IFCFG.pm patch
Filename:
MIME Type:
Creator:
Nicolas Nicolas
Created:
2020-12-13 09:05:51 CET
Size:
2.42 KB
patch
obsolete
>--- IFCFG.pm.ori 2020-12-08 22:38:39.845952022 +0100 >+++ IFCFG.pm 2020-12-12 10:31:18.851843635 +0100 >@@ -31,15 +31,25 @@ > #!-f $file and die "no such $file"; > sub new { > my $self = {}; >- >- my $ifconfig = `LC_ALL=C /sbin/ifconfig -a`; >+my @network_masks = ("128.0.0.0","192.0.0.0","224.0.0.0","240.0.0.0","248.0.0.0","252.0.0.0","254.0.0.0","255.0.0.0","255.128.0.0","255.192.0.0","255.224.0.0","255.240.0.0","255.248.0.0","255.252.0.0","255.254.0.0","255.255.0.0","255.255.128.0","255.255.192.0","255.255.224.0","255.255.240.0","255.255.248.0","255.255.252.0","255.225.254.0","255.255.255.0","255.255.255.128","255.255.255.192","255.255.255.224","255.255.255.240","255.255.255.248","255.255.255.252","255.255.255.254","255.255.255.255"); >+ #my $ifconfig = `LC_ALL=C /sbin/ifconfig -a`; >+ my $ifconfig = `ip -ts -a -4 address | grep inet`; > my $device = 'NONE'; > foreach (split('\n', $ifconfig)) { >- my ($temp) = /(^eth[0-9]*:?[0-9]*)/; >+ my ($temp) = /(en?[osp]?[0-9]*?s?[0-9]*:?[0-9]*$)/; >+ print "temp: $temp\n"; > $device = $temp if defined $temp; >- my ($ip, $bcast, $netmask) = /\s*inet addr:([0-9\.]*)\s*Bcast:([0-9\.]*)\s*Mask:([0-9\.]*)/; >+ my ($mask) = /^\s*inet\s+\d+\.\d+\.\d+\.\d+\/(\d+)/; >+ my ($ip) = /^\s*inet\s+(\d+\.\d+\.\d+\.\d+)/; >+ my $netmask=$mask; >+ my ($bcast) = /\s*brd\s+(\d+\.\d+\.\d+\.\d+)/; >+ print "ip: $ip\n"; >+ print "netmask: $netmask\n"; >+ print "bcast: $bcast\n"; >+ print "final network mask : $network_masks[$netmask-1]\n"; >+ #my ($ip, $bcast, $netmask) = /\s*inet ([0-9\.]*)\/[0-3][0-9])/; > if (defined $ip && defined $bcast && defined $netmask) { >- $self->{itf}{$device} = { IPADDR => $ip, BROADCAST => $bcast, NETMASK => $netmask }; >+ $self->{itf}{$device} = { IPADDR => $ip, BROADCAST => $bcast, NETMASK => $network_masks[$netmask-1] }; > my %conf = getVarsFromSh("/etc/sysconfig/network-scripts/ifcfg-$device"); > $self->{itf}{$device}{$_} = $conf{$_} foreach 'BOOTPROTO'; > } >@@ -64,13 +74,16 @@ > > #- TODO : return the main interface > sub default_itf { >- "eth0"; >-} >+ my ($temp_defint)=`route | grep default | tr -s " " | cut -d " " -f8`; >+ $temp_defint =~ s/\n$//; >+ "$temp_defint"; >+ } > > sub itf_get { > my ($self, $key, $o_itf) = @_; > > $o_itf ||= default_itf(); >+ print "o_itf:$o_itf\n"; > exists $self->{itf}{$o_itf}{$key} or print "ERROR: no $key field in $o_itf hash\n"; > $self->{itf}{$o_itf}{$key}; > }
--- IFCFG.pm.ori 2020-12-08 22:38:39.845952022 +0100 +++ IFCFG.pm 2020-12-12 10:31:18.851843635 +0100 @@ -31,15 +31,25 @@ #!-f $file and die "no such $file"; sub new { my $self = {}; - - my $ifconfig = `LC_ALL=C /sbin/ifconfig -a`; +my @network_masks = ("128.0.0.0","192.0.0.0","224.0.0.0","240.0.0.0","248.0.0.0","252.0.0.0","254.0.0.0","255.0.0.0","255.128.0.0","255.192.0.0","255.224.0.0","255.240.0.0","255.248.0.0","255.252.0.0","255.254.0.0","255.255.0.0","255.255.128.0","255.255.192.0","255.255.224.0","255.255.240.0","255.255.248.0","255.255.252.0","255.225.254.0","255.255.255.0","255.255.255.128","255.255.255.192","255.255.255.224","255.255.255.240","255.255.255.248","255.255.255.252","255.255.255.254","255.255.255.255"); + #my $ifconfig = `LC_ALL=C /sbin/ifconfig -a`; + my $ifconfig = `ip -ts -a -4 address | grep inet`; my $device = 'NONE'; foreach (split('\n', $ifconfig)) { - my ($temp) = /(^eth[0-9]*:?[0-9]*)/; + my ($temp) = /(en?[osp]?[0-9]*?s?[0-9]*:?[0-9]*$)/; + print "temp: $temp\n"; $device = $temp if defined $temp; - my ($ip, $bcast, $netmask) = /\s*inet addr:([0-9\.]*)\s*Bcast:([0-9\.]*)\s*Mask:([0-9\.]*)/; + my ($mask) = /^\s*inet\s+\d+\.\d+\.\d+\.\d+\/(\d+)/; + my ($ip) = /^\s*inet\s+(\d+\.\d+\.\d+\.\d+)/; + my $netmask=$mask; + my ($bcast) = /\s*brd\s+(\d+\.\d+\.\d+\.\d+)/; + print "ip: $ip\n"; + print "netmask: $netmask\n"; + print "bcast: $bcast\n"; + print "final network mask : $network_masks[$netmask-1]\n"; + #my ($ip, $bcast, $netmask) = /\s*inet ([0-9\.]*)\/[0-3][0-9])/; if (defined $ip && defined $bcast && defined $netmask) { - $self->{itf}{$device} = { IPADDR => $ip, BROADCAST => $bcast, NETMASK => $netmask }; + $self->{itf}{$device} = { IPADDR => $ip, BROADCAST => $bcast, NETMASK => $network_masks[$netmask-1] }; my %conf = getVarsFromSh("/etc/sysconfig/network-scripts/ifcfg-$device"); $self->{itf}{$device}{$_} = $conf{$_} foreach 'BOOTPROTO'; } @@ -64,13 +74,16 @@ #- TODO : return the main interface sub default_itf { - "eth0"; -} + my ($temp_defint)=`route | grep default | tr -s " " | cut -d " " -f8`; + $temp_defint =~ s/\n$//; + "$temp_defint"; + } sub itf_get { my ($self, $key, $o_itf) = @_; $o_itf ||= default_itf(); + print "o_itf:$o_itf\n"; exists $self->{itf}{$o_itf}{$key} or print "ERROR: no $key field in $o_itf hash\n"; $self->{itf}{$o_itf}{$key}; }
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 11940
:
12071
| 12072