diff options
Diffstat (limited to 'external/bsd/openresolv/dist/libc.in')
| -rw-r--r-- | external/bsd/openresolv/dist/libc.in | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/external/bsd/openresolv/dist/libc.in b/external/bsd/openresolv/dist/libc.in index 2b291b7cee8..ebcbba1eb8b 100644 --- a/external/bsd/openresolv/dist/libc.in +++ b/external/bsd/openresolv/dist/libc.in @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (c) 2007-2020 Roy Marples +# Copyright (c) 2007-2023 Roy Marples # All rights reserved # libc subscriber for resolvconf @@ -94,6 +94,7 @@ elif [ -d "$SYSCONFDIR"/resolvconf ]; then fi fi : ${resolv_conf:=/etc/resolv.conf} +: ${resolv_conf_tmp:="$resolv_conf.$$.openresolv"} : ${libc_service:=nscd} : ${list_resolv:=@SBINDIR@/resolvconf -l} if [ "${resolv_conf_head-x}" = x ] && [ -f "$SYSCONFDIR"/resolv.conf.head ] @@ -107,7 +108,7 @@ fi backup=true signature="# Generated by resolvconf" - + uniqify() { result= @@ -226,8 +227,26 @@ if $backup; then fi fi -# Create our resolv.conf now -(umask 022; printf %s "$newconf" >"$resolv_conf") +# There are pros and cons for writing directly to resolv.conf +# instead of a temporary file and then moving it over. +# The default is to write to resolv.conf as it has the least +# issues and has been the long standing default behaviour. +case "${resolv_conf_mv:-NO}" in +[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) + # Protect against symlink attack, ensure new file does not exist + rm -f "$resolv_conf_tmp" + # Keep original file owner, group and mode + [ -r "$resolv_conf" ] && cp -p "$resolv_conf" "$resolv_conf_tmp" + # Create our resolv.conf now + if (umask 022; printf %s "$newconf" >"$resolv_conf_tmp"); then + mv "$resolv_conf_tmp" "$resolv_conf" + fi + ;; +*) + (umask 022; printf %s "$newconf" >"$resolv_conf") + ;; +esac + if [ -n "$libc_restart" ]; then eval $libc_restart elif [ -n "$RESTARTCMD" ]; then |
