python > 3.5: Issue with unix domain sockets

Corinna Vinschen corinna-cygwin@cygwin.com
Thu May 6 08:35:33 GMT 2021


On May  4 22:04, Mark Geisert wrote:
> Corinna Vinschen wrote:
> > On May  4 02:45, Mark Geisert wrote:
> > > [blah blah...]
> > You're supposed to call the special setsockopt(SO_PEERCRED) on the
> > accepting socket.  The no_getpeereid property is inherited by the
> > accepted socket.
> 
> Ah, of course.  Well, I couldn't figure out a way to do the setsockopt()
> call some times but not others, because Python can't reach into the Cygwin
> DLL.  Nor should it.
> 
> Since this Python patch is supposed to be a temporary workaround, I took the
> tack that it should just ignore an error return from
> setsockopt(SO_PEERCRED).  In this fashion the handshake will be turned off
> when it can be, and when it can't (on the accepted socket) the attempt will
> error but that error will be ignored.

Sorry Mark, but I don't understand how you concluded that ignoring the
error from setsockopt(SO_PEERCRED) is the solution I pointed out above.

The right thing to do is to call setsockopt(SO_PEERCRED) (and check its
return value) before calling listen() on the accepting socket.  The
no_getpeereid property gets propagated to the accepted sockets and thus
there's no need to call it again for these sockets.


Corinna


More information about the Cygwin-developers mailing list