Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/openresolv/dist Import openresolv-3.7.3 with th...



details:   https://anonhg.NetBSD.org/src/rev/1571f00cbcba
branches:  trunk
changeset: 343707:1571f00cbcba
user:      roy <roy%NetBSD.org@localhost>
date:      Mon Feb 22 10:07:26 2016 +0000

description:
Import openresolv-3.7.3 with the following changes:
  *  Save the initial working directory and change to it just before
     running any scripts.
     This avoids scripts putting files accidently where they shouldn't.
  *  Strip trailing dot from search and domain names.
  *  man page improvements.

diffstat:

 external/bsd/openresolv/dist/resolvconf.in |  29 ++++++++++++++++++++++++-----
 1 files changed, 24 insertions(+), 5 deletions(-)

diffs (75 lines):

diff -r 2657fad5ad44 -r 1571f00cbcba external/bsd/openresolv/dist/resolvconf.in
--- a/external/bsd/openresolv/dist/resolvconf.in        Mon Feb 22 08:06:47 2016 +0000
+++ b/external/bsd/openresolv/dist/resolvconf.in        Mon Feb 22 10:07:26 2016 +0000
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (c) 2007-2015 Roy Marples
+# Copyright (c) 2007-2016 Roy Marples
 # All rights reserved
 
 # Redistribution and use in source and binary forms, with or without
@@ -50,12 +50,12 @@
                interface_order="$(cat "$SYSCONFDIR"/interface-order)"
        fi
 fi
-TMPDIR="$VARDIR/tmp"
 IFACEDIR="$VARDIR/interfaces"
 METRICDIR="$VARDIR/metrics"
 PRIVATEDIR="$VARDIR/private"
 EXCLUSIVEDIR="$VARDIR/exclusive"
 LOCKDIR="$VARDIR/lock"
+_PWD="$PWD"
 
 warn()
 {
@@ -120,6 +120,21 @@
        IFS="$OIFS"
 }
 
+# Strip any trailing dot from each name as a FQDN does not belong
+# in resolv.conf(5)
+# If you think otherwise, capture a DNS trace and you'll see libc
+# will strip it regardless.
+# This also solves setting up duplicate zones in our subscribers.
+strip_trailing_dots()
+{
+       local n=
+
+       for n; do
+               printf "%s" "${n%.}"
+       done
+       printf "\n"
+}
+
 # Parse resolv.conf's and make variables
 # for domain name servers, search name servers and global nameservers
 parse_resolv()
@@ -163,14 +178,14 @@
                        $islocal || ns="$ns${line#* } "
                        ;;
                "domain "*)
+                       search="$(strip_trailing_dots ${line#* })"
                        if [ -z "$domain" ]; then
-                               domain="${line#* }"
+                               domain="$search"
                                echo "DOMAIN=\"$domain\""
                        fi
-                       search="${line#* }"
                        ;;
                "search "*)
-                       search="${line#* }"
+                       search="$(strip_trailing_dots ${line#* })"
                        ;;
                *)
                        [ -n "$line" ] && continue
@@ -753,6 +768,10 @@
 export RESOLVCONF DOMAINS SEARCH NAMESERVERS LOCALNAMESERVERS
 : ${list_resolv:=list_resolv -l}
 retval=0
+
+# Run scripts in the same directory resolvconf is run from
+# in case any scripts accidently dump files in the wrong place.
+cd "$_PWD"
 for script in "$LIBEXECDIR"/*; do
        if [ -f "$script" ]; then
                eval script_enabled="\$${script##*/}"



Home | Main Index | Thread Index | Old Index