0

I have a program (written in C) that uses getaddrinfo() and its first parameter is the host name that I want it to get address information about, let's say it is "domain". In my /etc/hosts file on the same machine I can see that "domain" is supposed to resolve to 192.168.1.200. When I run the program it hangs on this call every time and cannot get the address information. However, if I replace "domain" with the actual IP Address, it works just fine.

By the way, this problem didn't exist a week or so ago, it is a new problem that has suddenly reared it's ugly head. I am fairly certain that something must have been done to this machine in the last week, and I have attempted to verify this with our other staff, but they also have no idea why this would occur.

So, my question is, does anyone out there have any idea what this would suddenly be occurring? What can I check to verify that it is configured how it should be? Thanks in advance.

glglgl
  • 89,107
  • 13
  • 149
  • 217
LebowskiT1000
  • 21
  • 1
  • 5

1 Answers1

1

Are you using Linux? My guess is that you've messed up something with the libnss mess glibc uses to route all its name lookups (hostnames, usernames, group names, etc.), perhaps by a botched glibc upgrade. Try running your program with strace and see if it's trying (and failing) to open libnss_* files. Also look in /etc/nsswitch.conf to make sure the hosts: line reads hosts: files dns. man nsswitch.conf could be helpful.

R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711
  • Yes sorry, we are using Linux (Gentoo) and it is possibly a botched glibc upgrade problem, I will look into that. Thank you. – LebowskiT1000 Nov 11 '10 at 23:48
  • Turns out I was making a big assumption DOH! I wrote a short little program using the function in question and worked no problem! After some more searching and debugging, I found it was a problem with the data it was getting back from the socket connection I was making. Sorry for the trouble, but thanks for the help. – LebowskiT1000 Nov 12 '10 at 01:58