diff options
author | Rolf Eike Beer <eb@emlix.com> | 2019-03-28 15:29:29 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-04-13 16:58:00 +0200 |
commit | 7180d9ed863e6ea350938b13384548f4f2617528 (patch) | |
tree | e6f7216d2219f243379796b72d52f3bf76e32b19 | |
parent | 0e7bd69bb58e0914f25e3543e6beb142a203738c (diff) | |
download | busybox-7180d9ed863e6ea350938b13384548f4f2617528.tar.gz |
examples/udhcp/simple.script: fix resolv.conf update if it is a dangling symlink
If /etc/resolv.conf is a symlink to a tmpfs and the actual file does not
already exist, "readlink -f" will not detect it as symlink. Explicitely check
for that condition before and touch the file, making the other code work as
intended.
Signed-off-by: Rolf Eike Beer <eb@emlix.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rwxr-xr-x | examples/udhcp/simple.script | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/examples/udhcp/simple.script b/examples/udhcp/simple.script index 44aa46ece..53974e6d6 100755 --- a/examples/udhcp/simple.script +++ b/examples/udhcp/simple.script @@ -55,6 +55,10 @@ case "$1" in echo "Recreating $RESOLV_CONF" # If the file is a symlink somewhere (like /etc/resolv.conf # pointing to /run/resolv.conf), make sure things work. + if test -L "$RESOLV_CONF"; then + # If it's a dangling symlink, try to create the target. + test -e "$RESOLV_CONF" || touch "$RESOLV_CONF" + fi realconf=$(readlink -f "$RESOLV_CONF" 2>/dev/null || echo "$RESOLV_CONF") tmpfile="$realconf-$$" > "$tmpfile" |