News for hackers. Stuff that matters.
Re:Getaddrinfo() on glibc calls getenv(), oh boy by LoganDark on Monday October 16, 2023 @09:13PM (#37909028)
getaddrinfo is terrible. Did you know it also opens and then connects to a socket? Any process that uses getaddrinfo needs a blanket exception in my firewall in order to work properly, because otherwise it will fail to connect to some randomly-generated port that it just made up.
Re:Getaddrinfo() on glibc calls getenv(), oh boy by tedunangst on Monday October 16, 2023 @09:25PM (#37909155)
What should I use instead that doesn't open a socket?
Re:Getaddrinfo() on glibc calls getenv(), oh boy by hknapp on Monday October 16, 2023 @09:35PM (#37909256)
They probably could have given a more apt name
Re:Getaddrinfo() on glibc calls getenv(), oh boy by Sprocklem on Monday October 16, 2023 @09:53PM (#37909440)
How do you propose that DNS resolution precede without opening a socket?
Re:Getaddrinfo() on glibc calls getenv(), oh boy by nomadluap on Monday October 16, 2023 @10:49PM (#37909929)
For one thing, it could delegate to a local service. Granted, the communication to this service is probably still be over a socket interface, but at least as a purely-local connection you would hopefully have some better worst-case performance characteristics.

This is basically what dnsmasq does when you use it as a local DNS cache.

Re:Getaddrinfo() on glibc calls getenv(), oh boy by kccqzy on Monday October 16, 2023 @11:20PM (#37910161)
Completely agree. Just use systemd-resolved which is the recommended way of doing DNS anyway.
Re:Getaddrinfo() on glibc calls getenv(), oh boy by guappa on Tuesday October 17, 2023 @03:25AM (#37911659)
And how do you communicate with systemd-resolved?
Re:Getaddrinfo() on glibc calls getenv(), oh boy by mambru on Tuesday October 17, 2023 @05:16AM (#37912394)
Re:Getaddrinfo() on glibc calls getenv(), oh boy by guappa on Tuesday October 17, 2023 @09:27AM (#37914692)
dbus is just a protocol that needs something else to actually transfer the data.

Normally, that's a socket in /run/dbus/system_bus_socket

Re:Getaddrinfo() on glibc calls getenv(), oh boy by kccqzy on Tuesday October 17, 2023 @01:09PM (#37918176)
And guess what. A UNIX socket does not use DNS or the damned getaddrinfo() function that's the ire of the article.
Re:Getaddrinfo() on glibc calls getenv(), oh boy by LoganDark on Monday October 16, 2023 @11:54PM (#37910392)
It opens a socket to the same process that called getaddrinfo. That is, it's just communicating with itself, using a brand-new randomly-generated port for each call. This should be completely unnecessary.
Re:Getaddrinfo() on glibc calls getenv(), oh boy by JackSlateur on Tuesday October 17, 2023 @08:18AM (#37913824)
So, I have a program that does getaddrinfo(3) and nothing more, and this program setup a socket, listen(2) to it, create another socket and connect with it to the first one ?

This looks insane and not what strace(1) tells me

Could you give me more details ?

Re:Getaddrinfo() on glibc calls getenv(), oh boy by LoganDark on Tuesday October 17, 2023 @05:13PM (#37921657)
I didn't know glibc didn't do the same thing. `getaddrinfo()` on Windows seems to do this because randomly a program will try to connect to `::1:59962` or something, and if I don't allow it in my firewall, it will start whining that some getaddrinfo thread failed to start. This has happened across all sorts of different programs. It's infuriating.