From owner-freebsd-bugs@FreeBSD.ORG Wed Apr 30 08:30:10 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 75AFA37B401 for ; Wed, 30 Apr 2003 08:30:10 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5B0AA43F85 for ; Wed, 30 Apr 2003 08:30:09 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h3UFU6Up025335 for ; Wed, 30 Apr 2003 08:30:06 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h3UFU6J7025334; Wed, 30 Apr 2003 08:30:06 -0700 (PDT) Resent-Date: Wed, 30 Apr 2003 08:30:06 -0700 (PDT) Resent-Message-Id: <200304301530.h3UFU6J7025334@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Keith White Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 27E6137B401 for ; Wed, 30 Apr 2003 08:20:44 -0700 (PDT) Received: from mail.site.uottawa.ca (mailn.site.uottawa.ca [137.122.89.142]) by mx1.FreeBSD.org (Postfix) with ESMTP id AD23243F3F for ; Wed, 30 Apr 2003 08:20:40 -0700 (PDT) (envelope-from Keith.White@site.uottawa.ca) Received: from admin16.site.uottawa.ca (admin16.site.uottawa.ca [137.122.90.250]) by mail.site.uottawa.ca (8.9.3/8.9.3) with ESMTP id LAA52899 for ; Wed, 30 Apr 2003 11:20:39 -0400 (EDT) Received: from admin16.site.uottawa.ca (localhost [127.0.0.1]) h3UFKdW5029291 for ; Wed, 30 Apr 2003 11:20:39 -0400 (EDT) (envelope-from kwhite@admin16.site.uottawa.ca) Received: (from kwhite@localhost) by admin16.site.uottawa.ca (8.12.9/8.12.9/Submit) id h3UFKd9R029290; Wed, 30 Apr 2003 11:20:39 -0400 (EDT) Message-Id: <200304301520.h3UFKd9R029290@admin16.site.uottawa.ca> Date: Wed, 30 Apr 2003 11:20:39 -0400 (EDT) From: Keith White To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/51628: ypmatch doesn't match keys in legacy NIS servers X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Keith White List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Apr 2003 15:30:10 -0000 >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 @@ -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: