From 292189d736fca81a4e9d908b074516932797d379 Mon Sep 17 00:00:00 2001 From: roy Date: Fri, 30 Dec 2016 19:42:05 +0000 Subject: [PATCH] Import openresolv-3.9.0 with the following changes: * Added --version option * Fix pdns_recursor restart command * Append a newline when restoring resolv.conf * public_interfaces overrides private interface markings * Fix runit support * inclusive_interfaces overrides exclusive interface markings --- external/bsd/openresolv/dist/libc.in | 2 +- external/bsd/openresolv/dist/resolvconf.in | 70 ++++++++++++++++------ 2 files changed, 53 insertions(+), 19 deletions(-) diff --git a/external/bsd/openresolv/dist/libc.in b/external/bsd/openresolv/dist/libc.in index aed7f7d0ff08..d49be65b67be 100644 --- a/external/bsd/openresolv/dist/libc.in +++ b/external/bsd/openresolv/dist/libc.in @@ -216,7 +216,7 @@ fi if $backup; then if [ "$newconf" = "$signature$NL" ]; then if [ -e "$resolv_conf.bak" ]; then - newconf="$(cat "$resolv_conf.bak")" + newconf="$(cat "$resolv_conf.bak")$NL" fi elif [ -e "$resolv_conf" ]; then read line <"$resolv_conf" diff --git a/external/bsd/openresolv/dist/resolvconf.in b/external/bsd/openresolv/dist/resolvconf.in index f77c13425bae..7353cfc348d1 100644 --- a/external/bsd/openresolv/dist/resolvconf.in +++ b/external/bsd/openresolv/dist/resolvconf.in @@ -25,13 +25,19 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. RESOLVCONF="$0" -OPENRESOLV_VERSION="3.8.0" +OPENRESOLV_VERSION="3.9.0" SYSCONFDIR=@SYSCONFDIR@ LIBEXECDIR=@LIBEXECDIR@ VARDIR=@VARDIR@ RCDIR=@RCDIR@ RESTARTCMD=@RESTARTCMD@ +if [ "$1" = "--version" ]; then + echo "openresolv $OPENRESOLV_VERSION" + echo "Copyright (c) 2007-2016 Roy Marples" + exit 0 +fi + # Disregard dhcpcd setting unset interface_order state_dir @@ -90,9 +96,10 @@ usage() that match the specified pattern -u Run updates from our current DNS information + --version Echo the ${RESOLVCONF##*/} version Options: - -f Ignore non existant interfaces + -f Ignore non existent interfaces -m metric Give the added DNS information a metric -p Mark the interface as private -x Mark the interface as exclusive @@ -129,6 +136,34 @@ strip_trailing_dots() printf "\n" } +private_iface() +{ + local p + + # Allow expansion + cd "$IFACEDIR" + + # Public interfaces override private ones. + for p in $public_interfaces; do + case "$iface" in + "$p"|"$p":*) return 1;; + esac + done + + if [ -e "$PRIVATEDIR/$iface" ]; then + return 0 + fi + + for p in $private_interfaces; do + case "$iface" in + "$p"|"$p":*) return 0;; + esac + done + + # Not a private interface + return 1 +} + # Parse resolv.conf's and make variables # for domain name servers, search name servers and global nameservers parse_resolv() @@ -144,17 +179,10 @@ parse_resolv() if ${new}; then iface="${line#\# resolv.conf from *}" new=false - if [ -e "$PRIVATEDIR/$iface" ]; then + if private_iface "$iface"; then private=true else - # Allow expansion - cd "$IFACEDIR" private=false - for p in $private_interfaces; do - case "$iface" in - "$p"|"$p":*) private=true; break;; - esac - done fi fi ;; @@ -270,11 +298,11 @@ detect_init() local status="@STATUSARG@" : ${status:=status} if [ -x /bin/systemctl -a -S /run/systemd/private ]; then - RESTARTCMD="if /bin/systemctl --quiet is-active; then + RESTARTCMD="if /bin/systemctl --quiet is-active \$1.service; then /bin/systemctl restart \$1.service; fi" elif [ -x /usr/bin/systemctl -a -S /run/systemd/private ]; then - RESTARTCMD="if /usr/bin/systemctl --quiet is-active; then + RESTARTCMD="if /usr/bin/systemctl --quiet is-active \$1.service; then /usr/bin/systemctl restart \$1.service; fi" elif [ -x /sbin/rc-service -a \ @@ -298,9 +326,9 @@ fi" /usr/sbin/service \$1 restart; fi" elif [ -x /bin/sv ]; then - RESTARTCMD="/bin/sv try-restart \$1" + RESTARTCMD="/bin/sv status \$1 >/dev/null 2>&1 && /bin/sv try-restart \$1" elif [ -x /usr/bin/sv ]; then - RESTARTCMD="/usr/bin/sv try-restart \$1" + RESTARTCMD="/usr/bin/sv status \$1 >/dev/null 2>&1 && /usr/bin/sv try-restart \$1" elif [ -e /etc/arch-release -a -d /etc/rc.d ]; then RCDIR=/etc/rc.d RESTARTCMD="if [ -e /var/run/daemons/\$1 ]; then @@ -375,6 +403,14 @@ list_resolv() done fi excl=true + cd "$IFACEDIR" + for i in $inclusive_interfaces; do + if [ -f "$i" -a "$list" = "$i" ]; then + list= + excl=false + break + fi + done ;; *) excl=false @@ -415,7 +451,6 @@ list_resolv() cd "$IFACEDIR" retval=1 - excl=true for i in $(uniqify $list); do # Only list interfaces which we really have if ! [ -f "$i" ]; then @@ -429,8 +464,7 @@ list_resolv() if [ "$cmd" = i -o "$cmd" = "-i" ]; then printf %s "$i " else - echo_resolv "$i" - echo + echo_resolv "$i" && echo fi [ $? = 0 -a "$retval" = 1 ] && retval=0 done @@ -884,7 +918,7 @@ export RESOLVCONF DOMAINS SEARCH NAMESERVERS LOCALNAMESERVERS retval=0 # Run scripts in the same directory resolvconf is run from -# in case any scripts accidently dump files in the wrong place. +# in case any scripts accidentally dump files in the wrong place. cd "$_PWD" for script in "$LIBEXECDIR"/*; do if [ -f "$script" ]; then