From 153d56e9f939b4dd48e65d68074e72356a6223f4 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Thu, 20 Feb 2003 17:30:10 +0000 Subject: - read_resolv_conf() reads DOMAINNAME & DOMAINNAME2 - read_resolv_conf() reads /etc/resolv.conf by default - read_resolv_conf_raw() created --- perl-install/network/network.pm | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'perl-install/network') diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm index e8a331314..ab5e2c1ae 100644 --- a/perl-install/network/network.pm +++ b/perl-install/network/network.pm @@ -25,12 +25,21 @@ sub read_conf { +{ getVarsFromSh($file) }; } -sub read_resolv_conf { + +sub read_resolv_conf_raw { my ($file) = @_; - my @l = map { if_(/^\s*nameserver\s+(\S+)/, $1) } cat_($file); + $file ||= "$::prefix/etc/resolv.conf"; + { nameserver => [ cat_($file) =~ /^\s*nameserver\s+(\S+)/mg ], + search => [ cat_($file) =~ /^\s*search\s+(\S+)/mg ] }; +} - my %netc = mapn { $_[0] => $_[1] } [ qw(dnsServer dnsServer2 dnsServer3) ], \@l; - \%netc; +sub read_resolv_conf { + my ($file) = @_; + my $resolv_conf = read_resolv_conf_raw($file); + +{ + (mapn { $_[0] => $_[1] } [ qw(dnsServer dnsServer2 dnsServer3) ], $resolv_conf->{nameserver}), + (mapn { $_[0] => $_[1] } [ qw(DOMAINNAME DOMAINNAME2 DOMAINNAME3) ], $resolv_conf->{search}), + }; } sub read_interface_conf { @@ -74,8 +83,8 @@ sub write_conf { my ($file, $netc) = @_; if ($netc->{HOSTNAME}) { - $netc->{HOSTNAME} =~ /\.(.*)$/; - $1 and $netc->{DOMAINNAME} = $1; + $netc->{HOSTNAME} =~ /\.(.+)$/; + $netc->{DOMAINNAME} = $1; } ($netc->{DOMAINNAME}) ||= 'localdomain'; add2hash($netc, { @@ -84,7 +93,7 @@ sub write_conf { if_(!$netc->{DHCP}, HOSTNAME => "localhost.$netc->{DOMAINNAME}"), }); - setVarsInSh($file, $netc, if_(!$netc->{DHCP}, 'HOSTNAME'), qw(NETWORKING FORWARD_IPV4 DOMAINNAME GATEWAY GATEWAYDEV NISDOMAIN)); + setVarsInSh($file, $netc, if_(!$netc->{DHCP}, 'HOSTNAME'), qw(NETWORKING FORWARD_IPV4 GATEWAY GATEWAYDEV NISDOMAIN)); } sub write_zeroconf { @@ -451,7 +460,7 @@ sub read_all_conf { my ($prefix, $netc, $intf) = @_; $netc ||= {}; $intf ||= {}; add2hash($netc, read_conf("$prefix/etc/sysconfig/network")) if -r "$prefix/etc/sysconfig/network"; - add2hash($netc, read_resolv_conf("$prefix/etc/resolv.conf")) if -r "$prefix/etc/resolv.conf"; + add2hash($netc, read_resolv_conf()); add2hash($netc, read_tmdns_conf("$prefix/etc/tmdns.conf")) if -r "$prefix/etc/tmdns.conf"; foreach (all("$prefix/etc/sysconfig/network-scripts")) { if (/ifcfg-(\w+)/ && $1 ne 'lo') { -- cgit v1.2.1