Skip to contentSkip to conversation

dhcp: make dhclient to get configuration for other programs

PATCH In review Yi Zhao 2 participants 2 messages Sep 7, 2017 – Oct 4, 2017

lore
Share & tools
lore

Yi Zhao

author
#0 lore raw

PATCH 1/1 dhcp: make dhclient to get configuration for other programs

From: Li Wang <[email protected]>

Make dhclient to run /etc/dhcp/dhclient.d/*.sh, and get the configuration for ntp, nis or other programes

These codes are from redhat rpm package.

---
 .../dhcp/dhcp/dhcp-add-exec-script-function.patch  | 89 ++++++++++++++++++++++
 meta/recipes-connectivity/dhcp/dhcp_4.3.6.bb       |  1 +
 meta/recipes-connectivity/dhcp/files/dhclient.conf |  1 +
 3 files changed, 91 insertions(+)
 create mode 100644 meta/recipes-connectivity/dhcp/dhcp/dhcp-add-exec-script-function.patch
meta/recipes-connectivity/dhcp/dhcp/dhcp-add-exec-script-function.patch new file +89 -0
new file mode 100644
index 0000000..9cad643
@@ -0,0 +1,89 @@
+[PATCH] dhcp: add exec script function
+
+Make dhclient to run /etc/dhcp/dhclient.d/*.sh, and get the configuration
+for ntp, nis or other programes
+
+These codes are from redhat rpm packages.
+
+Upstream-Status: Backport [redhat]
+
+Signed-off-by: Li Wang <[email protected]>
+Signed-off-by: Roy Li <[email protected]>
+Signed-off-by: Yi Zhao <[email protected]>
+---
+ client/scripts/linux | 20 ++++++++++++++++++++
+ 1 file changed, 20 insertions(+)
+
+diff --git a/client/scripts/linux b/client/scripts/linux
+index 5fb1612..de15a70 100755
+--- a/client/scripts/linux
++++ b/client/scripts/linux
+@@ -31,6 +31,8 @@
+ # overwirte this line to use a fake ip-echo tool. It's also convenient
+ # if your system holds ip tool in a non-standard location.
+ ip=/sbin/ip
++ETCDIR="/etc/dhcp"
++export SAVEDIR=/var/lib/dhcp
+ 
+ # update /etc/resolv.conf based on received values
+ # This updated version mostly follows Debian script by Andrew Pollock et al.
+@@ -177,6 +179,19 @@ exit_with_hooks() {
+     exit $exit_status
+ }
+ 
++execute_client_side_configuration_scripts() {
++# execute any additional client side configuration scripts we have
++    if [ "${1}" == "config" ] || [ "${1}" == "restore" ]; then
++        for f in ${ETCDIR}/dhclient.d/*.sh ; do
++            if [ -x "${f}" ]; then
++                subsystem="${f%.sh}"
++                subsystem="${subsystem##*/}"
++                . "${f}"
++                "${subsystem}_${1}"
++            fi
++        done
++    fi
++}
+ 
+ # Invoke the local dhcp client enter hooks, if they exist.
+ run_hook /etc/dhclient-enter-hooks
+@@ -271,10 +286,12 @@ case "$reason" in
+ 
+         # update /etc/resolv.conf
+         make_resolv_conf
++        execute_client_side_configuration_scripts "config"
+ 
+         ;;
+ 
+     EXPIRE|FAIL|RELEASE|STOP)
++        execute_client_side_configuration_scripts "restore"
+         if [ -n "$alias_ip_address" ]; then
+             # flush alias IP
+             ${ip} -4 addr flush dev ${interface} label ${interface}:0
+@@ -411,6 +428,7 @@ case "$reason" in
+            [ "${new_dhcp6_domain_search}" != "${old_dhcp6_domain_search}" ]; then
+             make_resolv_conf
+         fi
++        execute_client_side_configuration_scripts "config"
+ 
+         ;;
+ 
+@@ -423,6 +441,7 @@ case "$reason" in
+         ${ip} -6 addr change ${cur_ip6_address}/${cur_ip6_prefixlen} \
+             dev ${interface} scope global preferred_lft 0
+ 
++        execute_client_side_configuration_scripts "config"
+         ;;
+ 
+     EXPIRE6|RELEASE6|STOP6)
+@@ -434,6 +453,7 @@ case "$reason" in
+         ${ip} -6 addr del ${old_ip6_address}/${old_ip6_prefixlen} \
+             dev ${interface}
+ 
++        execute_client_side_configuration_scripts "restore"
+         ;;
+ esac
+ 
+-- 
+2.7.4
+
meta/recipes-connectivity/dhcp/dhcp_4.3.6.bb +1 -0
index 4634a01..d3f8cc8 100644
@@ -11,6 +11,7 @@ SRC_URI += "file://0001-define-macro-_PATH_DHCPD_CONF-and-_PATH_DHCLIENT_CON.pat
             file://0009-remove-dhclient-script-bash-dependency.patch \
             file://0010-build-shared-libs.patch \
             file://0011-Moved-the-call-to-isc_app_ctxstart-to-not-get-signal.patch \
+            file://dhcp-add-exec-script-function.patch \
            "
 
 SRC_URI[md5sum] = "afa6e9b3eb7539ea048421a82c668adc"
meta/recipes-connectivity/dhcp/files/dhclient.conf +1 -0
index 0e6dcf9..0f7d42f 100644
@@ -17,6 +17,7 @@
 #supersede domain-name "fugue.com home.vix.com";
 #prepend domain-name-servers 127.0.0.1;
 request subnet-mask, broadcast-address, time-offset, routers,
+	nis-domain, nis-servers, domain-search, ntp-servers,
 	domain-name, domain-name-servers, host-name,
 	netbios-name-servers, netbios-scope;
 #require subnet-mask, domain-name-servers;
Signature · 1 line
2.7.4
#1 lore raw
Quoted 2 lines · Yi Zhao

+Upstream-Status: Backport [redhat]

Unless Redhat is upstream, this is not a backport.

Ross