Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | dhcp-client: fix invoke dhclient-script failed on Read-only file system |
| 2 | |
| 3 | In read-only file system, '/etc' is on the readonly partition, |
| 4 | and '/etc/resolv.conf' is symlinked to a separate writable |
| 5 | partition. |
| 6 | |
| 7 | In this situation, we should use shell variable to instead of |
| 8 | temp files '/etc/resolv.conf.dhclient' and '/etc/resolv.conf.dhclient6'. |
| 9 | |
| 10 | Upstream-Status: Pending |
| 11 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> |
| 12 | --- |
| 13 | client/scripts/linux | 20 +++++++++----------- |
| 14 | 1 file changed, 9 insertions(+), 11 deletions(-) |
| 15 | |
| 16 | diff --git a/client/scripts/linux b/client/scripts/linux |
| 17 | --- a/client/scripts/linux |
| 18 | +++ b/client/scripts/linux |
| 19 | @@ -27,27 +27,25 @@ ip=/sbin/ip |
| 20 | |
| 21 | make_resolv_conf() { |
| 22 | if [ x"$new_domain_name_servers" != x ]; then |
| 23 | - cat /dev/null > /etc/resolv.conf.dhclient |
| 24 | - chmod 644 /etc/resolv.conf.dhclient |
| 25 | + resolv_conf="" |
| 26 | if [ x"$new_domain_search" != x ]; then |
| 27 | - echo search $new_domain_search >> /etc/resolv.conf.dhclient |
| 28 | + resolv_conf="search ${new_domain_search}\n" |
| 29 | elif [ x"$new_domain_name" != x ]; then |
| 30 | # Note that the DHCP 'Domain Name Option' is really just a domain |
| 31 | # name, and that this practice of using the domain name option as |
| 32 | # a search path is both nonstandard and deprecated. |
| 33 | - echo search $new_domain_name >> /etc/resolv.conf.dhclient |
| 34 | + resolv_conf="search ${new_domain_name}\n" |
| 35 | fi |
| 36 | for nameserver in $new_domain_name_servers; do |
| 37 | - echo nameserver $nameserver >>/etc/resolv.conf.dhclient |
| 38 | + resolv_conf="${resolv_conf}nameserver ${nameserver}\n" |
| 39 | done |
| 40 | |
| 41 | - mv /etc/resolv.conf.dhclient /etc/resolv.conf |
| 42 | + echo -e "${resolv_conf}" > /etc/resolv.conf |
| 43 | elif [ "x${new_dhcp6_name_servers}" != x ] ; then |
| 44 | - cat /dev/null > /etc/resolv.conf.dhclient6 |
| 45 | - chmod 644 /etc/resolv.conf.dhclient6 |
| 46 | + resolv_conf="" |
| 47 | |
| 48 | if [ "x${new_dhcp6_domain_search}" != x ] ; then |
| 49 | - echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6 |
| 50 | + resolv_conf="search ${new_dhcp6_domain_search}\n" |
| 51 | fi |
| 52 | shopt -s nocasematch |
| 53 | for nameserver in ${new_dhcp6_name_servers} ; do |
| 54 | @@ -59,11 +57,11 @@ make_resolv_conf() { |
| 55 | else |
| 56 | zone_id= |
| 57 | fi |
| 58 | - echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6 |
| 59 | + resolv_conf="${resolv_conf}nameserver ${nameserver}$zone_id\n" |
| 60 | done |
| 61 | shopt -u nocasematch |
| 62 | |
| 63 | - mv /etc/resolv.conf.dhclient6 /etc/resolv.conf |
| 64 | + echo -e "${resolv_conf}" > /etc/resolv.conf |
| 65 | fi |
| 66 | } |
| 67 | |
| 68 | -- |
| 69 | 1.8.1.2 |
| 70 | |