Bug 1252152 - grep-2.20-3.el6.x86_64 patch breaks dhclient's build of /etc/resolv.conf
grep-2.20-3.el6.x86_64 patch breaks dhclient's build of /etc/resolv.conf
Status: CLOSED DUPLICATE of bug 1210310
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: dhcp (Show other bugs)
6.6
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Jiri Popelka
Release Test Team
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-08-10 16:15 EDT by marco
Modified: 2015-08-11 04:29 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-08-11 04:29:18 EDT
Type: Bug
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 marco 2015-08-10 16:15:11 EDT
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 04:29:18 EDT
Should be fixed with initscripts-9.03.49-1.el6

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

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