Patches item #1492240, was opened at 2006-05-20 17:39 Message generated for change (Comment added) made by collinwinter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1492240&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Library (Lib) Group: Python 2.5 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Heiko Wundram (hwundram) Assigned to: Nobody/Anonymous (nobody) Summary: Socket-object convenience function: getpeercred(). Initial Comment: The attached patch implements a convenience function called getpeercred() which internally calls getsockopt(SO_PEERCRED) to retrieve the credentials (pid, uid and gid) of the remote process a socket is attached to, in case the remote end is local. This currently (AFAIK) only works (properly) on Linux 2.4+, but might work on BSD-style systems too. The returned data is wrapped in a new ucred type, which is subclassable to implement additional convenience functions in Lib/socket.py. The patch updates the socket module, the test suite, the documentation (including whatsnew), and adds a configure check for the definition of struct ucred in sys/socket.h, which is the default place for struct ucred if it is available. If struct ucred is not available on the current system, getpeercred() is made a dummy method, which returns a python-defined ucred type which contains pid=0, uid=gid=-1, which are the default values returned under Linux when the call fails because there is no credentials data associated with the socket. The decision to move the data to a separate type was made with respect to the ability to use struct ucred under other systems in a SCM_CREDENTIALS sendmsg() call. I'll post the implementation of sendmsg() and recvmsg() as a separate tracker item, but the latter patch will rely on the inclusion of this patch. ---------------------------------------------------------------------- Comment By: Collin Winter (collinwinter) Date: 2007-03-08 15:46 Message: Logged In: YES user_id=1344176 Originator: NO I'm uncomfortable with including something that only works on certain versions of a single platform. Are there any other functions or methods (not modules) that are only available for Linux? I can think of a number of places flagged as "Availability: Unix", but if getpeercred() doesn't work on the BSDs, it doesn't even meet that standard. If a decision is made to include this, and if it only works on Linux 2.4+, I'd rather see it not available at all on other platforms (rather than returning dummy values). ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1492240&group_id=5470 _______________________________________________ Patches mailing list [email protected] http://mail.python.org/mailman/listinfo/patches
