[oe-commits] Hongxu Jia : dhcp-client: fix invoke dhclient-script failed on Read-only file system

git at git.openembedded.org git at git.openembedded.org
Fri Mar 7 14:52:15 UTC 2014


Module: openembedded-core.git
Branch: master
Commit: df793f4356b411cbb92445c4559c9b21eb6d99fc
URL:    http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=df793f4356b411cbb92445c4559c9b21eb6d99fc

Author: Hongxu Jia <hongxu.jia at windriver.com>
Date:   Wed Mar  5 16:38:29 2014 +0800

dhcp-client: fix invoke dhclient-script failed on Read-only file system

In read-only file system, '/etc' is on the readonly partition,
and '/etc/resolv.conf' is symlinked to a separate writable
partition.

In this situation, we should use shell variable to instead of
the temp file '/etc/resolv.conf.dhclient'.

[YOCTO #5624]
Signed-off-by: Hongxu Jia <hongxu.jia at windriver.com>

Signed-off-by: Saul Wold <sgw at linux.intel.com>

---

 ...dhclient-script-drop-resolv.conf.dhclient.patch | 70 ++++++++++++++++++++++
 meta/recipes-connectivity/dhcp/dhcp_4.2.5-P1.bb    |  1 +
 2 files changed, 71 insertions(+)

diff --git a/meta/recipes-connectivity/dhcp/dhcp/dhclient-script-drop-resolv.conf.dhclient.patch b/meta/recipes-connectivity/dhcp/dhcp/dhclient-script-drop-resolv.conf.dhclient.patch
new file mode 100644
index 0000000..47ea555
--- /dev/null
+++ b/meta/recipes-connectivity/dhcp/dhcp/dhclient-script-drop-resolv.conf.dhclient.patch
@@ -0,0 +1,70 @@
+dhcp-client: fix invoke dhclient-script failed on Read-only file system
+
+In read-only file system, '/etc' is on the readonly partition,
+and '/etc/resolv.conf' is symlinked to a separate writable
+partition.
+
+In this situation, we should use shell variable to instead of
+temp files '/etc/resolv.conf.dhclient' and '/etc/resolv.conf.dhclient6'.
+
+Upstream-Status: Pending
+Signed-off-by: Hongxu Jia <hongxu.jia at windriver.com>
+---
+ client/scripts/linux | 20 +++++++++-----------
+ 1 file changed, 9 insertions(+), 11 deletions(-)
+
+diff --git a/client/scripts/linux b/client/scripts/linux
+--- a/client/scripts/linux
++++ b/client/scripts/linux
+@@ -27,27 +27,25 @@ ip=/sbin/ip
+ 
+ make_resolv_conf() {
+   if [ x"$new_domain_name_servers" != x ]; then
+-    cat /dev/null > /etc/resolv.conf.dhclient
+-    chmod 644 /etc/resolv.conf.dhclient
++    resolv_conf=""
+     if [ x"$new_domain_search" != x ]; then
+-      echo search $new_domain_search >> /etc/resolv.conf.dhclient
++      resolv_conf="search ${new_domain_search}\n"
+     elif [ x"$new_domain_name" != x ]; then
+       # Note that the DHCP 'Domain Name Option' is really just a domain
+       # name, and that this practice of using the domain name option as
+       # a search path is both nonstandard and deprecated.
+-      echo search $new_domain_name >> /etc/resolv.conf.dhclient
++      resolv_conf="search ${new_domain_name}\n"
+     fi
+     for nameserver in $new_domain_name_servers; do
+-      echo nameserver $nameserver >>/etc/resolv.conf.dhclient
++      resolv_conf="${resolv_conf}nameserver ${nameserver}\n"
+     done
+ 
+-    mv /etc/resolv.conf.dhclient /etc/resolv.conf
++    echo -e "${resolv_conf}" > /etc/resolv.conf
+   elif [ "x${new_dhcp6_name_servers}" != x ] ; then
+-    cat /dev/null > /etc/resolv.conf.dhclient6
+-    chmod 644 /etc/resolv.conf.dhclient6
++    resolv_conf=""
+ 
+     if [ "x${new_dhcp6_domain_search}" != x ] ; then
+-      echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6
++      resolv_conf="search ${new_dhcp6_domain_search}\n"
+     fi
+     shopt -s nocasematch 
+     for nameserver in ${new_dhcp6_name_servers} ; do
+@@ -59,11 +57,11 @@ make_resolv_conf() {
+       else
+ 	zone_id=
+       fi
+-      echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6
++      resolv_conf="${resolv_conf}nameserver ${nameserver}$zone_id\n"
+     done
+     shopt -u nocasematch 
+ 
+-    mv /etc/resolv.conf.dhclient6 /etc/resolv.conf
++    echo -e "${resolv_conf}" > /etc/resolv.conf
+   fi
+ }
+ 
+-- 
+1.8.1.2
+
diff --git a/meta/recipes-connectivity/dhcp/dhcp_4.2.5-P1.bb b/meta/recipes-connectivity/dhcp/dhcp_4.2.5-P1.bb
index 0c9f0db..77cdb4e 100644
--- a/meta/recipes-connectivity/dhcp/dhcp_4.2.5-P1.bb
+++ b/meta/recipes-connectivity/dhcp/dhcp_4.2.5-P1.bb
@@ -6,6 +6,7 @@ SRC_URI += "file://dhcp-3.0.3-dhclient-dbus.patch;striplevel=0 \
             file://fix-external-bind.patch \
             file://link-with-lcrypto.patch \
             file://fixsepbuild.patch \
+            file://dhclient-script-drop-resolv.conf.dhclient.patch \
            "
 
 SRC_URI[md5sum] = "f68e3c1f00a9af5742bc5e71d567cf93"



More information about the Openembedded-commits mailing list