SVN: nss_python/trunk/src: nss_grp.c nss_pwd.c nss_spwd.c

arekm arekm at pld-linux.org
Sun Feb 18 13:17:48 CET 2007


Author: arekm
Date: Sun Feb 18 13:17:47 2007
New Revision: 8275

Modified:
   nss_python/trunk/src/nss_grp.c
   nss_python/trunk/src/nss_pwd.c
   nss_python/trunk/src/nss_spwd.c
Log:
get*ent() python functions can return False to indicate NSS_STATUS_UNAVAIL.

Modified: nss_python/trunk/src/nss_grp.c
==============================================================================
--- nss_python/trunk/src/nss_grp.c	(original)
+++ nss_python/trunk/src/nss_grp.c	Sun Feb 18 13:17:47 2007
@@ -267,9 +267,18 @@
 
 
 	pValue = PyObject_CallFunction(pynss_getgrent_r, NULL);
-	if (pValue == NULL || !PyTuple_Check(pValue)) {
+	if (pValue == NULL) {
 		if (DEBUG)
-			nss_python_log(LOG_ERR, "_nss_python_getgrent_r: calling pynss_getgrent_r python function failed or result is not a tuple");
+			nss_python_log(LOG_ERR, "_nss_python_getgrent_r: calling pynss_getgrent_r python function failed");
+		return NSS_STATUS_UNAVAIL;
+	}
+
+	if (PyBool_Check(pValue) && pValue == Py_False)
+		return NSS_STATUS_NOTFOUND;
+
+	if (!PyTuple_Check(pValue)) {
+		if (DEBUG)
+			nss_python_log(LOG_ERR, "_nss_python_getgrent_r: result is not a tuple or false boolean");
 		return NSS_STATUS_UNAVAIL;
 	}
 

Modified: nss_python/trunk/src/nss_pwd.c
==============================================================================
--- nss_python/trunk/src/nss_pwd.c	(original)
+++ nss_python/trunk/src/nss_pwd.c	Sun Feb 18 13:17:47 2007
@@ -261,9 +261,18 @@
 	}
 
 	pValue = PyObject_CallFunction(pynss_getpwent_r, NULL);
-	if (pValue == NULL || !PyTuple_Check(pValue)) {
+	if (pValue == NULL) {
 		if (DEBUG)
-			nss_python_log(LOG_ERR, "_nss_python_getpwent_r: calling pynss_getpwent_r python function failed or result is not a tuple");
+			nss_python_log(LOG_ERR, "_nss_python_getpwent_r: calling pynss_getpwent_r python function failed");
+		return NSS_STATUS_UNAVAIL;
+	}
+
+	if (PyBool_Check(pValue) && pValue == Py_False)
+		return NSS_STATUS_NOTFOUND;
+
+	if (!PyTuple_Check(pValue)) {
+		if (DEBUG)
+			nss_python_log(LOG_ERR, "_nss_python_getpwent_r: result is not a tuple or false boolean");
 		return NSS_STATUS_UNAVAIL;
 	}
 

Modified: nss_python/trunk/src/nss_spwd.c
==============================================================================
--- nss_python/trunk/src/nss_spwd.c	(original)
+++ nss_python/trunk/src/nss_spwd.c	Sun Feb 18 13:17:47 2007
@@ -272,9 +272,18 @@
 	}
 
 	pValue = PyObject_CallFunction(pynss_getspwent_r, NULL);
-	if (pValue == NULL || !PyTuple_Check(pValue)) {
+	if (pValue == NULL) {
 		if (DEBUG)
-			nss_python_log(LOG_ERR, "_nss_python_getspwent_r: calling pynss_getspwent_r python function failed or result is not a tuple");
+			nss_python_log(LOG_ERR, "_nss_python_getspwent_r: calling pynss_getspwent_r python function failed");
+		return NSS_STATUS_UNAVAIL;
+	}
+
+	if (PyBool_Check(pValue) && pValue == Py_False)
+		return NSS_STATUS_NOTFOUND;
+
+	if (!PyTuple_Check(pValue)) {
+		if (DEBUG)
+			nss_python_log(LOG_ERR, "_nss_python_getspwent_r: result is not a tuple or false boolean");
 		return NSS_STATUS_UNAVAIL;
 	}
 


More information about the pld-cvs-commit mailing list