[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getaddrinfo() and AI_CANONNAME




This appears to be a bug in AIX.

#include <netdb.h>
#include <stdio.h>

main()
{
  char hostname[128];
  struct hostent *hp;
  struct addrinfo *res, *ai;
  struct addrinfo hints;
  gethostname(hostname, sizeof(hostname));
  printf("hostname = %s\n", hostname);
  hp = gethostbyname(hostname);
  if(hp != NULL)
    printf("h_name = %s\n", hp->h_name);
  memset(&hints, 0, sizeof(hints));
  hints.ai_flags = AI_CANONNAME;
  getaddrinfo(hostname, NULL, &hints, &res);
  for(ai = res; ai; ai = ai->ai_next) {
    printf("ai_canonname = %s\n", ai->ai_canonname);
  }
}

echo 10.0.0.1 `hostname` `hostname | sed 's/\..*//'` > /etc/hosts

and running the above with NSORDER="bind local" and "local bind" gives
different results, swapping the hostnames in /etc/hosts makes
getaddrinfo dtrt and gethostbyname dtwt. I'll see if I can file bug
report to IBM (not that it usually makes a difference).

/Johan