Subject: pkg/10396: rsync pkg does not build on IPv4 only kernel
To: None <gnats-bugs@gnats.netbsd.org>
From: Martin Husemann <martin@rumolt.teuto.de>
List: netbsd-bugs
Date: 06/19/2000 14:03:16
>Number:         10396
>Category:       pkg
>Synopsis:       rsync pkg does not build on IPv4 only kernel
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 19 14:04:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Martin Husemann
>Release:        current cvs updated on June 16, 2000
>Organization:
	
>Environment:
	
System: NetBSD rumolt.teuto.de 1.4ZD NetBSD 1.4ZD (RUMOLT) #0: Fri Jun 16 07:05:23 MEST 2000 martin@rumolt.teuto.de:/usr/src/sys-i4b/arch/i386/compile/RUMOLT i386


>Description:

When trying to build pkgsrc/net/rsync on a machine with IPv4 only kernel,
the autoconfiguration fails, since it supposes a bug in getaddrinfo.

>How-To-Repeat:

s.a.: it tries to compile this testprogram (debug output inserted by me), and
fails at inet6 = 0, inet 4 = 2, because the loop for inet6 never has been
done.

/* #include "confdefs.h" */

#include <stdio.h>
#include <sys/types.h>
#include <netdb.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>

main()
{
  int passive, gaierr, inet4 = 0, inet6 = 0;
  struct addrinfo hints, *ai, *aitop;
  char straddr[INET6_ADDRSTRLEN], strport[16];

  for (passive = 0; passive <= 1; passive++) {
    memset(&hints, 0, sizeof(hints));
    hints.ai_family = AF_UNSPEC;
    hints.ai_flags = passive ? AI_PASSIVE : 0;
    hints.ai_socktype = SOCK_STREAM;
    if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
      (void)gai_strerror(gaierr);
      fprintf(stderr, "getaddrinf() != 0\n");
      goto bad;
    }
    for (ai = aitop; ai; ai = ai->ai_next) {
      if (ai->ai_addr == NULL ||
          ai->ai_addrlen == 0 ||
          getnameinfo(ai->ai_addr, ai->ai_addrlen,
                      straddr, sizeof(straddr), strport, sizeof(strport),
                      NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
        fprintf(stderr, "getnameinfo != 0\n");
        goto bad;
      }
      if (strcmp(strport, "54321") != 0) {
      	fprintf(stderr, "strport != 0\n");
        goto bad;
      }
      switch (ai->ai_family) {
      case AF_INET:
        if (passive) {
          if (strcmp(straddr, "0.0.0.0") != 0) {
            fprintf(stderr, "0.0.0.0 != 0\n");
            goto bad;
          }
        } else {
          if (strcmp(straddr, "127.0.0.1") != 0) {
            fprintf(stderr, "loopback != 0\n");
            goto bad;
          }
        }
        inet4++;
        break;
      case AF_INET6:
        if (passive) {
          if (strcmp(straddr, "::") != 0) {
	    fprintf(stderr, ":: != 0\n");
            goto bad;
          }
        } else {
          if (strcmp(straddr, "::1") != 0) {
	    fprintf(stderr, "::1 != 0\n");
            goto bad;
          }
        }
        inet6++;
        break;
      case AF_UNSPEC:
        fprintf(stderr, "AF_UNSPEC\n");
        goto bad;
        break;
      default:
        /* another family support? */
        break;
      }
    }
  }

  if (inet6 != 2 || inet4 != 2) {
    fprintf(stderr, "inet6 = %d, inet4 = %d\n", inet6, inet4);
    goto bad;
  }

  if (aitop)
    freeaddrinfo(aitop);
  exit(0);

 bad:
  if (aitop)
    freeaddrinfo(aitop);
  exit(1);
}

>Fix:
n/a
>Release-Note:
>Audit-Trail:
>Unformatted: