From 8896340fc868fc6338a7e1ded1a45793aaafd1a8 Mon Sep 17 00:00:00 2001 From: Mohit Mehta Date: Fri, 27 Jun 2008 03:12:09 +0000 Subject: better detection of whether domain-name set using CLI is overriding domain-search received from dhcp client. used in 'show dhcp client leases' --- scripts/vyatta-show-dhclient.pl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/vyatta-show-dhclient.pl b/scripts/vyatta-show-dhclient.pl index a158598..0f3990b 100755 --- a/scripts/vyatta-show-dhclient.pl +++ b/scripts/vyatta-show-dhclient.pl @@ -124,7 +124,20 @@ sub dhclient_show_lease { print "subnet mask: $new_subnet_mask\n" if defined $new_subnet_mask; if (defined $new_domain_name) { print "domain name: $new_domain_name"; - if (`grep domain /etc/resolv.conf 2> /dev/null`) { + my $cli_domain_overrides = 0; + my $if_domain_exists = `grep domain /etc/resolv.conf 2> /dev/null | wc -l`; + if ($if_domain_exists > 0) { + my @domain = `grep domain /etc/resolv.conf`; + for my $each_domain_text_found (@domain) { + my @domain_text_split = split(/\t/, $each_domain_text_found, 2); + my $domain_at_start_of_line = $domain_text_split[0]; + chomp $domain_at_start_of_line; + if ($domain_at_start_of_line eq "domain") { + $cli_domain_overrides = 1; + } + } + } + if ($cli_domain_overrides == 1) { print "\t[overridden by domain-name set using CLI]\n"; } else { print "\n"; -- cgit v1.2.3