Bug 9735 - ifup should handle editing named.conf as well as resolv.conf
Summary: ifup should handle editing named.conf as well as resolv.conf
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: initscripts
Version: 6.1
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-02-24 06:11 UTC by Major
Modified: 2014-03-17 02:12 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-09-29 19:01:39 UTC
Embargoed:


Attachments (Terms of Use)

Description Major 2000-02-24 06:11:57 UTC
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 06:39:59 UTC
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 17:58:59 UTC
Please attach the patch in diff -u format; thanks.

Comment 3 Major 2000-02-28 06:16:59 UTC
--- 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 19:01:39 UTC
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.