summaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity/dhcp/dhcp/dhclient-script-drop-resolv.conf.dhclient.patch
blob: 47ea5554b84a6e66cda68842923025ec464e5019 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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@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