diff options
author | pfg <pfg@FreeBSD.org> | 2016-02-29 14:46:39 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2016-02-29 14:46:39 +0000 |
commit | 0f231ca03489f944c2825b461d215b34d43b9c4a (patch) | |
tree | b906a3b51ec000d02f5a1ea32fb9303c5c735405 /contrib/openresolv/resolvconf.in | |
parent | 6dd3382ff8741c8167dd44d3f94b1c162da3be3a (diff) | |
download | FreeBSD-src-0f231ca03489f944c2825b461d215b34d43b9c4a.zip FreeBSD-src-0f231ca03489f944c2825b461d215b34d43b9c4a.tar.gz |
MFV r296164:
Update openresolve to version 3.7.3 including:
* 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.
Relnotes: yes
Diffstat (limited to 'contrib/openresolv/resolvconf.in')
-rw-r--r-- | contrib/openresolv/resolvconf.in | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/contrib/openresolv/resolvconf.in b/contrib/openresolv/resolvconf.in index a946ed8..829321e 100644 --- a/contrib/openresolv/resolvconf.in +++ b/contrib/openresolv/resolvconf.in @@ -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 @@ -55,6 +55,7 @@ METRICDIR="$VARDIR/metrics" PRIVATEDIR="$VARDIR/private" EXCLUSIVEDIR="$VARDIR/exclusive" LOCKDIR="$VARDIR/lock" +_PWD="$PWD" warn() { @@ -119,6 +120,21 @@ echo_resolv() 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() @@ -162,14 +178,14 @@ parse_resolv() $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 @@ -752,6 +768,10 @@ eval "$(make_vars)" 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##*/}" |