mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-11-30 20:58:25 +02:00
[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
This commit is contained in:
parent
a4080edbad
commit
9c250a1ea9
@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
|
|||||||
include $(INCLUDE_DIR)/kernel.mk
|
include $(INCLUDE_DIR)/kernel.mk
|
||||||
|
|
||||||
PKG_NAME:=base-files
|
PKG_NAME:=base-files
|
||||||
PKG_RELEASE:=46
|
PKG_RELEASE:=47
|
||||||
|
|
||||||
PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
|
PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
|
||||||
|
|
||||||
|
@ -70,6 +70,16 @@ add_vlan() {
|
|||||||
add_dns() {
|
add_dns() {
|
||||||
local cfg="$1"; shift
|
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 dns
|
||||||
local add
|
local add
|
||||||
for dns in "$@"; do
|
for dns in "$@"; do
|
||||||
@ -79,20 +89,27 @@ add_dns() {
|
|||||||
}
|
}
|
||||||
done
|
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 entries of the given iface
|
||||||
remove_dns() {
|
remove_dns() {
|
||||||
local cfg="$1"
|
local cfg="$1"
|
||||||
|
|
||||||
local dns
|
[ -n "$cfg" ] && {
|
||||||
config_get dns "$cfg" dns
|
[ -f /tmp/resolv.conf.auto ] && {
|
||||||
for dns in $dns; do
|
local dns=$(uci_get_state network "$cfg" resolv_dns)
|
||||||
sed -i -e "/^nameserver $dns$/d" /tmp/resolv.conf.auto
|
for dns in $dns; do
|
||||||
done
|
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
|
# sort the device list, drop duplicates
|
||||||
@ -212,13 +229,7 @@ setup_interface_static() {
|
|||||||
[ -z "$ip6addr" ] || $DEBUG ifconfig "$iface" add "$ip6addr"
|
[ -z "$ip6addr" ] || $DEBUG ifconfig "$iface" add "$ip6addr"
|
||||||
[ -z "$gateway" ] || $DEBUG route add default gw "$gateway" dev "$iface"
|
[ -z "$gateway" ] || $DEBUG route add default gw "$gateway" dev "$iface"
|
||||||
[ -z "$ip6gw" ] || $DEBUG route -A inet6 add default gw "$ip6gw" dev "$iface"
|
[ -z "$ip6gw" ] || $DEBUG route -A inet6 add default gw "$ip6gw" dev "$iface"
|
||||||
[ -z "$dns" ] || {
|
[ -z "$dns" ] || add_dns "$config" $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
|
|
||||||
}
|
|
||||||
|
|
||||||
config_get type "$config" TYPE
|
config_get type "$config" TYPE
|
||||||
[ "$type" = "alias" ] && return 0
|
[ "$type" = "alias" ] && return 0
|
||||||
@ -363,12 +374,14 @@ setup_interface() {
|
|||||||
stop_interface_dhcp() {
|
stop_interface_dhcp() {
|
||||||
local config="$1"
|
local config="$1"
|
||||||
|
|
||||||
local iface
|
local ifname
|
||||||
config_get ifname "$config" ifname
|
config_get ifname "$config" ifname
|
||||||
|
|
||||||
local lock="/var/lock/dhcp-${ifname}"
|
local lock="/var/lock/dhcp-${ifname}"
|
||||||
[ -f "$lock" ] && lock -u "$lock"
|
[ -f "$lock" ] && lock -u "$lock"
|
||||||
|
|
||||||
|
remove_dns "$config"
|
||||||
|
|
||||||
local pidfile="/var/run/dhcp-${ifname}.pid"
|
local pidfile="/var/run/dhcp-${ifname}.pid"
|
||||||
local pid="$(cat "$pidfile" 2>/dev/null)"
|
local pid="$(cat "$pidfile" 2>/dev/null)"
|
||||||
[ -d "/proc/$pid" ] && {
|
[ -d "/proc/$pid" ] && {
|
||||||
|
@ -40,6 +40,9 @@ done
|
|||||||
config_get iftype "$cfg" type
|
config_get iftype "$cfg" type
|
||||||
[ "bridge" = "$iftype" ] && brctl delbr "$ifname" >/dev/null 2>/dev/null
|
[ "bridge" = "$iftype" ] && brctl delbr "$ifname" >/dev/null 2>/dev/null
|
||||||
|
|
||||||
|
# remove the interface's dns entries
|
||||||
|
remove_dns "$cfg"
|
||||||
|
|
||||||
# remove the interface's network state
|
# remove the interface's network state
|
||||||
uci_revert_state network "$1"
|
uci_revert_state network "$1"
|
||||||
|
|
||||||
|
@ -139,21 +139,21 @@ setup_interface () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# DNS
|
# DNS
|
||||||
config_get old_dns "$ifc" dns
|
old_dns=$(uci_get_state network "$ifc" dns)
|
||||||
|
old_domain=$(uci_get_state network "$ifc" dnsdomain)
|
||||||
user_dns=$(uci_get "network.$ifc.dns")
|
user_dns=$(uci_get "network.$ifc.dns")
|
||||||
[ -n "$user_dns" ] && dns="$user_dns"
|
[ -n "$user_dns" ] && dns="$user_dns"
|
||||||
|
|
||||||
[ -n "$dns" ] && [ ! -s "${RESOLV_CONF}" -o "$dns" != "$old_dns" ] && {
|
[ -n "$dns" ] && [ "$dns" != "$old_dns" -o -n "$user_dns" ] && {
|
||||||
echo "udhcpc: setting dns servers: $dns"
|
echo "udhcpc: setting dns servers: $dns"
|
||||||
echo -n > "${RESOLV_CONF}.tmp"
|
add_dns "$ifc" $dns
|
||||||
for i in $dns ; do
|
|
||||||
echo "nameserver $i" >> "${RESOLV_CONF}.tmp"
|
|
||||||
done
|
|
||||||
${domain:+echo search $domain} >> "${RESOLV_CONF}.tmp"
|
|
||||||
mv "${RESOLV_CONF}.tmp" "$RESOLV_CONF"
|
|
||||||
|
|
||||||
change_state network "$ifc" dnsdomain "$domain"
|
[ -n "$domain" ] && [ "$domain" != "$old_domain" ] && {
|
||||||
change_state network "$ifc" dns "$dns"
|
echo "udhcpc: setting dns domain: $domain"
|
||||||
|
sed -i -e "${old_domain:+/^search $old_domain$/d; }/^search $domain$/d" "${RESOLV_CONF}"
|
||||||
|
echo "search $domain" >> "${RESOLV_CONF}"
|
||||||
|
change_state network "$ifc" dnsdomain "$domain"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[ -n "$ifc" ] || return
|
[ -n "$ifc" ] || return
|
||||||
|
Loading…
Reference in New Issue
Block a user