diff options
author | Alex Harpin <development@landsofshadow.co.uk> | 2015-02-14 13:35:27 +0000 |
---|---|---|
committer | Alex Harpin <development@landsofshadow.co.uk> | 2015-02-14 13:45:51 +0000 |
commit | 6648f37a5895f259de2068504520f64f225c1899 (patch) | |
tree | 67ceb087a3fee1fe707eab8e5cf02b243568218d /scripts/system | |
parent | 24c99255b867e48ae3369a23f866951e8607fbbe (diff) | |
download | vyatta-cfg-system-6648f37a5895f259de2068504520f64f225c1899.tar.gz vyatta-cfg-system-6648f37a5895f259de2068504520f64f225c1899.zip |
vyatta-cfg-system: remove blank domain search and expand comment type
Tighten the checks for configured search domains to exclude adding
unnecessary blank domains and expand the comments added to
/etc/resolv.conf to indicate the source of the search domains.
Bug #486 http://bugzilla.vyos.net/show_bug.cgi?id=486
Diffstat (limited to 'scripts/system')
-rwxr-xr-x | scripts/system/vyatta_update_resolv.pl | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/scripts/system/vyatta_update_resolv.pl b/scripts/system/vyatta_update_resolv.pl index 4c54cfce..0dfa4bec 100755 --- a/scripts/system/vyatta_update_resolv.pl +++ b/scripts/system/vyatta_update_resolv.pl @@ -68,11 +68,14 @@ if ($dhclient_script == 0 && @search_domains > 0 && $domain_name && length($doma } my $search_domain_list = ''; +my $search_includes_system = 0; + foreach my $domain (@search_domains) { if (length($search_domain_list) > 0) { $search_domain_list .= ' '; } $search_domain_list .= $domain; + $search_includes_system = 1; } # add domain searches received from the dhcp client to those already in /etc/resolv.conf, as long as domain-name is not set in the CLI @@ -90,7 +93,10 @@ if (!defined($domain_name)) { my @dhcp_domains = split(/\s+/, $search_string, 2); my $dhcp_domain = $dhcp_domains[1]; chomp $dhcp_domain; - $search_domain_list .= ' ' . $dhcp_domain; + if (length($search_domain_list) > 0) { + $search_domain_list .= ' '; + } + $search_domain_list .= $dhcp_domain; $search_includes_dhcp = 1; } } @@ -100,10 +106,14 @@ if (!defined($domain_name)) { my $search = ''; if (length($search_domain_list) > 0) { my $source; - if ($search_includes_dhcp == 1) { - $source = "(system + dhcp)"; + if ($search_includes_system == 1) { + if ($search_includes_dhcp == 1) { + $source = "(system + dhcp)"; + } else { + $source = "(system)"; + } } else { - $source = "(system)"; + $source = "(dhcp)"; } $search = "#line generated by vyatta_update_resolv.pl $source\nsearch\t\t$search_domain_list\n"; } |