lists.arthurdejong.org
RSS feed

nss-pam-ldapd commit: r1640 - nss-pam-ldapd/pynslcd

[Date Prev][Date Next] [Thread Prev][Thread Next]

nss-pam-ldapd commit: r1640 - nss-pam-ldapd/pynslcd



Author: arthur
Date: Fri Mar 16 13:48:28 2012
New Revision: 1640
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?revision=1640&view=revision

Log:
implement a getpeercred() function

Modified:
   nss-pam-ldapd/pynslcd/pynslcd.py

Modified: nss-pam-ldapd/pynslcd/pynslcd.py
==============================================================================
--- nss-pam-ldapd/pynslcd/pynslcd.py    Fri Mar 16 10:46:34 2012        (r1639)
+++ nss-pam-ldapd/pynslcd/pynslcd.py    Fri Mar 16 13:48:28 2012        (r1640)
@@ -169,8 +169,13 @@
 
 
 def getpeercred(fd):
-    return (None, None, None)
-    # FIXME: implement and return uid, gid, pid
+    """Return uid, gid and pid of calling application."""
+    import struct
+    import socket
+    SO_PEERCRED = 17
+    creds = fd.getsockopt(socket.SOL_SOCKET, SO_PEERCRED, 
struct.calcsize('3i'))
+    pid, uid, gid = struct.unpack('3i',creds)
+    return uid, gid, pid
 
 
 handlers = {}
-- 
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits/