Bug 1252152

Summary: grep-2.20-3.el6.x86_64 patch breaks dhclient's build of /etc/resolv.conf
Product: Red Hat Enterprise Linux 6 Reporter: marco <marco>
Component: dhcpAssignee: Jiri Popelka <jpopelka>
Status: CLOSED DUPLICATE QA Contact: Release Test Team <release-test-team-automation>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.6   
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-08-11 08:29:18 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description marco 2015-08-10 20:15:11 UTC
Description of problem:

I am using Scientific Linux 6.6 

An EL6 desktop boots up crippled (no DNS) when an "options" line is present in /etc/resolv.conf, since the recent patch of grep to grep-2.20-3.el6.x86_64. 

The fix regarding the "-F" option to grep appears to interact poorly with the way it is used by the function "change_resolv_conf" in /etc/sysconfig/network-scripts/network-functions. In particular, the code checks for an "options" line in /etc/resolv.conf, and if one is found, keeps it, and replaces the rest of the file with the contents of the temporary file (created by the function "make_resolv_conf" in /sbin/dhclient-script) *MINUS* any matching options line(s) in the temporary file. 

The problem is that the output from this command (which is used to remove the options line from the temporary file): 

/bin/grep -vF "options ndots:2 
" /tmp/TMPFILENAME 

used to return the rest of the file (e.g.): 
   nameserver 132.205.96.93 
   nameserver 132.205.96.94 
   search encs.concordia.ca concordia.ca 

but now returns nothing. As a result, resolv.conf contains *only* the options line - no nameservers or search list, so of course no hostnames can be resolved, LDAP fails, automounting fails, etc., etc. 

It seems that the "second" (empty) line of the expression being searched for now matches anything, so the reverse match matches nothing. The grep expression can be made to "work" by making sure that the second line is not empty: 

/bin/grep -vF "options ndots:2 trash_do_not_match" /etc/resolv.conf 

nameserver 132.205.96.93 
nameserver 132.205.96.94 
search encs.concordia.ca admin.private concordia.ca 

... but this is the wrong fix for the code as it stands, because the "s" variable is re-used for various purposes, such that the "trash" string then ends up in the generated resolv.conf. For now, we've worked around the problem with this patch: ----------------------------------------------------------------------------- --- /etc/sysconfig/network-scripts/.old/network-functions.20150810.140031 2014-07-22 09:56:28.000000000 -0400 +++ /etc/sysconfig/network-scripts/network-functions 2015-08-10 14:33:49.000000000 -0400 @@ -503,9 +503,9 @@ change_resolv_conf () 
{ 
     s=$(/bin/grep '^[\ \ ]*option' /etc/resolv.conf 2>/dev/null); 
-    if [ "x$s" != "x" ]; then 
-       s="$s"$'\n'; 
-    fi; 
+#   if [ "x$s" != "x" ]; then 
+#      s="$s"$'\n'; 
+#   fi; 
     if [ $# -gt 1 ]; then 
        n_args=$#; 
        while [ $n_args -gt 0 ]; 
@@ -524,7 +524,7 @@ 
          done; 
     elif [ $# -eq 1 ]; then 
        if [ "x$s" != "x" ]; then 
-         s="$s"$(/bin/grep -vF "$s" $1); 
+         s=$(/bin/grep -v "$s" $1)$'\n'"$s"; 
        else 
          s=$(cat $1); 
     fi; ----------------------------------------------------------------------------- ... but the above doesn't cover all code paths, and may not be correct under all circumstances. Still, we hope it's a starting point for you, and at least we can boot our workstation properly again!


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

seems to break with grep-2.20-3.el6.x86_64


How reproducible:
- add an options line to /etc/resolv.conf
- reboot or restart dhclient to rebuild /etc/resolv.conf

Comment 2 Jiri Popelka 2015-08-11 08:29:18 UTC
Should be fixed with initscripts-9.03.49-1.el6

*** This bug has been marked as a duplicate of bug 1210310 ***