diff options
author | Alex Harpin <development@landsofshadow.co.uk> | 2015-02-14 13:35:27 +0000 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2015-04-07 02:11:53 +0200 |
commit | 9bb3ef695a5a0f8e206b489467a1958fe5fc495e (patch) | |
tree | 32dff94771b705d823cdc0b766855d1d3a9e97f1 | |
parent | 82d58c7b45fc113a056e42854cba26b8ecff2d45 (diff) | |
download | vyatta-cfg-system-9bb3ef695a5a0f8e206b489467a1958fe5fc495e.tar.gz vyatta-cfg-system-9bb3ef695a5a0f8e206b489467a1958fe5fc495e.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
-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"; } |