[pkg-dhcp-devel] Bug#855949: dhclient-script patch - allow override of default /etc/resolv.conf path

Doug McLaggan djmclaggan at gmail.com
Thu Feb 23 17:54:58 UTC 2017


Package: isc-dhcp-client
Version: 4.3.5-3
Severity: minor
Tags: patch


By default the script dhclient-script.linux updates /etc/resolv.conf
with name servers received via DHCP.  As noted in bugs #681698 and
#688864, in some cases this is not the desired action.

Also noted in the reply to bug #681698, this can be solved by
redefining the make_resolv_conf() function in a custom hook.

In some cases the desired action is to perform exactly the same
function as make_resolv_conf(), but using a different file path for
resolv.conf (while leaving the default file /etc/resolv.conf
untouched).

Duplicating make_resolv_conf() in a custom hook means updates to this
function from package upgrades will not be carried over to the custom
hook.  A cleaner solution would be to allow a custom hook to simply
override the default location of resolv.conf if required.

This requires a very small change to the existing script and it would
be a useful addition to allow name server updates to be diverted away
from /etc/resolve.conf as requested in the two bugs referenced above.

This change is a minor update to the recently added fix for bug
#687337.  If no custom hook defines a path for resolv.conf the script
uses exactly the same default as before this change.

A patch file for this change is attached.

---

Patch summary:

[PATCH] Allow resolv.conf path to be set by custom hook

A custom hook in /etc/dhcp/dhclient-enter-hooks.d/ can now set the
path for the file which will receive name server updates from DHCP.
The default path is "/etc/resolv.conf".
---
 debian/dhclient-script.linux |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
-------------- next part --------------
From: Doug McLaggan <djmclaggan at gmail.com>
Date: Thu, 23 Feb 2017 14:33:35 +0000
Subject: [PATCH] Allow resolv.conf path to be set by custom hook

A custom hook in /etc/dhcp/dhclient-enter-hooks.d/ can now set the
path for the file which will receive name server updates from DHCP.
The default path is "/etc/resolv.conf".
---
 debian/dhclient-script.linux |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/debian/dhclient-script.linux b/debian/dhclient-script.linux
index 9b0d3f8..94cabf9 100644
--- a/debian/dhclient-script.linux
+++ b/debian/dhclient-script.linux
@@ -43,8 +43,10 @@ make_resolv_conf() {
     # DHCPv4
     if [ -n "$new_domain_search" ] || [ -n "$new_domain_name" ] ||
        [ -n "$new_domain_name_servers" ]; then
-        resolv_conf=$(readlink -f "/etc/resolv.conf" 2>/dev/null) ||
-            resolv_conf="/etc/resolv.conf"
+        if [ -z "$resolv_conf" ]; then
+            resolv_conf=$(readlink -f "/etc/resolv.conf" 2>/dev/null) ||
+                resolv_conf="/etc/resolv.conf"
+        fi
 
         new_resolv_conf="${resolv_conf}.dhclient-new.$$"
         wait_for_rw "$new_resolv_conf"
@@ -87,8 +89,10 @@ make_resolv_conf() {
         mv -f $new_resolv_conf $resolv_conf
     # DHCPv6
     elif [ -n "$new_dhcp6_domain_search" ] || [ -n "$new_dhcp6_name_servers" ]; then
-        resolv_conf=$(readlink -f "/etc/resolv.conf" 2>/dev/null) ||
-            resolv_conf="/etc/resolv.conf"
+        if [ -z "$resolv_conf" ]; then
+            resolv_conf=$(readlink -f "/etc/resolv.conf" 2>/dev/null) ||
+                resolv_conf="/etc/resolv.conf"
+        fi
 
         new_resolv_conf="${resolv_conf}.dhclient-new.$$"
         wait_for_rw "$new_resolv_conf"


More information about the pkg-dhcp-devel mailing list