Signed-off-by: John Hansen <[email protected]>
Index: package/base-files-network/files/lib/network/config.sh
===================================================================
--- package/base-files-network/files/lib/network/config.sh (revision 28773)
+++ package/base-files-network/files/lib/network/config.sh (working copy)
@@ -135,6 +135,50 @@
}
}
+add_search() {
+ local cfg="$1"; shift
+
+ remove_search "$cfg"
+
+ # We may be called by pppd's ip-up which has a nonstandard umask set.
+ # Create an empty file here and force its permission to 0644, otherwise
+ # dnsmasq will not be able to re-read the resolv.conf.auto .
+ [ ! -f /tmp/resolv.conf.auto ] && {
+ touch /tmp/resolv.conf.auto
+ chmod 0644 /tmp/resolv.conf.auto
+ }
+
+ local search
+ local add
+ for search in "$@"; do
+ grep -qsF "search $search" /tmp/resolv.conf.auto || {
+ add="${add:+$add }$search"
+ echo "search $search" >> /tmp/resolv.conf.auto
+ }
+ done
+
+ [ -n "$cfg" ] && {
+ uci_toggle_state network "$cfg" search "$add"
+ uci_toggle_state network "$cfg" resolv_search "$add"
+ }
+}
+
+remove_search() {
+ local cfg="$1"
+
+ [ -n "$cfg" ] && {
+ [ -f /tmp/resolv.conf.auto ] && {
+ local search=$(uci_get_state network "$cfg" resolv_dns)
+ for search in $search; do
+ sed -i -e "/^search $search$/d"
/tmp/resolv.conf.auto
+ done
+ }
+
+ uci_revert_state network "$cfg" search
+ uci_revert_state network "$cfg" resolv_search
+ }
+}
+
# sort the device list, drop duplicates
sort_list() {
local arg="$*"
@@ -256,12 +300,13 @@
config_get ip6addr "$config" ip6addr
[ -z "$ipaddr" -o -z "$netmask" ] && [ -z "$ip6addr" ] && return 1
- local gateway ip6gw dns bcast metric
+ local gateway ip6gw dns bcast metric search
config_get gateway "$config" gateway
config_get ip6gw "$config" ip6gw
config_get dns "$config" dns
config_get bcast "$config" broadcast
config_get metric "$config" metric
+ config_get search "$config" search
case "$ip6addr" in
*/*) ;;
@@ -273,6 +318,7 @@
[ -z "$gateway" ] || $DEBUG route add default gw "$gateway"
${metric:+metric $metric} dev "$iface"
[ -z "$ip6gw" ] || $DEBUG route -A inet6 add default gw "$ip6gw"
${metric:+metric $metric} dev "${iface%:*}"
[ -z "$dns" ] || add_dns "$config" $dns
+ [ -z "$search" ] || add_search "$config" $search
config_get type "$config" TYPE
[ "$type" = "alias" ] && return 0
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel