Module Name:    src
Committed By:   roy
Date:           Sun Dec 27 18:26:50 UTC 2020

Modified Files:
        src/external/bsd/openresolv/dist: resolvconf.8.in resolvconf.conf.5.in
            resolvconf.in

Log Message:
Sync with openresolv-3.12.0


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/external/bsd/openresolv/dist/resolvconf.8.in
cvs rdiff -u -r1.20 -r1.21 \
    src/external/bsd/openresolv/dist/resolvconf.conf.5.in
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/openresolv/dist/resolvconf.in

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/openresolv/dist/resolvconf.8.in
diff -u src/external/bsd/openresolv/dist/resolvconf.8.in:1.10 src/external/bsd/openresolv/dist/resolvconf.8.in:1.11
--- src/external/bsd/openresolv/dist/resolvconf.8.in:1.10	Mon Jan 27 21:13:05 2020
+++ src/external/bsd/openresolv/dist/resolvconf.8.in	Sun Dec 27 18:26:50 2020
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd November 29, 2016
+.Dd December 23, 2016
 .Dt RESOLVCONF 8
 .Os
 .Sh NAME
@@ -38,6 +38,10 @@
 .Fl a Ar interface Ns Op Ar .protocol
 .No < Ns Pa file
 .Nm
+.Fl C Ar pattern
+.Nm
+.Fl c Ar pattern
+.Nm
 .Op Fl f
 .Fl d Ar interface Ns Op Ar .protocol
 .Nm
@@ -126,6 +130,15 @@ file(s) for all the
 .Ar protocols
 on the
 .Ar interface .
+For systems that support the concept of persisting configuration when
+the carrier goes down, then it should instead call
+.Nm
+with
+.Fl C Ar interface.*
+arguments to deprecate the matching interfaces and
+.Fl c Ar interface.*
+to activate the matching interfaces when the carrier comes up.
+This only affects the order in which interfaces are processed.
 .Pp
 Here are some options for the above commands:-
 .Bl -tag -width pattern_opt

Index: src/external/bsd/openresolv/dist/resolvconf.conf.5.in
diff -u src/external/bsd/openresolv/dist/resolvconf.conf.5.in:1.20 src/external/bsd/openresolv/dist/resolvconf.conf.5.in:1.21
--- src/external/bsd/openresolv/dist/resolvconf.conf.5.in:1.20	Mon Jan 27 21:13:05 2020
+++ src/external/bsd/openresolv/dist/resolvconf.conf.5.in	Sun Dec 27 18:26:50 2020
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd September 8, 2019
+.Dd October 1, 2020
 .Dt RESOLVCONF.CONF 5
 .Os
 .Sh NAME
@@ -220,7 +220,7 @@ openresolv ships with subscribers for th
 and
 .Xr unbound 8 .
 Each subscriber can create configuration files which should be included in
-in the subscribers main configuration file.
+the subscribers main configuration file.
 .Pp
 To disable a subscriber, simply set it's name to NO.
 For example, to disable the libc subscriber you would set:

Index: src/external/bsd/openresolv/dist/resolvconf.in
diff -u src/external/bsd/openresolv/dist/resolvconf.in:1.8 src/external/bsd/openresolv/dist/resolvconf.in:1.9
--- src/external/bsd/openresolv/dist/resolvconf.in:1.8	Wed Jul 22 13:19:17 2020
+++ src/external/bsd/openresolv/dist/resolvconf.in	Sun Dec 27 18:26:50 2020
@@ -25,7 +25,7 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 RESOLVCONF="$0"
-OPENRESOLV_VERSION="3.11.0"
+OPENRESOLV_VERSION="3.12.0"
 SYSCONFDIR=@SYSCONFDIR@
 LIBEXECDIR=@LIBEXECDIR@
 VARDIR=@VARDIR@
@@ -64,6 +64,7 @@ IFACEDIR="$VARDIR/interfaces"
 METRICDIR="$VARDIR/metrics"
 PRIVATEDIR="$VARDIR/private"
 EXCLUSIVEDIR="$VARDIR/exclusive"
