Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set ARES_AI_NUMERICSERV hint flags when calling ares_getaddrinfo #9694

Closed
wants to merge 1 commit into from

Conversation

bsergean
Copy link
Contributor

@bsergean bsergean commented Oct 10, 2022

The hint flag is ARES_AI_NUMERICSERV, and it will save a call to getservbyname or getservbyname_r to set it.

This is where the hint flag is used in the C-Ares library -> https://github.com/c-ares/c-ares/blob/main/src/lib/ares_getaddrinfo.c#L645

For context we are trying to make a static binary that can run on any linux box, however that fails as not setting the hint triggers a getservbyname_r calls, which in turn loads the nss libraries which might not be on a different linux box (possible if that box runs alpine).

[pid 42269] openat(AT_FDCWD, "/etc/services", O_RDONLY|O_CLOEXEC) = 76
 > /lib/x86_64-linux-gnu/libc-2.27.so(__open_nocancel+0x41) [0x10fd61]
 > /lib/x86_64-linux-gnu/libc-2.27.so(_IO_file_fopen+0x79d) [0x8cbed]
 > /lib/x86_64-linux-gnu/libc-2.27.so(fopen+0x7a) [0x7ee5a]
 > /lib/x86_64-linux-gnu/libnss_files-2.27.so(_nss_files_getservbyname_r+0x39) [0x31a9]
 > /path/to/our/app(__getservbyname_r+0x153) [0x175a4f3]

The hint flag is ARES_AI_NUMERICSERV, and it will save a call to getservbyname or getservbyname_r to set it.
@bsergean bsergean changed the title Set hint flags when calling ares_getaddrinfo Set ARES_AI_NUMERICSERV hint flags when calling ares_getaddrinfo Oct 10, 2022
@bsergean
Copy link
Contributor Author

I think that the FreeBSD test failures are unrelated.

@bagder
Copy link
Member

bagder commented Oct 11, 2022

I think that the FreeBSD test failures are unrelated.

Oh yes, they most definitely are unrelated.

@bagder bagder closed this in e71a9b4 Oct 11, 2022
@bagder
Copy link
Member

bagder commented Oct 11, 2022

Thanks!

@bsergean
Copy link
Contributor Author

Thanks for taking a look and merging !

obonaventure pushed a commit to mptcp-apps/curl that referenced this pull request Oct 12, 2022
The hint flag is ARES_AI_NUMERICSERV, and it will save a call to
getservbyname or getservbyname_r to set it.

Closes curl#9694
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants