changeset 3386:ceea3e620194

6496648 New nsswitch doesn't handle netmasks entries with comments appended 6508109 getgrent[_r] can't get entry from ldap backend 6508123 getauuserent[_r] and getuserattr can't get entry with compat backend. 6510271 nss_nis returns NSS_SUCCESS when no netgroup can be found
author michen
date Mon, 08 Jan 2007 20:18:15 -0800
parents 262d8d58ab35
children 419a59452232
files usr/src/lib/nsswitch/compat/common/compat_common.c usr/src/lib/nsswitch/files/common/netmasks.c usr/src/lib/nsswitch/ldap/common/getgrent.c usr/src/lib/nsswitch/nis/common/getnetgrent.c
diffstat 4 files changed, 29 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/lib/nsswitch/compat/common/compat_common.c	Mon Jan 08 20:02:52 2007 -0800
+++ b/usr/src/lib/nsswitch/compat/common/compat_common.c	Mon Jan 08 20:18:15 2007 -0800
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  *
  * Common code and structures used by name-service-switch "compat" backends.
@@ -544,21 +544,30 @@
 	/*
 	 * assume a NULL buf.result pointer is an indication
 	 * that the lookup result should be returned in /etc
-	 * file format
+	 * file format (if called from _nss_compat_getent(),
+	 * be->return_string_data and argp->buf.result
+	 * would be set already if argp->buf.result is NULL)
 	 */
-	if (argp->buf.result == NULL) {
-		be->return_string_data = 1;
+	if (check != NULL) {
+		if (argp->buf.result == NULL) {
+			be->return_string_data = 1;
 
-		/*
-		 * the code executed later needs the result struct
-		 * as working area
-		 */
-		argp->buf.result = be->workarea;
+			/*
+			 * the code executed later needs the result struct
+			 * as working area
+			 */
+			argp->buf.result = be->workarea;
+		} else
+			be->return_string_data = 0;
+	}
+
+	/*
+	 * use an alternate str2ent function if necessary
+	 */
+	if (be->return_string_data == 1)
 		func = be->str2ent_alt;
-	} else {
-		be->return_string_data = 0;
+	else
 		func = argp->str2ent;
-	}
 
 	/*CONSTCOND*/
 	while (1) {
--- a/usr/src/lib/nsswitch/files/common/netmasks.c	Mon Jan 08 20:02:52 2007 -0800
+++ b/usr/src/lib/nsswitch/files/common/netmasks.c	Mon Jan 08 20:18:15 2007 -0800
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  *
  * files/netmasks.c -- "files" backend for nsswitch "netmasks" database
@@ -100,7 +100,7 @@
 		argp->buf.buffer = tmpbuf;
 		argp->buf.buflen = NSS_LINELEN_NETMASKS;
 	}
-	res = _nss_files_XY_all(be, argp, 0, argp->key.name, check_addr);
+	res = _nss_files_XY_all(be, argp, 1, argp->key.name, check_addr);
 	if (argp->buf.result != NULL) {
 		argp->buf.buffer = NULL;
 		argp->buf.buflen = 0;
--- a/usr/src/lib/nsswitch/ldap/common/getgrent.c	Mon Jan 08 20:02:52 2007 -0800
+++ b/usr/src/lib/nsswitch/ldap/common/getgrent.c	Mon Jan 08 20:18:15 2007 -0800
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -127,8 +127,8 @@
 
 	members = __ns_ldap_getAttrStruct(result->entry, _G_MEM);
 	if (members == NULL || members->attrvalue == NULL) {
-		nss_result = NSS_STR_PARSE_PARSE;
-		goto result_grp2str;
+		/* no member is fine, skip processing the member list */
+		goto nomember;
 	}
 
 	for (i = 0; i < members->value_count; i++) {
@@ -147,6 +147,7 @@
 			TEST_AND_ADJUST(len, buffer, buflen, result_grp2str);
 		}
 	}
+nomember:
 	/* The front end marshaller doesn't need the trailing nulls */
 	if (argp->buf.result != NULL)
 		be->buflen = strlen(be->buffer);
--- a/usr/src/lib/nsswitch/nis/common/getnetgrent.c	Mon Jan 08 20:02:52 2007 -0800
+++ b/usr/src/lib/nsswitch/nis/common/getnetgrent.c	Mon Jan 08 20:18:15 2007 -0800
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -805,7 +805,7 @@
 /* =====> is this (an authoritative "no") always the right thing to do?	*/
 /*	  Answer:  yes, except for hostnames that aren't all lowercase	*/
 
-	*statusp = NSS_SUCCESS;		/* Yup, three different flavours of */
+	*statusp = NSS_NOTFOUND;	/* Yup, three different flavours of */
 	ia->status = NSS_NETGR_NO;	/*   status information, so-called. */
 	return (1);			/*   Silly, innit?		    */
 }