Date: Wed, 30 Apr 2003 11:20:39 -0400 (EDT) From: Keith White <Keith.White@site.uottawa.ca> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/51628: ypmatch doesn't match keys in legacy NIS servers Message-ID: <200304301520.h3UFKd9R029290@admin16.site.uottawa.ca> Resent-Message-ID: <200304301530.h3UFU6J7025334@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 51628 >Category: bin >Synopsis: ypmatch doesn't match keys in legacy NIS servers >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Apr 30 08:30:06 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Keith White >Release: FreeBSD 4.8-STABLE i386 >Organization: SITE, University of Ottawa >Environment: System: FreeBSD admin16.site.uottawa.ca 4.8-STABLE FreeBSD 4.8-STABLE #32: Mon Apr 28 13:44:12 EDT 2003 kwhite@admin16.site.uottawa.ca:/usr/obj/usr/src/sys/XBAT i386 >Description: ypmatch does not match keys in NIS databases that include the NULL in the key field. Databases that started out on SunOS 4.X, say, include NULL in both the key and data fields. This makes it impossible to use ypmatch to check for the existence of keys since the terminating NULL is removed prior to calling yp_match(). Try this against a SunOS 4.x NIS server: $ ypmatch @ aliases ypmatch: can't match key @ in map mail.aliases. reason: No such key in map Try it at the same time on a Solaris host: $ ypmatch @ aliases @ (FWIW the '@' key is used to signify that the NIS aliases database is up-to-date. When it doesn't exist the aliases database is in the process of being updated.) >How-To-Repeat: >Fix: The following patch will do another yp_match() call including the terminating NULL in the key if the first call failed. --- ypmatch.c.orig 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 <sys/param.h> @@ -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) >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304301520.h3UFKd9R029290>