aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/lib
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2010-05-30 18:23:43 +0000
committerJo-Philipp Wich <jow@openwrt.org>2010-05-30 18:23:43 +0000
commitd156518f0872807bfde07b1948e9426f1f3b6dac (patch)
tree5fed1caa9f80787eed0f74c7725451bc46b138c7 /package/base-files/files/lib
parent9232721abcfec679e07d4278f6fac8f837c5c953 (diff)
downloadupstream-d156518f0872807bfde07b1948e9426f1f3b6dac.tar.gz
upstream-d156518f0872807bfde07b1948e9426f1f3b6dac.tar.bz2
upstream-d156518f0872807bfde07b1948e9426f1f3b6dac.zip
[package] base-files:
- use add_dns() and remove_dns() for when changing resolv.conf.auto for static or dhcp interfaces - force 0644 permissions when creating resolv.conf.auto, fixes dnsmasq permissions denied problem with pppd interfaces - revert dns servers in /sbin/ifdown - bump package revision git-svn-id: svn://svn.openwrt.org/openwrt/trunk@21638 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/base-files/files/lib')
-rwxr-xr-xpackage/base-files/files/lib/network/config.sh43
1 files changed, 28 insertions, 15 deletions
diff --git a/package/base-files/files/lib/network/config.sh b/package/base-files/files/lib/network/config.sh
index 32170bb274..1bb3a46ecd 100755
--- a/package/base-files/files/lib/network/config.sh
+++ b/package/base-files/files/lib/network/config.sh
@@ -70,6 +70,16 @@ add_vlan() {
add_dns() {
local cfg="$1"; shift
+ remove_dns "$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 dns
local add
for dns in "$@"; do
@@ -79,20 +89,27 @@ add_dns() {
}
done
- uci_set_state network "$cfg" dns "$add"
+ [ -n "$cfg" ] && {
+ uci_set_state network "$cfg" dns "$add"
+ uci_set_state network "$cfg" resolv_dns "$add"
+ }
}
# remove dns entries of the given iface
remove_dns() {
local cfg="$1"
- local dns
- config_get dns "$cfg" dns
- for dns in $dns; do
- sed -i -e "/^nameserver $dns$/d" /tmp/resolv.conf.auto
- done
+ [ -n "$cfg" ] && {
+ [ -f /tmp/resolv.conf.auto ] && {
+ local dns=$(uci_get_state network "$cfg" resolv_dns)
+ for dns in $dns; do
+ sed -i -e "/^nameserver $dns$/d" /tmp/resolv.conf.auto
+ done
+ }
- uci_revert_state network "$cfg" dns
+ uci_revert_state network "$cfg" dns
+ uci_revert_state network "$cfg" resolv_dns
+ }
}
# sort the device list, drop duplicates
@@ -212,13 +229,7 @@ setup_interface_static() {
[ -z "$ip6addr" ] || $DEBUG ifconfig "$iface" add "$ip6addr"
[ -z "$gateway" ] || $DEBUG route add default gw "$gateway" dev "$iface"
[ -z "$ip6gw" ] || $DEBUG route -A inet6 add default gw "$ip6gw" dev "$iface"
- [ -z "$dns" ] || {
- for ns in $dns; do
- grep "$ns" /tmp/resolv.conf.auto 2>/dev/null >/dev/null || {
- echo "nameserver $ns" >> /tmp/resolv.conf.auto
- }
- done
- }
+ [ -z "$dns" ] || add_dns "$config" $dns
config_get type "$config" TYPE
[ "$type" = "alias" ] && return 0
@@ -363,12 +374,14 @@ setup_interface() {
stop_interface_dhcp() {
local config="$1"
- local iface
+ local ifname
config_get ifname "$config" ifname
local lock="/var/lock/dhcp-${ifname}"
[ -f "$lock" ] && lock -u "$lock"
+ remove_dns "$config"
+
local pidfile="/var/run/dhcp-${ifname}.pid"
local pid="$(cat "$pidfile" 2>/dev/null)"
[ -d "/proc/$pid" ] && {