Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH V2 0/2] dhcp-client: fix invoke dhclient-script failed on Read-only file system
@ 2013-12-03 13:46 Hongxu Jia
  2013-12-03 13:46 ` [PATCH 1/2] dhclient-script: let resolv.conf and resolv.conf.dhclient on the same direcotry Hongxu Jia
  2013-12-03 13:46 ` [PATCH 2/2] dhclient-script: override make_resolv_conf for read-only fs Hongxu Jia
  0 siblings, 2 replies; 7+ messages in thread
From: Hongxu Jia @ 2013-12-03 13:46 UTC (permalink / raw)
  To: openembedded-core; +Cc: saul.wold

Change in V2:
* we should *never* check IMAGE_FEATURES in individual recipes.
  Two reasons:
  1) It may cause unnecessary rebuilds.
  2) IMAGE_FEATURES may be set in <image>.bb instead of local.conf.

* The make_resolv_conf function in that script doesn't take into
  consideration the situation in which /etc/resolv.conf is a symlink
  to /var/run/resolv.conf.

The following changes since commit a17ffbdbb7d142a94ef842a32b749b18e2e7f0a1:

  bitbake: hob: fix rotating progress icon animation (2013-12-02 17:51:35 +0000)

are available in the git repository at:

  git://git.pokylinux.org/poky-contrib hongxu/fix-dhcpclient
  http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=hongxu/fix-dhcpclient

Hongxu Jia (2):
  dhclient-script: let resolv.conf and resolv.conf.dhclient on the same
    direcotry
  dhclient-script: override make_resolv_conf for read-only fs

 meta/recipes-connectivity/dhcp/dhcp.inc            |  7 +-
 ...ript-let-resolv.conf-and-resolv.conf.dhcl.patch | 74 ++++++++++++++++++++++
 .../dhcp/files/readonly-dhclient-enter-hooks       | 31 +++++++++
 3 files changed, 111 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-connectivity/dhcp/dhcp/dhclient-script-let-resolv.conf-and-resolv.conf.dhcl.patch
 create mode 100644 meta/recipes-connectivity/dhcp/files/readonly-dhclient-enter-hooks

-- 
1.8.1.2



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] dhclient-script: let resolv.conf and resolv.conf.dhclient on the same direcotry
  2013-12-03 13:46 [PATCH V2 0/2] dhcp-client: fix invoke dhclient-script failed on Read-only file system Hongxu Jia
@ 2013-12-03 13:46 ` Hongxu Jia
  2013-12-03 22:09   ` Phil Blundell
  2013-12-10  4:41   ` Saul Wold
  2013-12-03 13:46 ` [PATCH 2/2] dhclient-script: override make_resolv_conf for read-only fs Hongxu Jia
  1 sibling, 2 replies; 7+ messages in thread
From: Hongxu Jia @ 2013-12-03 13:46 UTC (permalink / raw)
  To: openembedded-core; +Cc: saul.wold

Even though '/etc' is on the readonly partition, it's possible that
/etc/resolv.conf is on a separate writable partition.

In this situation, we should make sure the temp file resolv.conf.dhclient
on the same direcotry.

