[OE-core] [PATCH 2/2] dhclient-script: override make_resolv_conf for read-only fs
Hongxu Jia
hongxu.jia at windriver.com
Tue Dec 3 13:46:59 UTC 2013
When dhclient-script starts, the client script first defines a shell
function, make_resolv_conf , which is later used to create the
/etc/resolv.conf file.
But the read-only filesystem didn't permit the modification, so override
the default behaviour and redefine this function in the enter hook script.
http://linux.about.com/library/cmd/blcmdl8_dhclient-script.htm
[YOCTO #5624]
Signed-off-by: Hongxu Jia <hongxu.jia at windriver.com>
---
meta/recipes-connectivity/dhcp/dhcp.inc | 6 ++++-
.../dhcp/files/readonly-dhclient-enter-hooks | 31 ++++++++++++++++++++++
2 files changed, 36 insertions(+), 1 deletion(-)
create mode 100644 meta/recipes-connectivity/dhcp/files/readonly-dhclient-enter-hooks
diff --git a/meta/recipes-connectivity/dhcp/dhcp.inc b/meta/recipes-connectivity/dhcp/dhcp.inc
index d8376aa..58715be 100644
--- a/meta/recipes-connectivity/dhcp/dhcp.inc
+++ b/meta/recipes-connectivity/dhcp/dhcp.inc
@@ -16,6 +16,7 @@ SRC_URI = "ftp://ftp.isc.org/isc/dhcp/${PV}/dhcp-${PV}.tar.gz \
file://site.h \
file://init-relay file://default-relay \
file://init-server file://default-server \
+ file://readonly-dhclient-enter-hooks \
file://dhclient-script-let-resolv.conf-and-resolv.conf.dhcl.patch \
file://dhclient.conf file://dhcpd.conf"
@@ -52,6 +53,7 @@ do_install_append () {
mv ${D}${sbindir}/dhclient ${D}${base_sbindir}/
fi
install -m 0755 ${S}/client/scripts/linux ${D}${base_sbindir}/dhclient-script
+ install -m 0755 ${WORKDIR}/readonly-dhclient-enter-hooks ${D}${sysconfdir}/dhclient-enter-hooks
}
PACKAGES += "dhcp-server dhcp-server-config dhcp-client dhcp-relay dhcp-omshell"
@@ -67,7 +69,9 @@ FILES_dhcp-server-config = "${sysconfdir}/default/dhcp-server ${sysconfdir}/dhcp
FILES_dhcp-relay = "${sbindir}/dhcrelay ${sysconfdir}/init.d/dhcp-relay ${sysconfdir}/default/dhcp-relay"
-FILES_dhcp-client = "${base_sbindir}/dhclient ${base_sbindir}/dhclient-script ${sysconfdir}/dhcp/dhclient.conf"
+FILES_dhcp-client = "${base_sbindir}/dhclient ${base_sbindir}/dhclient-script ${sysconfdir}/dhcp/dhclient.conf \
+ ${sysconfdir}/dhclient-enter-hooks \
+"
RDEPENDS_dhcp-client = "bash"
FILES_dhcp-omshell = "${bindir}/omshell"
diff --git a/meta/recipes-connectivity/dhcp/files/readonly-dhclient-enter-hooks b/meta/recipes-connectivity/dhcp/files/readonly-dhclient-enter-hooks
new file mode 100644
index 0000000..c43e81f
--- /dev/null
+++ b/meta/recipes-connectivity/dhcp/files/readonly-dhclient-enter-hooks
@@ -0,0 +1,31 @@
+is_on_read_only_partition () {
+ FILE=$1
+ dir=`dirname $(readlink -f "$FILE")`
+ while true; do
+ if [ ! -d "$dir" ]; then
+ echo "ERROR: $dir is not a directory"
+ exit 1
+ else
+ for flag in `awk -v dir=$dir '{ if ($2 == dir) { print "FOUND"; split($4,FLAGS,",") } }; \
+ END { for (f in FLAGS) print FLAGS[f] }' < /proc/mounts`; do
+ [ "$flag" = "FOUND" ] && partition="read-write"
+ [ "$flag" = "ro" ] && { partition="read-only"; break; }
+ done
+ if [ "$dir" = "/" -o -n "$partition" ]; then
+ break
+ else
+ dir=`dirname $dir`
+ fi
+ fi
+ done
+ [ "$partition" = "read-only" ] && echo "yes" || echo "no"
+}
+
+# If resolv.conf on the readonly partition, we should override make_resolv_conf
+if [ `is_on_read_only_partition /etc/resolv.conf` = "no" ]; then
+ return
+fi
+
+make_resolv_conf(){
+ :
+}
--
1.8.1.2
More information about the Openembedded-core
mailing list