0001-workaround-busybox-limitation-in-linux-dhclient-script.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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
  5. Busybox is a lightweight implementation of coreutils commonly used on
  6. space-constrained embedded Linux distributions. It's implementation of
  7. chown and chmod doesn't provide a "--reference" option added to
  8. client/scripts/linux as of commit 9261cb14. This change works around
  9. that limitation by using stat to read ownership and permissions flags
  10. and simple chown/chmod calls supported in both coreutils and busybox.
  11. modified: client/scripts/linux
  12. Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
  13. Upstream-Status: Pending [ISC-Bugs #48771]
  14. ---
  15. client/scripts/linux | 17 +++++++++++++----
  16. 1 file changed, 13 insertions(+), 4 deletions(-)
  17. Index: dhcp-4.4.3/client/scripts/linux
  18. ===================================================================
  19. --- dhcp-4.4.3.orig/client/scripts/linux
  20. +++ dhcp-4.4.3/client/scripts/linux
  21. @@ -32,6 +32,17 @@
  22. # if your system holds ip tool in a non-standard location.
  23. ip=/sbin/ip
  24. +chown_chmod_by_reference() {
  25. + local reference_file="$1"
  26. + local target_file="$2"
  27. +
  28. + local owner=$(stat -c "%u:%g" "$reference_file")
  29. + local perm=$(stat -c "%a" "$reference_file")
  30. +
  31. + chown "$owner" "$target_file"
  32. + chmod "$perm" "$target_file"
  33. +}
  34. +
  35. # update /etc/resolv.conf based on received values
  36. # This updated version mostly follows Debian script by Andrew Pollock et al.
  37. make_resolv_conf() {
  38. @@ -74,8 +85,7 @@ make_resolv_conf() {
  39. fi
  40. if [ -f /etc/resolv.conf ]; then
  41. - chown --reference=/etc/resolv.conf $new_resolv_conf
  42. - chmod --reference=/etc/resolv.conf $new_resolv_conf
  43. + chown_chmod_by_reference /etc/resolv.conf $new_resolv_conf
  44. fi
  45. mv -f $new_resolv_conf /etc/resolv.conf
  46. # DHCPv6
  47. @@ -101,8 +111,7 @@ make_resolv_conf() {
  48. fi
  49. if [ -f /etc/resolv.conf ]; then
  50. - chown --reference=/etc/resolv.conf $new_resolv_conf
  51. - chmod --reference=/etc/resolv.conf $new_resolv_conf
  52. + chown_chmod_by_reference /etc/resolv.conf $new_resolv_conf
  53. fi
  54. mv -f $new_resolv_conf /etc/resolv.conf
  55. fi