Bug 9735 - ifup should handle editing named.conf as well as resolv.conf
ifup should handle editing named.conf as well as resolv.conf
Status: CLOSED WONTFIX
Product: Red Hat Linux
Classification: Retired
Component: initscripts (Show other bugs)
6.1
All Linux
medium Severity medium
: ---
: ---
Assigned To: Bill Nottingham
: FutureFeature
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-02-24 01:11 EST by Major
Modified: 2014-03-16 22:12 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-09-29 15:01:39 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Major 2000-02-24 01:11:57 EST
It would be useful for ifup to be able to edit a named.conf file
   instead of the resolv.conf file when it gets a nameserver
   address from a PPP peer.

   If the attached replacement for the ifup-post file is used, the
   PEERDNS variable can be set to "named", "resolv" or "no" according
   to the user's intentions.

   The enhancement file includes my fix to bug 9734
Comment 1 Major 2000-02-24 01:39:59 EST
I tried to attach the patch as a file, but bugzilla claimed I
didn't (No file was provided, or it was empty.) --- Major

Here it is:

9a10
>
31,32c32,54
< if [ "$PEERDNS" != no -a -n "$DNS1" ] &&
<    tr=`mktemp /tmp/resolv.XXXXXX` ; then
---
> case "$PEERDNS" in
> named)
>   if [ -n "$DNS1" ] && tmp=`mktemp /tmp/named.XXXXXX`
>   then
>
>     conf=/etc/named.conf
>     forwarders="{ $DNS1"
>     if [ "$DNS2" != "" ]
>     then
>       forwarders="$forwarders; $DNS2"
>     fi
>     forwarders="$forwarders; }"
>     grep -v "forwarders" $conf \
>     | awk -v forwarders="$forwarders" '{print}
>            /options/ {print " forwarders " forwarders ";" }' >$tmp
>     cat $tmp >$conf
>     rm -f $tmp
>     kill -1 $(cat /var/run/named.pid)
>   fi
>   ;;
> resolv)
>   if [ -n "$DNS1" ] && tr=`mktemp /tmp/resolv.XXXXXX`
>   then
38c60
<       case $answer in
---
>     case $answer in
58,62c80,86
<     done
<     # maintain permissions
<     cat $tr > /etc/resolv.conf
<     rm -f $tr
< fi
---
>      done
>      # maintain permissions
>      cat $tr > /etc/resolv.conf
>      rm -f $tr
>   fi
>   ;;
> esac
Comment 2 Bill Nottingham 2000-02-24 12:58:59 EST
Please attach the patch in diff -u format; thanks.
Comment 3 Major 2000-02-28 01:16:59 EST
--- ifup-post.dist	Thu Feb 24 07:49:09 2000
+++ ifup-post	Thu Feb 24 14:30:00 2000
@@ -7,6 +7,7 @@
 CONFIG=$1
 source_config

+
 DEVICETYPE=`echo $DEVICE | sed "s/[0-9]*$//"`
 REALDEVICE=`echo $DEVICE | sed 's/:.*//g'`
 if echo $DEVICE | grep -q ':' ; then
@@ -28,14 +29,35 @@
     eval `/bin/ipcalc --silent --hostname ${IPADDR}` && set_hostname $HOSTNAME
 fi

-if [ "$PEERDNS" != no -a -n "$DNS1" ] &&
-   tr=`mktemp /tmp/resolv.XXXXXX` ; then
+case "$PEERDNS" in
+named)
+  if [ -n "$DNS1" ] && tmp=`mktemp /tmp/named.XXXXXX`
+  then
+
+    conf=/etc/named.conf
+    forwarders="{ $DNS1"
+    if [ "$DNS2" != "" ]
+    then
+      forwarders="$forwarders; $DNS2"
+    fi
+    forwarders="$forwarders; }"
+    grep -v "forwarders" $conf \
+    | awk -v forwarders="$forwarders" '{print}
+           /options/ {print "	forwarders " forwarders ";" }' >$tmp
+    cat $tmp >$conf
+    rm -f $tmp
+    kill -1 $(cat /var/run/named.pid)
+  fi
+  ;;
+resolv)
+  if [ -n "$DNS1" ] && tr=`mktemp /tmp/resolv.XXXXXX`
+  then
     # replace only the first two nameserver lines; cannot count on awk
     # and do not know if sed is capable of this...
     current_replacement="$DNS1"
     next_replacement="$DNS2"
     (cat /etc/resolv.conf ; echo EOF ; echo EOF) | while read answer ; do
-	case $answer in
+    case $answer in
 	    nameserver*|EOF)
 		if [ -n "$current_replacement" ] ; then
 		    echo "nameserver $current_replacement" >> $tr
@@ -55,11 +77,13 @@
 		echo "$answer" >> $tr
 		;;
 	esac
-    done
-    # maintain permissions
-    cat $tr > /etc/resolv.conf
-    rm -f $tr
-fi
+     done
+     # maintain permissions
+     cat $tr > /etc/resolv.conf
+     rm -f $tr
+  fi
+  ;;
+esac

 # Notify programs that have requested notification
 do_netreport
Comment 4 Bill Nottingham 2005-09-29 15:01:39 EDT
In the future, something like this would fall to NetworkManager; ergo, I'm not
really willing to change the intiscripts behavior in this area at this time.

Note You need to log in before you can comment on or make changes to this bug.