[YOCTO #5624]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 meta/recipes-connectivity/dhcp/dhcp.inc            |  1 +
 ...ript-let-resolv.conf-and-resolv.conf.dhcl.patch | 74 ++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 100644 meta/recipes-connectivity/dhcp/dhcp/dhclient-script-let-resolv.conf-and-resolv.conf.dhcl.patch

diff --git a/meta/recipes-connectivity/dhcp/dhcp.inc b/meta/recipes-connectivity/dhcp/dhcp.inc
index ad82b57..d8376aa 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://dhclient-script-let-resolv.conf-and-resolv.conf.dhcl.patch \
 	   file://dhclient.conf file://dhcpd.conf"
 
 inherit autotools
diff --git a/meta/recipes-connectivity/dhcp/dhcp/dhclient-script-let-resolv.conf-and-resolv.conf.dhcl.patch b/meta/recipes-connectivity/dhcp/dhcp/dhclient-script-let-resolv.conf-and-resolv.conf.dhcl.patch
new file mode 100644
index 0000000..db56f70
--- /dev/null
+++ b/meta/recipes-connectivity/dhcp/dhcp/dhclient-script-let-resolv.conf-and-resolv.conf.dhcl.patch
@@ -0,0 +1,74 @@
+dhclient-script: let resolv.conf and resolv.conf.dhclient on the same direcotry
+
+Even though '/etc' is on the readonly partition, it's possible that
+/etc/resolv.conf is on a separate writable partition.
+
+In this situation, we should make sure the temp file resolv.conf.dhclient
+on the same direcotry.
+
+Upstream-Status: Pending
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+---
+ client/scripts/linux |   24 +++++++++++++-----------
+ 1 file changed, 13 insertions(+), 11 deletions(-)
+
+diff --git a/client/scripts/linux b/client/scripts/linux
+index 6f8ea4b..fbc6324 100755
+--- a/client/scripts/linux
++++ b/client/scripts/linux
+@@ -27,27 +27,29 @@ 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
++    sysconfdir=`dirname $(readlink -f '/etc/resolv.conf')`
++    cat /dev/null > $sysconfdir/resolv.conf.dhclient
++    chmod 644 $sysconfdir/resolv.conf.dhclient
+     if [ x"$new_domain_search" != x ]; then
+-      echo search $new_domain_search >> /etc/resolv.conf.dhclient
++      echo search $new_domain_search >> $sysconfdir/esolv.conf.dhclient
+     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
++      echo search $new_domain_name >> $sysconfdir/resolv.conf.dhclient
+     fi
+     for nameserver in $new_domain_name_servers; do
+-      echo nameserver $nameserver >>/etc/resolv.conf.dhclient
++      echo nameserver $nameserver >>$sysconfdir/resolv.conf.dhclient
+     done
+ 
+-    mv /etc/resolv.conf.dhclient /etc/resolv.conf
++    mv $sysconfdir/resolv.conf.dhclient $sysconfdir/resolv.conf
+   elif [ "x${new_dhcp6_name_servers}" != x ] ; then
+-    cat /dev/null > /etc/resolv.conf.dhclient6
+-    chmod 644 /etc/resolv.conf.dhclient6
++    sysconfdir=`dirname $(readlink -f '/etc/resolv.conf')`
++    cat /dev/null > $sysconfdir/resolv.conf.dhclient6
++    chmod 644 $sysconfdir/resolv.conf.dhclient6
+ 
+     if [ "x${new_dhcp6_domain_search}" != x ] ; then
+-      echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6
++      echo search ${new_dhcp6_domain_search} >> $sysconfdir/resolv.conf.dhclient6
+     fi
+     shopt -s nocasematch 
+     for nameserver in ${new_dhcp6_name_servers} ; do
+@@ -59,11 +61,11 @@ make_resolv_conf() {
+       else
+ 	zone_id=
+       fi
+-      echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6
++      echo nameserver ${nameserver}$zone_id >> $sysconfdir/resolv.conf.dhclient6
+     done
+     shopt -u nocasematch 
+ 
+-    mv /etc/resolv.conf.dhclient6 /etc/resolv.conf
++    mv $sysconfdir/resolv.conf.dhclient6 $sysconfdir/resolv.conf
+   fi
+ }
+ 
+-- 
+1.7.9.5
+
-- 
1.8.1.2



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] dhclient-script: override make_resolv_conf for read-only fs
  2013-12-03 13:46 [PATCH V2 0/2] dhcp-client: fix invoke dhclient-script failed on Read-only file system Hongxu Jia
  2013-12-03 13:46 ` [PATCH 1/2] dhclient-script: let resolv.conf and resolv.conf.dhclient on the same direcotry Hongxu Jia
@ 2013-12-03 13:46 ` Hongxu Jia
  1 sibling, 0 replies; 7+ messages in thread
From: Hongxu Jia @ 2013-12-03 13:46 UTC (permalink / raw)
  To: openembedded-core; +Cc: saul.wold

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@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



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] dhclient-script: let resolv.conf and resolv.conf.dhclient on the same direcotry
  2013-12-03 13:46 ` [PATCH 1/2] dhclient-script: let resolv.conf and resolv.conf.dhclient on the same direcotry Hongxu Jia
@ 2013-12-03 22:09   ` Phil Blundell
  2013-12-04  2:00     ` Hongxu Jia
  2013-12-10  4:41   ` Saul Wold
  1 sibling, 1 reply; 7+ messages in thread
From: Phil Blundell @ 2013-12-03 22:09 UTC (permalink / raw)
  To: Hongxu Jia; +Cc: saul.wold, openembedded-core

On Tue, 2013-12-03 at 21:46 +0800, Hongxu Jia wrote:
> +-      echo search $new_domain_search >> /etc/resolv.conf.dhclient
> ++      echo search $new_domain_search >> $sysconfdir/esolv.conf.dhclient

Should that be "$sysconfdir/resolv.conf.dhclient"?

