summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMarat Nepomnyashy <marat@vyatta.com>2007-12-26 16:51:13 -0800
committerMarat Nepomnyashy <marat@vyatta.com>2007-12-26 16:51:13 -0800
commitea4c396e33bf34cb8272daa2e1b2177a962cffb1 (patch)
treed579efec109e9a94bc435864532c5d16c940c861 /scripts
parentfa71dcd232351c123ac34dcd6622449f9193b0c5 (diff)
downloadvyatta-cfg-system-ea4c396e33bf34cb8272daa2e1b2177a962cffb1.tar.gz
vyatta-cfg-system-ea4c396e33bf34cb8272daa2e1b2177a962cffb1.zip
Treat 'system domain-name $(@)' and 'system domain-search domain $(@)' as mutually exclusive. Generate an error message and refuse commit if both are specified. Bug 2256 fix.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/system/vyatta_update_resolv.pl30
1 files changed, 27 insertions, 3 deletions
diff --git a/scripts/system/vyatta_update_resolv.pl b/scripts/system/vyatta_update_resolv.pl
index 0255b256..a8d05cfd 100755
--- a/scripts/system/vyatta_update_resolv.pl
+++ b/scripts/system/vyatta_update_resolv.pl
@@ -47,9 +47,18 @@ if ($modify_dir ne '') {
}
+$vc->setLevel('system');
+
+my @domains = $vc->returnValues('domain-search domain');
+my $domain_name = $vc->returnValue('domain-name');
+
+if (@domains > 0 && $domain_name && length($domain_name) > 0) {
+ print STDERR "System configuration error. Both \'domain-name\' and \'domain-search\' are specified, but only one of these mutually exclusive parameters is allowed.\n";
+ print STDERR "System configuration commit aborted due to error(s).\n";
+ exit(1);
+}
+
my $doms = '';
-$vc->setLevel('system domain-search domain');
-my @domains = $vc->returnValues('.');
foreach my $domain (@domains) {
if (length($doms) > 0) {
$doms .= ' ';
@@ -62,9 +71,15 @@ if (length($doms) > 0) {
$search = "search\t\t$doms\t\t#line generated by $0\n";
}
+my $domain = '';
+if ($domain_name && length($domain_name) > 0) {
+ $domain = "domain\t\t$domain_name\t\t#line generated by $0\n";
+}
+
# The following will re-write '/etc/resolv.conf' line by line,
-# replacing the 'search' specifier with the latest values.
+# replacing the 'search' specifier with the latest values,
+# or replacing the 'domain' specifier with the latest value.
my @resolv;
if (-e '/etc/resolv.conf') {
@@ -75,6 +90,7 @@ if (-e '/etc/resolv.conf') {
my $foundSearch = 0;
+my $foundDomain = 0;
open (RESOLV, '>/etc/resolv.conf') or die("$0: Error! Unable to open '/etc/resolv.conf' for output: $!\n");
foreach my $line (@resolv) {
@@ -83,6 +99,11 @@ foreach my $line (@resolv) {
if (length($search) > 0) {
print RESOLV $search;
}
+ } elsif ($line =~ /^domain\s/) {
+ $foundDomain = 1;
+ if (length($domain) > 0) {
+ print RESOLV $domain;
+ }
} else {
print RESOLV $line;
}
@@ -90,6 +111,9 @@ foreach my $line (@resolv) {
if ($foundSearch == 0 && length($search) > 0) {
print RESOLV $search;
}
+if ($foundDomain == 0 && length($domain) > 0) {
+ print RESOLV $domain;
+}
close (RESOLV);