diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2012-03-16 13:48:28 +0100 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2012-03-16 13:48:28 +0100 |
commit | a67f3bfa1eb898a35dff5c5a834de6432999b862 (patch) | |
tree | ce0092d567553aa7e9a15ba29dc5df0ce16e6731 /pynslcd | |
parent | 274d1302917c8f373f9ecaee3adb1169d77ce35f (diff) |
implement a getpeercred() function
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1640 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'pynslcd')
-rwxr-xr-x | pynslcd/pynslcd.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/pynslcd/pynslcd.py b/pynslcd/pynslcd.py index 7cd8209..a053ad5 100755 --- a/pynslcd/pynslcd.py +++ b/pynslcd/pynslcd.py @@ -169,8 +169,13 @@ def log_newsession(): 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 = {} |