p.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] dhclient-script: let resolv.conf and resolv.conf.dhclient on the same direcotry
  2013-12-03 22:09   ` Phil Blundell
@ 2013-12-04  2:00     ` Hongxu Jia
  0 siblings, 0 replies; 7+ messages in thread
From: Hongxu Jia @ 2013-12-04  2:00 UTC (permalink / raw)
  To: Phil Blundell; +Cc: saul.wold, openembedded-core

On 12/04/2013 06:09 AM, Phil Blundell wrote:
> On Tue, 2013-12-03 at 21:46 +0800, Hongxu Jia wrote:
>> +-      echo search $new_domain_search >> /etc/resolv.conf.dhclient
>> ++      echo search $new_domain_search >> $sysconfdir/esolv.conf.dhclient
> Should that be "$sysconfdir/resolv.conf.dhclient"?

Yes, sorry for the missing, I have updated the git tree to fix this.

//Hongxu

> p.
>
>



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] dhclient-script: let resolv.conf and resolv.conf.dhclient on the same direcotry
  2013-12-03 13:46 ` [PATCH 1/2] dhclient-script: let resolv.conf and resolv.conf.dhclient on the same direcotry Hongxu Jia
  2013-12-03 22:09   ` Phil Blundell
@ 2013-12-10  4:41   ` Saul Wold
  2013-12-10 10:25     ` Hongxu Jia
  1 sibling, 1 reply; 7+ messages in thread
From: Saul Wold @ 2013-12-10  4:41 UTC (permalink / raw)
  To: Hongxu Jia, openembedded-core

On 12/03/2013 05:46 AM, Hongxu Jia wrote:
> Even though '/etc' is on the readonly partition, it's possible that
> /etc/resolv.conf is on a separate writable partition.
>
> In this situation, we should make sure the temp file resolv.conf.dhclient
> on the same direcotry.
>
> [YOCTO #5624]
>
> Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> ---
>   meta/recipes-connectivity/dhcp/dhcp.inc            |  1 +
>   ...ript-let-resolv.conf-and-resolv.conf.dhcl.patch | 74 ++++++++++++++++++++++

These new scripts are doing alot of out calling from the shell script, 
and can cause additional fork/execs during the critical path of system 
startup, is there any way to reduce this?

Sau!

>   2 files changed, 75 insertions(+)
>   create mode 100644 meta/recipes-connectivity/dhcp/dhcp/dhclient-script-let-resolv.conf-and-resolv.conf.dhcl.patch
>
> diff --git a/meta/recipes-connectivity/dhcp/dhcp.inc b/meta/recipes-connectivity/dhcp/dhcp.inc
> index ad82b57..d8376aa 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://dhclient-script-let-resolv.conf-and-resolv.conf.dhcl.patch \
>   	   file://dhclient.conf file://dhcpd.conf"
>
>   inherit autotools
> diff --git a/meta/recipes-connectivity/dhcp/dhcp/dhclient-script-let-resolv.conf-and-resolv.conf.dhcl.patch b/meta/recipes-connectivity/dhcp/dhcp/dhclient-script-let-resolv.conf-and-resolv.conf.dhcl.patch
> new file mode 100644
> index 0000000..db56f70
> --- /dev/null
> +++ b/meta/recipes-connectivity/dhcp/dhcp/dhclient-script-let-resolv.conf-and-resolv.conf.dhcl.patch
> @@ -0,0 +1,74 @@
> +dhclient-script: let resolv.conf and resolv.conf.dhclient on the same direcotry
> +
> +Even though '/etc' is on the readonly partition, it's possible that
> +/etc/resolv.conf is on a separate writable partition.
> +
> +In this situation, we should make sure the temp file resolv.conf.dhclient
> +on the same direcotry.
> +
> +Upstream-Status: Pending
> +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> +---
> + client/scripts/linux |   24 +++++++++++++-----------
> + 1 file changed, 13 insertions(+), 11 deletions(-)
> +
> +diff --git a/client/scripts/linux b/client/scripts/linux
> +index 6f8ea4b..fbc6324 100755
> +--- a/client/scripts/linux
> ++++ b/client/scripts/linux
> +@@ -27,27 +27,29 @@ 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
> ++    sysconfdir=`dirname $(readlink -f '/etc/resolv.conf')`
> ++    cat /dev/null > $sysconfdir/resolv.conf.dhclient
> ++    chmod 644 $sysconfdir/resolv.conf.dhclient
> +     if [ x"$new_domain_search" != x ]; then
> +-      echo search $new_domain_search >> /etc/resolv.conf.dhclient
> ++      echo search $new_domain_search >> $sysconfdir/esolv.conf.dhclient
> +     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
> ++      echo search $new_domain_name >> $sysconfdir/resolv.conf.dhclient
> +     fi
> +     for nameserver in $new_domain_name_servers; do
> +-      echo nameserver $nameserver >>/etc/resolv.conf.dhclient
> ++      echo nameserver $nameserver >>$sysconfdir/resolv.conf.dhclient
> +     done
> +
> +-    mv /etc/resolv.conf.dhclient /etc/resolv.conf
> ++    mv $sysconfdir/resolv.conf.dhclient $sysconfdir/resolv.conf
> +   elif [ "x${new_dhcp6_name_servers}" != x ] ; then
> +-    cat /dev/null > /etc/resolv.conf.dhclient6
> +-    chmod 644 /etc/resolv.conf.dhclient6
> ++    sysconfdir=`dirname $(readlink -f '/etc/resolv.conf')`
> ++    cat /dev/null > $sysconfdir/resolv.conf.dhclient6
> ++    chmod 644 $sysconfdir/resolv.conf.dhclient6
> +
> +     if [ "x${new_dhcp6_domain_search}" != x ] ; then
> +-      echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6
> ++      echo search ${new_dhcp6_domain_search} >> $sysconfdir/resolv.conf.dhclient6
> +     fi
> +     shopt -s nocasematch
> +     for nameserver in ${new_dhcp6_name_servers} ; do
> +@@ -59,11 +61,11 @@ make_resolv_conf() {
> +       else
> + 	zone_id=
> +       fi
> +-      echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6
> ++      echo nameserver ${nameserver}$zone_id >> $sysconfdir/resolv.conf.dhclient6
> +     done
> +     shopt -u nocasematch
> +
> +-    mv /etc/resolv.conf.dhclient6 /etc/resolv.conf
> ++    mv $sysconfdir/resolv.conf.dhclient6 $sysconfdir/resolv.conf
> +   fi
> + }
> +
> +--
> +1.7.9.5
> +
>



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] dhclient-script: let resolv.conf and resolv.conf.dhclient on the same direcotry
  2013-12-10  4:41   ` Saul Wold
@ 2013-12-10 10:25     ` Hongxu Jia
  0 siblings, 0 replies; 7+ messages in thread
