Blame SOURCES/glibc-rh1085290.patch

147e83
commit dd3022d75e6fb8957843d6d84257a5d8457822d5
147e83
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
147e83
Date:   Thu Mar 27 19:49:51 2014 +0530
147e83
147e83
    Return NULL for wildcard values in getnetgrent from nscd (BZ #16759)
147e83
    
147e83
    getnetgrent is supposed to return NULL for values that are wildcards
147e83
    in the (host, user, domain) triplet.  This works correctly with nscd
147e83
    disabled, but with it enabled, it returns a blank ("") instead of a
147e83
    NULL.  This is easily seen with the output of `getent netgroup foonet`
147e83
    for a netgroup foonet defined as follows in /etc/netgroup:
147e83
    
147e83
        foonet (,foo,)
147e83
    
147e83
    The output with nscd disabled is:
147e83
    
147e83
        foonet ( ,foo,)
147e83
    
147e83
    while with nscd enabled, it is:
147e83
    
147e83
        foonet (,foo,)
147e83
    
147e83
    The extra space with nscd disabled is due to the fact that `getent
147e83
    netgroup` adds it if the return value from getnetgrent is NULL for
147e83
    either host or user.
147e83
147e83
diff --git glibc-2.17-c758a686/inet/getnetgrent_r.c glibc-2.17-c758a686/inet/getnetgrent_r.c
147e83
index 62cdfda..f6d064d 100644
147e83
--- glibc-2.17-c758a686/inet/getnetgrent_r.c
147e83
+++ glibc-2.17-c758a686/inet/getnetgrent_r.c
147e83
@@ -235,6 +235,14 @@ endnetgrent (void)
147e83
   __libc_lock_unlock (lock);
147e83
 }
147e83
 
147e83
+static const char *
147e83
+get_nonempty_val (const char *in)
147e83
+{
147e83
+  if (*in == '\0')
147e83
+    return NULL;
147e83
+  return in;
147e83
+}
147e83
+
147e83
 #ifdef USE_NSCD
147e83
 static enum nss_status
147e83
 nscd_getnetgrent (struct __netgrent *datap, char *buffer, size_t buflen,
147e83
@@ -243,11 +251,11 @@ nscd_getnetgrent (struct __netgrent *datap, char *buffer, size_t buflen,
147e83
     return NSS_STATUS_UNAVAIL;
147e83
 
147e83
   datap->type = triple_val;
147e83
-  datap->val.triple.host = datap->cursor;
147e83
+  datap->val.triple.host = get_nonempty_val (datap->cursor);
147e83
   datap->cursor = (char *) __rawmemchr (datap->cursor, '\0') + 1;
147e83
-  datap->val.triple.user = datap->cursor;
147e83
+  datap->val.triple.user = get_nonempty_val (datap->cursor);
147e83
   datap->cursor = (char *) __rawmemchr (datap->cursor, '\0') + 1;
147e83
-  datap->val.triple.domain = datap->cursor;
147e83
+  datap->val.triple.domain = get_nonempty_val (datap->cursor);
147e83
   datap->cursor = (char *) __rawmemchr (datap->cursor, '\0') + 1;
147e83
 
147e83
   return NSS_STATUS_SUCCESS;