--- ypmatch.c Wed Apr 30 10:02:54 2003 +++ ypmatch.c Wed Apr 30 10:04:55 2003 @@ -29,7 +29,7 @@ #ifndef lint static const char rcsid[] = - "$FreeBSD: src/usr.bin/ypmatch/ypmatch.c,v 1.7.2.2 2002/02/15 00:46:56 des Exp $"; + "$FreeBSD: src/usr.bin/ypmatch/ypmatch.c,v 1.7.2.X 2002/02/15 00:46:56 des Exp $"; #endif /* not lint */ #include @@ -117,6 +117,18 @@ r = yp_match(domainname, inmap, inkey, strlen(inkey), &outbuf, &outbuflen); +/* + If we failed, try again including the terminating NULL in the key. + Some NIS servers include the NULL, notably SunOS 4.X. +*/ + if (r != 0 && r != YPERR_YPBIND) { + r = yp_match(domainname, inmap, inkey, + strlen(inkey)+1, &outbuf, &outbuflen); + if (r == 0 && outbuf[outbuflen-1] == '\0') { +/* since we added a NULL, let's remove it from the result */ + --outbuflen; + } + } switch (r) { case 0: if (key)