From: Hongxu Jia @ 2013-12-10 10:25 UTC (permalink / raw)
  To: Saul Wold, openembedded-core

On 12/10/2013 12:41 PM, Saul Wold wrote:
> On 12/03/2013 05:46 AM, Hongxu Jia wrote:
>> Even though '/etc' is on the readonly partition, it's possible that
>> /etc/resolv.conf is on a separate writable partition.
>>
>> In this situation, we should make sure the temp file 
>> resolv.conf.dhclient
>> on the same direcotry.
>>
>> [YOCTO #5624]
>>
>> Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
>> ---
>>   meta/recipes-connectivity/dhcp/dhcp.inc            |  1 +
>>   ...ript-let-resolv.conf-and-resolv.conf.dhcl.patch | 74 
>> ++++++++++++++++++++++
>
> These new scripts are doing alot of out calling from the shell script, 
> and can cause additional fork/execs during the critical path of system 
> startup, is there any way to reduce this?
>

Do you mean the new script :readonly-dhclient-enter-hooks ?
If yes, we could just drop the [PATCH 2/2] patch and it could
work while read-only is enabled;

Because /etc/resolv.conf is a symlink to /var/run/ resolv.conf in
oe-core, and it's always writable:

#ls /etc/resolv.conf -al
lrwxrwxrwx 1 root root 29 Oct 22  2012 /etc/resolv.conf -> 
/var/run/resolv.conf

//Hongxu

> Sau!
>
>>   2 files changed, 75 insertions(+)
>>   create mode 100644 
>> meta/recipes-connectivity/dhcp/dhcp/dhclient-script-let-resolv.conf-and-resolv.conf.dhcl.patch
>>
>> diff --git a/meta/recipes-connectivity/dhcp/dhcp.inc 
>> b/meta/recipes-connectivity/dhcp/dhcp.inc
>> index ad82b57..d8376aa 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://dhclient-script-let-resolv.conf-and-resolv.conf.dhcl.patch \
>>          file://dhclient.conf file://dhcpd.conf"
>>
>>   inherit autotools
>> diff --git 
>> a/meta/recipes-connectivity/dhcp/dhcp/dhclient-script-let-resolv.conf-and-resolv.conf.dhcl.patch 
>> b/meta/recipes-connectivity/dhcp/dhcp/dhclient-script-let-resolv.conf-and-resolv.conf.dhcl.patch 
>>
>> new file mode 100644
>> index 0000000..db56f70
>> --- /dev/null
>> +++ 
>> b/meta/recipes-connectivity/dhcp/dhcp/dhclient-script-let-resolv.conf-and-resolv.conf.dhcl.patch
>> @@ -0,0 +1,74 @@
>> +dhclient-script: let resolv.conf and resolv.conf.dhclient on the 
>> same direcotry
>> +
>> +Even though '/etc' is on the readonly partition, it's possible that
>> +/etc/resolv.conf is on a separate writable partition.
>> +
>> +In this situation, we should make sure the temp file 
>> resolv.conf.dhclient
>> +on the same direcotry.
>> +
>> +Upstream-Status: Pending
>> +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
>> +---
>> + client/scripts/linux |   24 +++++++++++++-----------
>> + 1 file changed, 13 insertions(+), 11 deletions(-)
>> +
>> +diff --git a/client/scripts/linux b/client/scripts/linux
>> +index 6f8ea4b..fbc6324 100755
>> +--- a/client/scripts/linux
>> ++++ b/client/scripts/linux
>> +@@ -27,27 +27,29 @@ 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
>> ++    sysconfdir=`dirname $(readlink -f '/etc/resolv.conf')`
>> ++    cat /dev/null > $sysconfdir/resolv.conf.dhclient
>> ++    chmod 644 $sysconfdir/resolv.conf.dhclient
>> +     if [ x"$new_domain_search" != x ]; then
>> +-      echo search $new_domain_search >> /etc/resolv.conf.dhclient
>> ++      echo search $new_domain_search >> 
>> $sysconfdir/esolv.conf.dhclient
>> +     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
>> ++      echo search $new_domain_name >> $sysconfdir/resolv.conf.dhclient
>> +     fi
>> +     for nameserver in $new_domain_name_servers; do
>> +-      echo nameserver $nameserver >>/etc/resolv.conf.dhclient
>> ++      echo nameserver $nameserver >>$sysconfdir/resolv.conf.dhclient
>> +     done
>> +
>> +-    mv /etc/resolv.conf.dhclient /etc/resolv.conf
>> ++    mv $sysconfdir/resolv.conf.dhclient $sysconfdir/resolv.conf
>> +   elif [ "x${new_dhcp6_name_servers}" != x ] ; then
>> +-    cat /dev/null > /etc/resolv.conf.dhclient6
>> +-    chmod 644 /etc/resolv.conf.dhclient6
>> ++    sysconfdir=`dirname $(readlink -f '/etc/resolv.conf')`
>> ++    cat /dev/null > $sysconfdir/resolv.conf.dhclient6
>> ++    chmod 644 $sysconfdir/resolv.conf.dhclient6
>> +
>> +     if [ "x${new_dhcp6_domain_search}" != x ] ; then
>> +-      echo search ${new_dhcp6_domain_search} >> 
>> /etc/resolv.conf.dhclient6
>> ++      echo search ${new_dhcp6_domain_search} >> 
>> $sysconfdir/resolv.conf.dhclient6
>> +     fi
>> +     shopt -s nocasematch
>> +     for nameserver in ${new_dhcp6_name_servers} ; do
>> +@@ -59,11 +61,11 @@ make_resolv_conf() {
>> +       else
>> +     zone_id=
>> +       fi
>> +-      echo nameserver ${nameserver}$zone_id >> 
>> /etc/resolv.conf.dhclient6
>> ++      echo nameserver ${nameserver}$zone_id >> 
>> $sysconfdir/resolv.conf.dhclient6
>> +     done
>> +     shopt -u nocasematch
>> +
>> +-    mv /etc/resolv.conf.dhclient6 /etc/resolv.conf
>> ++    mv $sysconfdir/resolv.conf.dhclient6 $sysconfdir/resolv.conf
>> +   fi
>> + }
>> +
>> +--
>> +1.7.9.5
>> +
>>
>



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-12-10 10:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-03 13:46 [PATCH V2 0/2] dhcp-client: fix invoke dhclient-script failed on Read-only file system Hongxu Jia
2013-12-03 13:46 ` [PATCH 1/2] dhclient-script: let resolv.conf and resolv.conf.dhclient on the same direcotry Hongxu Jia
2013-12-03 22:09   ` Phil Blundell
2013-12-04  2:00     ` Hongxu Jia
2013-12-10  4:41   ` Saul Wold
2013-12-10 10:25     ` Hongxu Jia
2013-12-03 13:46 ` [PATCH 2/2] dhclient-script: override make_resolv_conf for read-only fs Hongxu Jia

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox