getnameinfo problems in glibc 2.4

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

getnameinfo problems in glibc 2.4

I am a maintainer of a custom Linux distro for my companies products
(MIPS based HPC platform).  I am upgrading the entire system from
gcc-3.4.3/glibc-2.3.3 to gcc-4.2/glibc-2.4 and I have run into a quirk
with telnet.  I'm not sure if this is a bug or a new feature I don't
understand.  It works as expected in glibc-2.3.3.

Telnet calls getnaminfo with the following line of code:

    error = getnameinfo (who, who_len,
                  NULL, 0,
                  registerd_host_only ? NI_NAMEREQD : 0);

I seems to not matter what registerd_host_only is set to (it is normally
0), if I do not have a name server configured, I get an error return
value (EAI_AGAIN).  I can work around it with a hosts line in
nsswitch.conf as:

hosts:      files dns [NOTFOUND=success]

Maybe I am misinterpretting the NI_NAMEREQD flag.  the man page says:

   If set, then a error is returned if the hostname cannot be looked

So what happens if NI_NAMEREQD is not set? My logic inverts this as:

   If not set, then a error is not returned if the hostname cannot be looked
But that is not what is happening.  If a nameserver is not found
(without the [NOTFOUND=success] in nsswitch.conf), getnameinfo returns
EAI_AGAIN.  Seems redundant.

Can someone enlighten me on the correct way to handle this?