diff options
author | Alex Harpin <development@landsofshadow.co.uk> | 2014-09-14 10:36:20 +0100 |
---|---|---|
committer | Alex Harpin <development@landsofshadow.co.uk> | 2014-09-14 10:36:20 +0100 |
commit | d69939edb20d357d096d60d15dde41ddc0a03aba (patch) | |
tree | ad0955e85ab5061719e67c480f9f9eeaaa5e4f9a | |
parent | d5585c36ec524898cd736fb039aad167eee5c6ab (diff) | |
download | vyatta-cfg-system-d69939edb20d357d096d60d15dde41ddc0a03aba.tar.gz vyatta-cfg-system-d69939edb20d357d096d60d15dde41ddc0a03aba.zip |
vyatta-cfg-system: rename allow-dhcp-nameservers and change to typeless
Rename allow-dhcp-nameservers to disable-dhcp-nameservers and update
the logic to take the new meaning into account. The option is now also
typeless, so the node is either absent (default) or present (enabled).
Format 'set / delete system disable-dhcp-nameservers'
Linked to Bug #182 and Bug #308
Bug #314 http://bugzilla.vyos.net/show_bug.cgi?id=314
-rwxr-xr-x | scripts/system/vyatta_update_resolv.pl | 19 | ||||
-rw-r--r-- | templates/system/allow-dhcp-nameservers/node.def | 7 | ||||
-rw-r--r-- | templates/system/disable-dhcp-nameservers/node.def | 5 |
3 files changed, 15 insertions, 16 deletions
diff --git a/scripts/system/vyatta_update_resolv.pl b/scripts/system/vyatta_update_resolv.pl index f193fd96..921052f0 100755 --- a/scripts/system/vyatta_update_resolv.pl +++ b/scripts/system/vyatta_update_resolv.pl @@ -39,12 +39,12 @@ $vc->setLevel('system'); my @domains; my $domain_name = undef; -my $allow_dhcp_nameservers = ''; +my $disable_dhcp_nameservers = undef; if ($config_mode == 1) { - $allow_dhcp_nameservers = $vc->returnValue('allow-dhcp-nameservers'); + $disable_dhcp_nameservers = $vc->exists('disable-dhcp-nameservers'); } else { - $allow_dhcp_nameservers = $vc->returnOrigValue('allow-dhcp-nameservers'); + $disable_dhcp_nameservers = $vc->existsOrig('disable-dhcp-nameservers'); } if ($dhclient_script == 1) { @@ -105,14 +105,14 @@ if ($domain_name && length($domain_name) > 0) { } # update /etc/resolv.conf with name-servers received from dhcp client, done when this script is called -# with either the dhclient-script (on DHCP changes) or config-mode (allow-dhcp-nameservers) options. +# with either the dhclient-script (on DHCP changes) or config-mode (disable-dhcp-nameservers) options. if (($dhclient_script == 1) || ($config_mode == 1)) { my @current_dhcp_nameservers; my $restart_ntp = 0; - # code below to add new name-servers received from dhcp client, but only if allow-dhcp-nameservers - # is set to true (default) + # code below to add new name-servers received from dhcp client, but only if disable-dhcp-nameservers + # hasn't been enabled. my @dhcp_interfaces_resolv_files = `ls /etc/ | grep resolv.conf.dhclient-new`; if ($#dhcp_interfaces_resolv_files >= 0) { @@ -140,7 +140,7 @@ if (($dhclient_script == 1) || ($config_mode == 1)) { } } } - if (($ns_in_resolvconf == 0) && ($allow_dhcp_nameservers eq "true")) { + if (($ns_in_resolvconf == 0) && !($disable_dhcp_nameservers)) { open (my $rf, '>>', '/etc/resolv.conf') or die "$! error trying to overwrite"; print $rf "nameserver\t$ns\t\t#nameserver written by $0\n"; @@ -153,7 +153,8 @@ if (($dhclient_script == 1) || ($config_mode == 1)) { } # code below to remove old name-servers from /etc/resolv.conf that were not received in this response - # from dhcp-server, or to remove previous dhcp supplied name-servers if allow-dhcp-nameservers is false + # from dhcp-server, or to remove previous dhcp supplied name-servers if disable-dhcp-nameservers has + # been enabled. my @nameservers_dhcp_in_resolvconf = `grep 'nameserver written' /etc/resolv.conf`; my @dhcp_nameservers_in_resolvconf; @@ -163,7 +164,7 @@ if (($dhclient_script == 1) || ($config_mode == 1)) { $dhcp_nameservers_in_resolvconf[$count_nameservers_in_resolvconf] = $dhcp_nameserver[1]; $count_nameservers_in_resolvconf++; } - if (($#current_dhcp_nameservers < 0) || ($allow_dhcp_nameservers eq "false")) { + if (($#current_dhcp_nameservers < 0) || ($disable_dhcp_nameservers)) { for my $dhcpnameserver (@dhcp_nameservers_in_resolvconf) { my $cmd = "sed -i '/$dhcpnameserver\t/d' /etc/resolv.conf"; system($cmd); diff --git a/templates/system/allow-dhcp-nameservers/node.def b/templates/system/allow-dhcp-nameservers/node.def deleted file mode 100644 index 442e003f..00000000 --- a/templates/system/allow-dhcp-nameservers/node.def +++ /dev/null @@ -1,7 +0,0 @@ -priority: 300 -type: bool -help: Allow DHCP to update DNS settings -default: true - -update: sudo /opt/vyatta/sbin/vyatta_update_resolv.pl --config-mode 1 -delete: sudo /opt/vyatta/sbin/vyatta_update_resolv.pl --config-mode 1
\ No newline at end of file diff --git a/templates/system/disable-dhcp-nameservers/node.def b/templates/system/disable-dhcp-nameservers/node.def new file mode 100644 index 00000000..adf84948 --- /dev/null +++ b/templates/system/disable-dhcp-nameservers/node.def @@ -0,0 +1,5 @@ +priority: 300 +help: Disable DHCP updates of DNS settings + +create: sudo /opt/vyatta/sbin/vyatta_update_resolv.pl --config-mode 1 +delete: sudo /opt/vyatta/sbin/vyatta_update_resolv.pl --config-mode 1 |