SVN: nss_python/trunk/doc/nss_python.py

arekm arekm at pld-linux.org
Sun Feb 18 14:05:46 CET 2007


Author: arekm
Date: Sun Feb 18 14:05:46 2007
New Revision: 8278

Modified:
   nss_python/trunk/doc/nss_python.py
Log:
Extended example.

Modified: nss_python/trunk/doc/nss_python.py
==============================================================================
--- nss_python/trunk/doc/nss_python.py	(original)
+++ nss_python/trunk/doc/nss_python.py	Sun Feb 18 14:05:46 2007
@@ -1,3 +1,5 @@
+#!/usr/bin/python
+# -*- coding: UTF-8 -*-
 #
 #    nss_python - NSS module which allows to write python bacends for NSS
 #    Copyright (C) 2007 Arkadiusz Miśkiewicz <arekm at pld-linux.org>
@@ -37,6 +39,9 @@
 # password
 
 u = ("some-user", "dfsdf", 2323, 4444, "gecos field", "/tmp", "/bin/false")
+u_tbl = [ u, u, u, u, u ]
+
+u_cnt = 0
 
 def pynss_getpwnam_r(login):
 	return u
@@ -44,14 +49,23 @@
 def pynss_getpwuid_r(uid):
 	return u
 
+# needs to return True
 def pynss_setpwent():
-	return
+	u_cnt = 0
+	return True
 
 def pynss_endpwent():
 	return
 
+# return False when there is no more entries
 def pynss_getpwent_r():
-	return
+	global u_cnt
+	if u_cnt >= len(u_tbl):
+		return False
+	ret = u_tbl[u_cnt]
+	u_cnt += 1
+	return ret
+
 
 # shadow
 s = ("some-login", "bleble", 0, 1, 2, 3, 4, 5, 6)


More information about the pld-cvs-commit mailing list