1 From eec0503cfc36f63d777f5cb3f2719cecedcb8468 Mon Sep 17 00:00:00 2001
2 From: Haris Okanovic <haris.okanovic@ni.com>
3 Date: Mon, 7 Jan 2019 13:22:09 -0600
4 Subject: [PATCH] Workaround busybox limitation in Linux dhclient-script
6 Busybox is a lightweight implementation of coreutils commonly used on
7 space-constrained embedded Linux distributions. It's implementation of
8 chown and chmod doesn't provide a "--reference" option added to
9 client/scripts/linux as of commit 9261cb14. This change works around
10 that limitation by using stat to read ownership and permissions flags
11 and simple chown/chmod calls supported in both coreutils and busybox.
13 modified: client/scripts/linux
15 Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
16 Upstream-Status: Pending [ISC-Bugs #48771]
18 client/scripts/linux | 17 +++++++++++++----
19 1 file changed, 13 insertions(+), 4 deletions(-)
21 diff --git a/client/scripts/linux b/client/scripts/linux
22 index 0c429697..2435a44b 100755
23 --- a/client/scripts/linux
24 +++ b/client/scripts/linux
26 # if your system holds ip tool in a non-standard location.
29 +chown_chmod_by_reference() {
30 + local reference_file="$1"
31 + local target_file="$2"
33 + local owner=$(stat -c "%u:%g" "$reference_file")
34 + local perm=$(stat -c "%a" "$reference_file")
36 + chown "$owner" "$target_file"
37 + chmod "$perm" "$target_file"
40 # update /etc/resolv.conf based on received values
41 # This updated version mostly follows Debian script by Andrew Pollock et al.
43 @@ -74,8 +85,7 @@ make_resolv_conf() {
46 if [ -f /etc/resolv.conf ]; then
47 - chown --reference=/etc/resolv.conf $new_resolv_conf
48 - chmod --reference=/etc/resolv.conf $new_resolv_conf
49 + chown_chmod_by_reference /etc/resolv.conf $new_resolv_conf
51 mv -f $new_resolv_conf /etc/resolv.conf
53 @@ -101,8 +111,7 @@ make_resolv_conf() {
56 if [ -f /etc/resolv.conf ]; then
57 - chown --reference=/etc/resolv.conf $new_resolv_conf
58 - chmod --reference=/etc/resolv.conf $new_resolv_conf
59 + chown_chmod_by_reference /etc/resolv.conf $new_resolv_conf
61 mv -f $new_resolv_conf /etc/resolv.conf