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