+DEPRECATEDDIR="$VARDIR/deprecated"
 LOCKDIR="$VARDIR/lock"
 _PWD="$PWD"
 
@@ -88,6 +89,8 @@ usage()
 	Commands:
 	  -a \$INTERFACE    Add DNS information to the specified interface
 	                   (DNS supplied via stdin in resolv.conf format)
+	  -C \$PATTERN      Deprecate DNS information for matched interfaces
+	  -c \$PATTERN      Configure DNS information for matched interfaces
 	  -d \$INTERFACE    Delete DNS information from the specified interface
 	  -h               Show this help cruft
 	  -i [\$PATTERN]    Show interfaces that have supplied DNS information
@@ -275,19 +278,14 @@ dirname()
 
 config_mkdirs()
 {
-	e=0
 	for f; do
 		[ -n "$f" ] || continue
 		d="$(dirname "$f")"
 		if [ ! -d "$d" ]; then
-			if type install >/dev/null 2>&1; then
-				install -d "$d" || e=$?
-			else
-				mkdir "$d" || e=$?
-			fi
+			mkdir -p "$d" || return $?
 		fi
 	done
-	return $e
+	return 0
 }
 
 # With the advent of alternative init systems, it's possible to have
@@ -412,6 +410,22 @@ echo_resolv()
 	IFS="$OIFS"
 }
 
+deprecated_interface()
+{
+	[ -d "$DEPRECATEDDIR" ] || return 1
+
+	cd "$DEPRECATEDDIR"
+	for da; do
+		for daf in *; do
+			[ -f "$daf" ] || continue
+			case "$da" in
+			$daf) return 0;;
+			esac
+		done
+	done
+	return 1
+}
+
 list_resolv()
 {
 	[ -d "$IFACEDIR" ] || return 0
@@ -453,12 +467,14 @@ list_resolv()
 		$force || report=true
 	elif ! $excl; then
 		cd "$IFACEDIR"
+
 		for i in $interface_order; do
 			[ -f "$i" ] && list="$list $i"
 			for ii in "$i":* "$i".*; do
 				[ -f "$ii" ] && list="$list $ii"
 			done
 		done
+
 		for i in $dynamic_order; do
 			if [ -e "$i" ] && ! [ -e "$METRICDIR/"*" $i" ]; then
 				list="$list $i"
@@ -470,18 +486,32 @@ list_resolv()
 				fi
 			done
 		done
+
 		# Interfaces have an implicit metric of 0 if not specified.
 		for i in *; do
 			if [ -f "$i" ] && ! [ -e "$METRICDIR/"*" $i" ]; then
 				list="$list $i"
 			fi
 		done
+
 		if [ -d "$METRICDIR" ]; then
 			cd "$METRICDIR"
 			for i in *; do
 				[ -f "$i" ] && list="$list ${i#* }"
 			done
 		fi
+
+		# Move deprecated interfaces to the back
+		active=
+		deprecated=
+		for i in $list; do
+			if deprecated_interface "$i"; then
+				deprecated="$deprecated $i"
+			else
+				active="$active $i"
+			fi
+		done
+		list="$active $deprecated"
 	fi
 
 	cd "$IFACEDIR"
@@ -680,7 +710,7 @@ make_vars()
 
 force=false
 VFLAG=
-while getopts a:Dd:fhIilm:pRruvVx OPT; do
+while getopts a:C:c:Dd:fhIilm:pRruvVx OPT; do
 	case "$OPT" in
 	f) force=true;;
 	h) usage;;
@@ -695,7 +725,7 @@ while getopts a:Dd:fhIilm:pRruvVx OPT; d
 		fi
 		;;
 	x) IF_EXCLUSIVE=1;;
-	'?') ;;
+	'?') exit 1;;
 	*) cmd="$OPT"; iface="$OPTARG";;
 	esac
 done
@@ -744,14 +774,20 @@ if [ "$cmd" = v ] || [ -n "$VFLAG" ]; th
 fi
 
 # Test that we have valid options
