(self)
Return the PID/UID/GID tuple of the peer socket for UNIX sockets.

        This function uses SO_PEERCRED to query the UNIX PID, UID, GID
        of the peer, which is only available if the bind address is
        a UNIX domain socket.

        Raises:
            NotImplementedError: in case of unsupported socket type
            RuntimeError: in case of SO_PEERCRED lookup unsupported or disabled
Return the PID/UID/GID tuple of the peer socket for UNIX sockets.
Return the PID / UID / GID tuple of the peer socket for UNIX sockets .
def get_peer_creds(self):  # LRU cached on per-instance basis, see __init__
        """Return the PID/UID/GID tuple of the peer socket for UNIX sockets.

        This function uses SO_PEERCRED to query the UNIX PID, UID, GID
        of the peer, which is only available if the bind address is
        a UNIX domain socket.

        Raises:
            NotImplementedError: in case of unsupported socket type
            RuntimeError: in case of SO_PEERCRED lookup unsupported or disabled

        """
        PEERCRED_STRUCT_DEF = '3i'

        if IS_WINDOWS or self.socket.family != socket.AF_UNIX:
            raise NotImplementedError(
                'SO_PEERCRED is only supported in Linux kernel and WSL',
            )
        elif not self.peercreds_enabled:
            raise RuntimeError(
                'Peer creds lookup is disabled within this server',
            )

        try:
            peer_creds = self.socket.getsockopt(
                # FIXME: Use LOCAL_CREDS for BSD-like OSs
                # Ref: https://gist.github.com/LucaFilipozzi/e4f1e118202aff27af6aadebda1b5d91  # noqa
                socket.SOL_SOCKET, socket.SO_PEERCRED,
                struct.calcsize(PEERCRED_STRUCT_DEF),
            )
        except socket.error as socket_err:
            """Non-Linux kernels don't support SO_PEERCRED.

            Refs:
            http://welz.org.za/notes/on-peer-cred.html
            https://github.com/daveti/tcpSockHack
            msdn.microsoft.com/en-us/commandline/wsl/release_notes#build-15025
            """
            six.raise_from(  # 3.6+: raise RuntimeError from socket_err
                RuntimeError,
                socket_err,
            )
        else:
            pid, uid, gid = struct.unpack(PEERCRED_STRUCT_DEF, peer_creds)
            return pid, uid, gid
def get_peer_creds ( self ) : # LRU cached on per-instance basis, see __init__ PEERCRED_STRUCT_DEF = '3i' if IS_WINDOWS or self . socket . family != socket . AF_UNIX : raise NotImplementedError ( 'SO_PEERCRED is only supported in Linux kernel and WSL' , ) elif not self . peercreds_enabled : raise RuntimeError ( 'Peer creds lookup is disabled within this server' , ) try : peer_creds = self . socket . getsockopt ( # FIXME: Use LOCAL_CREDS for BSD-like OSs # Ref: https://gist.github.com/LucaFilipozzi/e4f1e118202aff27af6aadebda1b5d91  # noqa socket . SOL_SOCKET , socket . SO_PEERCRED , struct . calcsize ( PEERCRED_STRUCT_DEF ) , ) except socket . error as socket_err : """Non-Linux kernels don't support SO_PEERCRED.

            Refs:
            http://welz.org.za/notes/on-peer-cred.html
            https://github.com/daveti/tcpSockHack
            msdn.microsoft.com/en-us/commandline/wsl/release_notes#build-15025
            """ six . raise_from ( # 3.6+: raise RuntimeError from socket_err RuntimeError , socket_err , ) else : pid , uid , gid = struct . unpack ( PEERCRED_STRUCT_DEF , peer_creds ) return pid , uid , gid