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.6.1 with th...
details: https://anonhg.NetBSD.org/src/rev/7a97777db9e6
branches: trunk
changeset: 333307:7a97777db9e6
user: roy <roy%NetBSD.org@localhost>
date: Tue Oct 28 22:37:59 2014 +0000
description:
Import openresolv-3.6.1 with the following changes:
* Don't update when nothing has been deleted
* Backup resolv.conf to resolv.conf.bak when it doesn't have an openresolv
signature
Restore it when the new resolv.conf only has the openresolv signature
* Document prepend_search and prepend_nameservers
* Implement append_search and append_nameservers
* Implement replace and replace_sub to allow for keyword/value/replacement
diffstat:
external/bsd/openresolv/dist/libc.in | 26 ++++++++++++-
external/bsd/openresolv/dist/resolvconf.in | 54 +++++++++++++++++++++++++++++-
2 files changed, 76 insertions(+), 4 deletions(-)
diffs (145 lines):
diff -r 6478725fa4c9 -r 7a97777db9e6 external/bsd/openresolv/dist/libc.in
--- a/external/bsd/openresolv/dist/libc.in Tue Oct 28 21:36:30 2014 +0000
+++ b/external/bsd/openresolv/dist/libc.in Tue Oct 28 22:37:59 2014 +0000
@@ -106,6 +106,9 @@
resolv_conf_tail="$(cat "$SYSCONFDIR"/resolv.conf.tail)"
fi
+backup=true
+signature="# Generated by resolvconf"
+
uniqify()
{
local result=
@@ -121,6 +124,7 @@
case "${resolv_conf_passthrough:-NO}" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
+ backup=false
newest=
for conf in "$IFACEDIR"/*; do
if [ -z "$newest" -o "$conf" -nt "$newest" ]; then
@@ -147,11 +151,11 @@
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) ;;
*)
: ${domain:=$DOMAIN}
- newsearch="$(uniqify $prepend_search $SEARCH)"
+ newsearch="$(uniqify $prepend_search $SEARCH $append_search)"
NS="$LOCALNAMESERVERS $NAMESERVERS"
newns=
gotlocal=false
- for n in $(uniqify $prepend_nameservers $NS); do
+ for n in $(uniqify $prepend_nameservers $NS $append_nameservers); do
add=true
islocal=false
for l in $local_nameservers; do
@@ -169,7 +173,7 @@
done
# Hold our new resolv.conf in a variable to save on temporary files
- newconf="# Generated by resolvconf$NL"
+ newconf="$signature$NL"
if [ -n "$resolv_conf_head" ]; then
newconf="$newconf$resolv_conf_head$NL"
fi
@@ -207,6 +211,22 @@
[ "$(cat "$resolv_conf")" = "$(printf %s "$newconf")" ] && exit 0
fi
+# Change is good.
+# If the old file does not have our signature, back it up.
+# If the new file just has our signature, restore the backup.
+if $backup; then
+ if [ "$newconf" = "$signature$NL" ]; then
+ if [ -e "$resolv_conf.bak" ]; then
+ newconf="$(cat "$resolv_conf.bak")"
+ fi
+ elif [ -e "$resolv_conf" ]; then
+ read line <"$resolv_conf"
+ if [ "$line" != "$signature" ]; then
+ cp "$resolv_conf" "$resolv_conf.bak"
+ fi
+ fi
+fi
+
# Create our resolv.conf now
(umask 022; printf %s "$newconf" >"$resolv_conf")
eval $libc_restart
diff -r 6478725fa4c9 -r 7a97777db9e6 external/bsd/openresolv/dist/resolvconf.in
--- a/external/bsd/openresolv/dist/resolvconf.in Tue Oct 28 21:36:30 2014 +0000
+++ b/external/bsd/openresolv/dist/resolvconf.in Tue Oct 28 22:37:59 2014 +0000
@@ -354,6 +354,47 @@
echo
}
+replace()
+{
+ local r= k= f= v= val= sub=
+
+ while read -r keyword value; do
+ for r in $replace; do
+ k="${r%%/*}"
+ r="${r#*/}"
+ f="${r%%/*}"
+ r="${r#*/}"
+ v="${r%%/*}"
+ case "$keyword" in
+ $k)
+ case "$value" in
+ $f) value="$v";;
+ esac
+ ;;
+ esac
+ done
+ val=
+ for sub in $value; do
+ for r in $replace_sub; do
+ k="${r%%/*}"
+ r="${r#*/}"
+ f="${r%%/*}"
+ r="${r#*/}"
+ v="${r%%/*}"
+ case "$keyword" in
+ $k)
+ case "$sub" in
+ $f) sub="$v";;
+ esac
+ ;;
+ esac
+ done
+ val="$val${val:+ }$sub"
+ done
+ printf "%s %s\n" "$keyword" "$val"
+ done
+}
+
make_vars()
{
local newdomains= d= dn= newns= ns=
@@ -369,7 +410,7 @@
eval "$(echo_prepend | parse_resolv)"
fi
if [ -z "$VFLAG" ]; then
- eval "$(list_resolv -l "$@" | parse_resolv)"
+ eval "$(list_resolv -l "$@" | replace | parse_resolv)"
fi
if [ -n "$name_servers_append" -o -n "$search_domains_append" ]; then
eval "$(echo_append | parse_resolv)"
@@ -510,6 +551,17 @@
if [ ! -d "$IFACEDIR" ]; then
mkdir -m 0755 -p "$IFACEDIR" || \
error_exit "Failed to create needed directory $IFACEDIR"
+ if [ "$cmd" = d ]; then
+ # Provide the same error messages as below
+ if ! ${force}; then
+ cd "$IFACEDIR"
+ for i in $args; do
+ warn "No resolv.conf for interface $i"
+ done
+ fi
+ ${force}
+ exit $?
+ fi
else
# Delete any existing information about the interface
if [ "$cmd" = d ]; then
Home |
Main Index |
Thread Index |
Old Index