From 0af9cba5559994d661b2f702caf68d33ae3bd3cf Mon Sep 17 00:00:00 2001 From: roy Date: Tue, 27 Jun 2023 17:07:53 +0000 Subject: Sync with openresolv-3.13.2 --- external/bsd/openresolv/dist/dnsmasq.in | 8 +++--- external/bsd/openresolv/dist/libc.in | 27 +++++++++++++++++--- external/bsd/openresolv/dist/named.in | 4 +-- external/bsd/openresolv/dist/pdnsd.in | 10 ++++---- external/bsd/openresolv/dist/resolvconf.8.in | 6 ++--- external/bsd/openresolv/dist/resolvconf.conf.5.in | 19 ++++++++++---- external/bsd/openresolv/dist/resolvconf.in | 30 +++++++++++++++++------ external/bsd/openresolv/dist/unbound.in | 10 ++++++-- 8 files changed, 81 insertions(+), 33 deletions(-) (limited to 'external') diff --git a/external/bsd/openresolv/dist/dnsmasq.in b/external/bsd/openresolv/dist/dnsmasq.in index 8014eed5721..ae33f094b64 100644 --- a/external/bsd/openresolv/dist/dnsmasq.in +++ b/external/bsd/openresolv/dist/dnsmasq.in @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (c) 2007-2020 Roy Marples +# Copyright (c) 2007-2023 Roy Marples # All rights reserved # dnsmasq subscriber for resolvconf @@ -105,7 +105,7 @@ for d in $DOMAINS; do empty=true continue fi - i=$(($i + 1)) + i=$((i + 1)) while [ ${#addr} -lt 4 ]; do addr="0${addr}" done @@ -118,7 +118,7 @@ for d in $DOMAINS; do fi done while [ $i != 8 ]; do - i=$(($i + 1)) + i=$((i + 1)) front="$front byte:0 byte:0" done front="${front}$back" @@ -151,7 +151,7 @@ else fi # Try to ensure that config dirs exist -if type config_mkdirs >/dev/null 2>&1; then +if command -v config_mkdirs >/dev/null 2>&1; then config_mkdirs "$dnsmasq_conf" "$dnsmasq_resolv" else @SBINDIR@/resolvconf -D "$dnsmasq_conf" "$dnsmasq_resolv" 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 diff --git a/external/bsd/openresolv/dist/named.in b/external/bsd/openresolv/dist/named.in index 3301896416b..978eb98eafa 100644 --- a/external/bsd/openresolv/dist/named.in +++ b/external/bsd/openresolv/dist/named.in @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (c) 2007-2020 Roy Marples +# Copyright (c) 2007-2023 Roy Marples # All rights reserved # named subscriber for resolvconf @@ -79,7 +79,7 @@ for d in $DOMAINS; do done # Try to ensure that config dirs exist -if type config_mkdirs >/dev/null 2>&1; then +if command -v config_mkdirs >/dev/null 2>&1; then config_mkdirs "$named_options" "$named_zones" else @SBINDIR@/resolvconf -D "$named_options" "$named_zones" diff --git a/external/bsd/openresolv/dist/pdnsd.in b/external/bsd/openresolv/dist/pdnsd.in index 2e8f6eb044b..149808c0966 100644 --- a/external/bsd/openresolv/dist/pdnsd.in +++ b/external/bsd/openresolv/dist/pdnsd.in @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (c) 2010-2020 Roy Marples +# Copyright (c) 2010-2023 Roy Marples # All rights reserved # pdnsd subscriber for resolvconf @@ -46,7 +46,7 @@ remove_markers() in_marker=0 shift; shift - if type sed >/dev/null 2>&1; then + if command -v sed >/dev/null 2>&1; then sed "/^$m1/,/^$m2/d" $@ else for x do @@ -66,9 +66,9 @@ remove_markers() change_file() { if [ -e "$1" ]; then - if type cmp >/dev/null 2>&1; then + if command -v cmp >/dev/null 2>&1; then cmp -s "$1" "$2" - elif type diff >/dev/null 2>&1; then + elif command -v diff >/dev/null 2>&1; then diff -q "$1" "$2" >/dev/null else # Hopefully we're only working on small text files ... @@ -88,7 +88,7 @@ newresolv="# Generated by resolvconf$NL" changed=false # Try to ensure that config dirs exist -if type config_mkdirs >/dev/null 2>&1; then +if command -v config_mkdirs >/dev/null 2>&1; then config_mkdirs "$pdnsd_resolv" "$pdnsd_conf" else @SBINDIR@/resolvconf -D "$pdnsd_resolv" "$pdnsd_conf" diff --git a/external/bsd/openresolv/dist/resolvconf.8.in b/external/bsd/openresolv/dist/resolvconf.8.in index 39020e9e425..b678c3c7f2a 100644 --- a/external/bsd/openresolv/dist/resolvconf.8.in +++ b/external/bsd/openresolv/dist/resolvconf.8.in @@ -1,4 +1,4 @@ -.\" Copyright (c) 2007-2020 Roy Marples +.\" Copyright (c) 2007-2023 Roy Marples .\" All rights reserved .\" .\" Redistribution and use in source and binary forms, with or without @@ -189,7 +189,7 @@ Echo the resolvconf version to .El .Pp .Nm -also has some commands designed to be used by it's subscribers and +also has some commands designed to be used by its subscribers and system startup:- .Bl -tag -width pattern_opt .It Fl I @@ -229,7 +229,7 @@ in the correct order. .Nm first processes interfaces from the .Sy interface_order -list, then interfaces without a metic and that match the +list, then interfaces without a metric and that match the .Sy dynamic_order list, then interfaces with a metric in order and finally the rest in the operating systems lexical order. diff --git a/external/bsd/openresolv/dist/resolvconf.conf.5.in b/external/bsd/openresolv/dist/resolvconf.conf.5.in index b36e8678233..6ccb6412595 100644 --- a/external/bsd/openresolv/dist/resolvconf.conf.5.in +++ b/external/bsd/openresolv/dist/resolvconf.conf.5.in @@ -1,4 +1,4 @@ -.\" Copyright (c) 2009-2020 Roy Marples +.\" Copyright (c) 2009-2023 Roy Marples .\" All rights reserved .\" .\" Redistribution and use in source and binary forms, with or without @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd October 1, 2020 +.Dd May 23, 2023 .Dt RESOLVCONF.CONF 5 .Os .Sh NAME @@ -134,7 +134,7 @@ search foo.org dead.beef nameserver 1.2.3.4 nameserver 2.3.4.5 .Ed -and this configuaration: +and this configuration: .Bd -compact -literal -offset indent replace="search/foo*/bar.com" replace="$replace nameserver/1.2.3.4/5.6.7.8" @@ -210,6 +210,12 @@ Prepend name servers to the dynamically generated list. Append search domains to the dynamically generated list. .It Sy prepend_search Prepend search domains to the dynamically generated list. +.It Sy resolv_conf_mv +Defaults to NO. +Defines if +.Pa /etc/resolv.conf +is updated by writing to a temporary file and then moving it +vs writing directly to it. .El .Sh SUBSCRIBER OPTIONS openresolv ships with subscribers for the name servers @@ -222,7 +228,7 @@ and Each subscriber can create configuration files which should be included in the subscribers main configuration file. .Pp -To disable a subscriber, simply set it's name to NO. +To disable a subscriber, simply set its name to NO. For example, to disable the libc subscriber you would set: .Bd -compact -literal -offset indent libc=NO @@ -322,6 +328,9 @@ forward-zones-file=/etc/pdns/recursor-zones.conf This file tells unbound about specific and global name servers. .It Sy unbound_insecure When set to YES, unbound marks the domains as insecure, thus ignoring DNSSEC. +.It Sy unbound_forward_zone_options +Options appended to each forward zone. +Each option should be separated by an embedded new line. .Pp Example resolvconf.conf for unbound: .Bd -compact -literal -offset indent @@ -385,4 +394,4 @@ Each distribution is a special snowflake and likes to name the same thing differently, namely the named service script. .Pp Please report them to -.Lk http://roy.marples.name/projects/openresolv +.Lk https://roy.marples.name/projects/openresolv diff --git a/external/bsd/openresolv/dist/resolvconf.in b/external/bsd/openresolv/dist/resolvconf.in index 198096b587d..aa77ffe6284 100644 --- a/external/bsd/openresolv/dist/resolvconf.in +++ b/external/bsd/openresolv/dist/resolvconf.in @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (c) 2007-2020 Roy Marples +# Copyright (c) 2007-2023 Roy Marples # All rights reserved # Redistribution and use in source and binary forms, with or without @@ -25,7 +25,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. RESOLVCONF="$0" -OPENRESOLV_VERSION="3.12.0" +OPENRESOLV_VERSION="3.13.2" SYSCONFDIR=@SYSCONFDIR@ LIBEXECDIR=@LIBEXECDIR@ VARDIR=@VARDIR@ @@ -158,7 +158,7 @@ private_iface() if [ -e "$PRIVATEDIR/$iface" ]; then return 0 fi - + for p in $private_interfaces; do case "$iface" in "$p"|"$p":*) return 0;; @@ -290,9 +290,9 @@ config_mkdirs() # With the advent of alternative init systems, it's possible to have # more than one installed. So we need to try and guess what one we're -# using unless overriden by configure. +# using unless overridden by configure. # Note that restarting a service is a last resort - the subscribers -# should make a reasonable attempt to reconfigre the service via some +# should make a reasonable attempt to reconfigure the service via some # method, normally SIGHUP. detect_init() { @@ -327,6 +327,12 @@ detect_init() then /usr/sbin/invoke-rc.d $1 restart fi' + elif [ -x /usr/bin/s6-rc ] && [ -x /usr/bin/s6-svc ]; then + RESTARTCMD=' + if s6-rc -a list | grep -qFx $1-srv + then + s6-svc -r /run/service/$1-srv + fi' elif [ -x /sbin/service ]; then # Old RedHat RCDIR=/etc/init.d @@ -367,6 +373,8 @@ detect_init() then /etc/rc.d/$1 restart fi' + elif [ -d /etc/dinit.d ] && command -v dinitctl >/dev/null 2>&1; then + RESTARTCMD='dinitctl --quiet restart --ignore-unstarted $1' else for x in /etc/init.d/rc.d /etc/rc.d /etc/init.d; do [ -d $x ] || continue @@ -432,6 +440,8 @@ list_resolv() cmd="$1" shift + pattern_specified="$1" + excl=false list= report=false @@ -462,7 +472,7 @@ list_resolv() # If we have an interface ordering list, then use that. # It works by just using pathname expansion in the interface directory. - if [ -n "$1" ]; then + if [ -n "$pattern_specified" ]; then list="$*" $force || report=true elif ! $excl; then @@ -515,7 +525,11 @@ list_resolv() fi cd "$IFACEDIR" - retval=1 + if $excl || [ -n "$pattern_specified" ]; then + retval=1 + else + retval=0 + fi for i in $(uniqify $list); do # Only list interfaces which we really have if ! [ -f "$i" ]; then @@ -542,7 +556,7 @@ list_resolv() fi done fi - + if [ "$cmd" = i ] || [ "$cmd" = "-i" ]; then printf %s "$i " else diff --git a/external/bsd/openresolv/dist/unbound.in b/external/bsd/openresolv/dist/unbound.in index bdb7766573c..5b01a015e85 100644 --- a/external/bsd/openresolv/dist/unbound.in +++ b/external/bsd/openresolv/dist/unbound.in @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (c) 2009-2020 Roy Marples +# Copyright (c) 2009-2023 Roy Marples # All rights reserved # unbound subscriber for resolvconf @@ -49,6 +49,9 @@ for d in $DOMAINS; do ;; esac newconf="$newconf${NL}forward-zone:$NL name: \"$dn\"$NL" + if [ -n "$unbound_forward_zone_options" ]; then + newconf="$newconf $unbound_forward_zone_options${NL}" + fi while [ -n "$ns" ]; do newconf="$newconf forward-addr: ${ns%%,*}$NL" [ "$ns" = "${ns#*,}" ] && break @@ -58,13 +61,16 @@ done if [ -n "$NAMESERVERS" ]; then newconf="$newconf${NL}forward-zone:$NL name: \".\"$NL" + if [ -n "$unbound_forward_zone_options" ]; then + newconf="$newconf $unbound_forward_zone_options${NL}" + fi for n in $NAMESERVERS; do newconf="$newconf forward-addr: $n$NL" done fi # Try to ensure that config dirs exist -if type config_mkdirs >/dev/null 2>&1; then +if command -v config_mkdirs >/dev/null 2>&1; then config_mkdirs "$unbound_conf" else @SBINDIR@/resolvconf -D "$unbound_conf" -- cgit