Bug 85841 - ifup-post removes 'search' domains from /etc/resolv.conf
ifup-post removes 'search' domains from /etc/resolv.conf
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: initscripts (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Bill Nottingham
Brock Organ
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-03-08 22:37 EST by Enrique Perez-Terron
Modified: 2014-03-16 22:35 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-04-28 15:03:41 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 Enrique Perez-Terron 2003-03-08 22:37:17 EST
Description of problem:
ifup-post does not keep "search" values if DOMAIN is set

Version-Release number of selected component (if applicable):
7.10-1

How reproducible:
Follow the steps below

Steps to Reproduce:
1.Add the following lines to /etc/resolv.conf (save a copy first, to restore)
search tomato.place
search juicy.fruit
2. Add the following lines to /etc/sysconfig/netowrk-scripts/ifcfg-eth0
DOMAIN=mydomain.lan
DNS1=1.1.1.1
DNS2=2.2.2.2
3. Execute the following commands as root
cd /etc/sysconfig/network-scripts
./ifdown eth0
./ifup eth0
cat /etc/resolv.conf
    
Actual results:
...
search mydomain.lan

Expected results:
...
search mydomain.lan tomato.place juicy.fruit

Additional info:
The reason is the construct echo blah | while read var; do GETLOST=$var; done
where the variable GETLOST is set only in the subshell at the end of the pipe.
In the parent process, the variable is not changed. Notice that there are
two nested levels of this construct.
Comment 1 Enrique Perez-Terron 2003-03-08 22:48:07 EST
I suggest the following patch. The inner level of "echo | while read" is
removed. The outer is kept, but the use of the variable is moved inside 
the subshell by adding a pair of parentheses, i.e.

   echo | (while read...done; echo $VARIALBE >> file)

--- /etc/sysconfig/network-scripts/ifup-post    2003-03-09 04:09:09.000000000 +0100
+++ /usr/src/redhat/BUILD/initscripts-7.10/sysconfig/network-scripts/ifup-post 
2003-02-20 18:14:53.000000000 +0100
@@ -34,7 +34,7 @@
     current_replacement="$DNS1"
     next_replacement="$DNS2"
     search=
-    (cat /etc/resolv.conf ; echo EOF ; echo EOF) | (while read answer ; do
+    (cat /etc/resolv.conf ; echo EOF ; echo EOF) | while read answer ; do
        case $answer in
            nameserver*|EOF)
                if [ -n "$current_replacement" ] ; then
@@ -53,7 +53,9 @@
                ;;
            domain*|search*)
                if [ -n "$DOMAIN" ]; then
-                   search=`set $answer; shift; echo "$search $*"`
+                   echo "$answer" | while read key value ; do
+                       search="$search $value"
+                   done
                else
                    echo "$answer" >> $tr
                fi
@@ -65,7 +67,7 @@
     done
     if [ -n "$DOMAIN" ]; then
         echo "search $DOMAIN $search" >> $tr
-    fi)
+    fi

     # backup resolv.conf
     cp -af /etc/resolv.conf /etc/resolv.conf.save
Comment 2 Bill Nottingham 2005-04-28 15:03:41 EDT
This is fixed in current initscripts.

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