[Kimchi-devel] [WIP 3/4] An example to demo how pam_members.so is used

Shu Ming shuming at linux.vnet.ibm.com
Wed Jan 29 17:07:59 UTC 2014


See the comments in pam_members.c in detail

Signed-off-by: Shu Ming <shuming at linux.vnet.ibm.com>
---
 src/kimchi/pamauth_acc.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 src/kimchi/pamauth_acc.py

diff --git a/src/kimchi/pamauth_acc.py b/src/kimchi/pamauth_acc.py
new file mode 100644
index 0000000..da6a4c2
--- /dev/null
+++ b/src/kimchi/pamauth_acc.py
@@ -0,0 +1,51 @@
+# An example to demo how pam_members.so is used
+# See the comments in pam_members.c
+#!/usr/bin/env python
+
+import sys
+import PAM
+
+if __name__ == '__main__':
+
+    if len(sys.argv) == 2:
+        user = sys.argv[1]
+    else:
+        user = None
+
+    auth = PAM.pam()
+    auth.start('vmadmin')
+
+    if user != None:
+        auth.set_item(PAM.PAM_USER, user)
+
+    auth.set_userdata("vmadmin data")
+
+    try:
+        auth.acct_mgmt()
+    except PAM.error, (resp, code):
+        print 'Not vmadmin'
+        print 'Go away! (%s)' % resp
+    except:
+        print 'Internal error'
+    else:
+        print 'Good to go!'
+
+    service = 'vmusr'
+    auth = PAM.pam()
+    auth.start('vmuser')
+
+    if user != None:
+        auth.set_item(PAM.PAM_USER, user)
+
+    auth.set_userdata("vmuser data")
+
+    try:
+        auth.acct_mgmt()
+    except PAM.error, (resp, code):
+        print 'Not vmuser'
+        print 'Go away! (%s)' % resp
+    except:
+        print 'Internal error'
+    else:
+        print 'Good to go!'
+
-- 
1.8.1.4




More information about the Kimchi-devel mailing list