Sorry for the late reply.

Adam, could you run the attached example program (derived from the
getaddrinfo and getnameinfo manpages) please? The output should help us
narrow down whether the problem is with the application code of sslh or
something in the environment.

Use: gcc -Wall -o gai gai.c && ./gai localhost 9002

Thanks.

On Sat, May 6, 2017 at 8:57 PM, Adam Borowski <kilob...@angband.pl> wrote:

> On Sat, May 06, 2017 at 08:00:11PM +0200, Michael Stapelberg wrote:
> > Thanks. It seems like getaddrinfo() is returning two results when
> resolving
> > localhost. Can you provide the contents of your hostname
> resolution-related
> > configuration please? I.e., /etc/hosts, /etc/resolv.conf,
> > /etc/nsswitch.conf, anything else you might have tweaked in that area.
>
> nsswitch.conf: always default.
>
>
> amd64 (100% fails on all chroots):
> .--====[ /etc/hosts ]
> 127.0.0.1       localhost
> 127.0.1.1       umbar.angband.pl        umbar
> #lots of commented out stuff
>
> # The following lines are desirable for IPv6 capable hosts
> ::1     localhost ip6-localhost ip6-loopback
> ff02::1 ip6-allnodes
> ff02::2 ip6-allrouters
> +--====[ /etc/resolv.conf ]
> domain angband.pl
> search angband.pl
> nameserver 2001:6a0:118::3:2
> `----
>
> armhf (100% fails on all chroots):
> .--====[ /etc/hosts ]
> 127.0.0.1       localhost
> ::1             localhost ip6-localhost ip6-loopback
> fe00::0         ip6-localnet
> ff00::0         ip6-mcastprefix
> ff02::1         ip6-allnodes
> ff02::2         ip6-allrouters
>
> 127.0.0.1  kholdan      kholdan.angband.pl
> 2001:6a0:118::3:6       narchost
> #2001:6a0:118::3:3      apt.angband.pl
> +--====[ /etc/resolv.conf ]
> domain angband.pl
> search angband.pl
> nameserver 10.0.1.2
> `----
>
> arm64 (100% ok on all chroots):
> .--====[ /etc/hosts ]
> 127.0.0.1       localhost
> 127.0.1.1       sirius.angband.pl sirius
>
> # The following lines are desirable for IPv6 capable hosts
> ::1     localhost ip6-localhost ip6-loopback
> fe00::0 ip6-localnet
> ff00::0 ip6-mcastprefix
> ff02::1 ip6-allnodes
> ff02::2 ip6-allrouters
> +--====[ /etc/resolv.conf ]
> domain angband.pl
> nameserver 10.0.1.2
> nameserver 2001:6a0:118::3:2
> `----
>
> (10.0.1.2 is same as 2001:6a0:118::3:2)
>
> --
> Don't be racist.  White, amber or black, all beers should be judged based
> solely on their merits.  Heck, even if occasionally a cider applies for a
> beer's job, why not?
> On the other hand, corpo lager is not a race.
>



-- 
Best regards,
Michael
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

int main(int argc, char *argv[]) {
    struct addrinfo hints;
    struct addrinfo *result, *rp;
    int s;

    if (argc < 3) {
        fprintf(stderr, "Usage: %s host port...\n", argv[0]);
        exit(EXIT_FAILURE);
    }

    /* Obtain address(es) matching host/port */

    memset(&hints, 0, sizeof(struct addrinfo));
    hints.ai_family = AF_UNSPEC;    /* Allow IPv4 or IPv6 */
    hints.ai_socktype = SOCK_DGRAM; /* Datagram socket */
    hints.ai_flags = 0;
    hints.ai_protocol = 0;          /* Any protocol */

    s = getaddrinfo(argv[1], argv[2], &hints, &result);
    if (s != 0) {
        fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(s));
        exit(EXIT_FAILURE);
    }

	printf("printing getaddrinfo(%s, %s) results:\n", argv[1], argv[2]);
	printf("\n");
    for (rp = result; rp != NULL; rp = rp->ai_next) {
		printf("  ai_family = %d\n", rp->ai_family);
		printf("  ai_socktype = %d\n", rp->ai_socktype);
		printf("  ai_protocol = %d\n", rp->ai_protocol);
		printf("  rp->ai_addrlen = %d\n", rp->ai_addrlen);
		char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
		if (getnameinfo(rp->ai_addr, rp->ai_addrlen, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) == 0)
			printf("    host=%s, serv=%s\n", hbuf, sbuf);
		printf("\n");
    }
	printf("done\n");
}

Reply via email to