News for hackers. Stuff that matters.
Re:Show HN: ip2unix – Turn IP sockets into Unix domain sockets by caf on Wednesday July 08, 2020 @08:11AM (#23769090)
Do any programs get confused when they call getsockname() and the result is an AF_UNIX they weren't expecting?
Re:Show HN: ip2unix – Turn IP sockets into Unix domain sockets by aszlig on Wednesday July 08, 2020 @09:30AM (#23769679)
If programs call getsockname() the result is not a sockaddr_un, but instead sockaddr_in(6) is used from the original call to bind(). If the socket was implicitly bound, a random[1] address is generated.

Things are a bit trickier if it gets to getpeername(), since we want to have somewhat stable addresses. This is done by querying SO_PEERCRED and encoding[2] the pid for IPv4 or pid, uid and gid for IPv6 into the address.

In summary: Programs shouldn't get confused, but if they do, it's certainly a bug in ip2unix. Feel free to open an issue :-)

[1]: https://github.com/nixcloud/ip2unix/blob/d7d297ed68cdadc65dc...

[2]: https://github.com/nixcloud/ip2unix/blob/d7d297ed68cdadc65dc...