Patchwork [1/2] dhclient-script: let resolv.conf and resolv.conf.dhclient on the same direcotry

login
register
mail settings
Submitter Hongxu Jia
Date Dec. 3, 2013, 1:46 p.m.
Message ID <ae7e0f907b72ad9af0a078bdf317a7eb10315c7f.1386078157.git.hongxu.jia@windriver.com>
Download mbox | patch
Permalink /patch/62727/
State New
Headers show

Comments

Hongxu Jia - Dec. 3, 2013, 1:46 p.m.
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
Phil Blundell - Dec. 3, 2013, 10:09 p.m.
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.
Hongxu Jia - Dec. 4, 2013, 2 a.m.
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.
>
>
Saul Wold - Dec. 10, 2013, 4:41 a.m.
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
> +
>
Hongxu Jia - Dec. 10, 2013, 10:25 a.m.
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
>> +
>>
>

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
+