From fe25b96c7ae70a3cb392b45937377b97a535a1dd Mon Sep 17 00:00:00 2001 From: Dmitry V. Levin Date: Tue, 26 May 2009 12:41:34 +0000 Subject: [PATCH 2/2] ip-up: Rewrite openresolv support Use environment variables $DNS1 and $DNS2 instead of /etc/ppp/resolv.conf, because this file is not reliable source. --- ppp-common/ppp/ip-up | 26 ++++++++++++++++++++------ 1 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ppp-common/ppp/ip-up b/ppp-common/ppp/ip-up index d0fcb40..e2bf19c 100755 --- a/ppp-common/ppp/ip-up +++ b/ppp-common/ppp/ip-up @@ -32,7 +32,6 @@ REALDEVICE=$1 NS_IFUP=/etc/sysconfig/network-scripts/ifup-post N_C_S_CONFIG=/etc/sysconfig/network RESOLVCONF=/sbin/resolvconf -PPP_RESOLV_CONF=/etc/ppp/resolv.conf export PATH=/sbin:/usr/sbin:/bin:/usr/bin @@ -56,11 +55,12 @@ export PATH=/sbin:/usr/sbin:/bin:/usr/bin . /etc/init.d/functions SourceIfNotEmpty $N_C_S_CONFIG +[ -z "$MS_DNS1" ] || DNS1=$MS_DNS1 +[ -z "$MS_DNS2" ] || DNS2=$MS_DNS2 + # taken from net-scripts -modify_resolver() +modify_resolv_conf() { - [ -z "$MS_DNS1" ] || DNS1=$MS_DNS1 - [ -z "$MS_DNS2" ] || DNS2=$MS_DNS2 local tr if [ -n "$DNS1" ] && ! grep -qs "^nameserver $DNS1" /etc/resolv.conf && tr=`mktemp /etc/resolv.conf.XXXXXX`; then @@ -117,12 +117,26 @@ modify_resolver() fi } +update_via_resolvconf() +{ + local t + t=$(mktemp -t resolv.conf.XXXXXXXXXX) || return + local d + for d in $DNS1 $DNS2; do + echo "nameserver $d" >"$t" + done + if [ -s "$t" ]; then + "$RESOLVCONF" -a "$REALDEVICE" <"$t" + fi + rm -f -- "$t" +} + if ! is_no "$RESOLV_MODS"; then if [ -x "$RESOLVCONF" ]; then - [ -f "$PPP_RESOLV_CONF" ] && $RESOLVCONF -a $REALDEVICE <$PPP_RESOLV_CONF + update_via_resolvconf else # check if kppp was here, don't touch /etc/resolv.conf then, just UC - grep -iqs '#.*ppp temp entry' /etc/resolv.conf || modify_resolver + grep -iqs '#.*ppp temp entry' /etc/resolv.conf || modify_resolv_conf UC=/usr/sbin/update_chrooted [ -x $UC ] && $UC conf fi -- 1.6.3.1