-if [ "$cmd" = a ] || [ "$cmd" = d ]; then
+case "$cmd" in
+a|d|C|c)
 	if [ -z "$iface" ]; then
-		usage "Interface not specified"
+		error_exit "Interface not specified"
+	fi
+	;;
+u)	;;
+*)
+	if [ -n "$cmd" ] && [ "$cmd" != h ]; then
+		error_exit "Unknown option $cmd"
 	fi
-elif [ "$cmd" != u ]; then
-	[ -n "$cmd" ] && [ "$cmd" != h ] && usage "Unknown option $cmd"
 	usage
-fi
+	;;
+esac
 
 if [ "$cmd" = a ]; then
 	for x in '/' \\ ' ' '*'; do
@@ -809,6 +845,9 @@ fi
 # in /usr which we do our very best to operate without.
 [ -w "$VARDIR" ] || error_exit "Cannot write to $LOCKDIR"
 : ${lock_timeout:=10}
+: ${clear_nopids:=5}
+have_pid=false
+had_pid=false
 while true; do
 	if mkdir "$LOCKDIR" 2>/dev/null; then
 		trap 'rm -rf "$LOCKDIR";' EXIT
@@ -816,18 +855,43 @@ while true; do
 		echo $$ >"$LOCKDIR/pid"
 		break
 	fi
-	pid=$(cat "$LOCKDIR/pid")
-	if ! kill -0 "$pid"; then
+	pid=$(cat "$LOCKDIR/pid" 2>/dev/null)
+	if [ "$pid" -gt 0 ] 2>/dev/null; then
+		have_pid=true
+		had_pid=true
+	else
+		have_pid=false
+		clear_nopids=$(($clear_nopids - 1))
+		if [ "$clear_nopids" -le 0 ]; then
+			warn "not seen a pid, clearing lock directory"
+			rm -rf "$LOCKDIR"
+		else
+			lock_timeout=$(($lock_timeout - 1))
+			sleep 1
+		fi
+		continue
+	fi
+	if $have_pid && ! kill -0 "$pid"; then
 		warn "clearing stale lock pid $pid"
 		rm -rf "$LOCKDIR"
 		continue
 	fi
 	lock_timeout=$(($lock_timeout - 1))
 	if [ "$lock_timeout" -le 0 ]; then
-		error_exit "timed out waiting for lock from pid $pid"
+		if $have_pid; then
+			error_exit "timed out waiting for lock from pid $pid"
+		else
+			if $had_pid; then
+				error_exit "timed out waiting for lock" \
+					"from some pids"
+			else
+				error_exit "timed out waiting for lock"
+			fi
+		fi
 	fi
 	sleep 1
 done
+unset have_pid had_pid clear_nopids
 
 case "$cmd" in
 a)
@@ -947,13 +1011,45 @@ d)
 			"$PRIVATEDIR/$i" \
 			"$EXCLUSIVEDIR/"*" $i" || exit $?
 	done
-	if ! ${changed}; then
+
+	if ! $changed; then
 		# Set the return code based on the forced flag
-		${force}
+		$force
 		exit $?
 	fi
 	unset changed i
 	;;
+
+C)
+	# Mark interface as deprecated
+	[ ! -d "$DEPRECATEDDIR" ] && mkdir "$DEPRECATEDDIR"
+	cd "$DEPRECATEDDIR"
+	changed=false
+	for i in $args; do
+		if [ ! -e "$i" ]; then
+			changed=true
+			echo " " >"$i" || exit $?
+		fi
+	done
+	$changed || exit 0
+	unset changed i
+	;;
+
+c)
+	# Mark interface as active
+	if [ -d "$DEPRECATEDDIR" ]; then
+		cd "$DEPRECATEDDIR"
+		changed=false
+		for i in $args; do
+			if [ -e "$i" ]; then
+				changed=true
+				rm "$i" || exit $?
+			fi
+		done
+		$changed || exit 0
+		unset changed i
+	fi
+	;;
 esac
 
 case "${resolvconf:-YES}" in

Reply via email to