NetBSD Problem Report #9513

Received: (qmail 21434 invoked from network); 1 Mar 2000 00:10:03 -0000
Message-Id: <200003010009.QAA01488@railgun.siteROCK.com>
Date: Tue, 29 Feb 2000 16:09:13 -0800 (PST)
From: greywolf@siterock.com
Reply-To: greywolf@starwolf.com
To: gnats-bugs@gnats.netbsd.org
Subject: ypmatch fails on mail.aliases, mail.byaddr from Solaris
X-Send-Pr-Version: 3.95

>Number:         9513
>Category:       bin
>Synopsis:       ypmatch fails on mail.aliases, mail.byaddr from Solaris
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 29 16:12:01 +0000 2000
>Closed-Date:    Sat Apr 12 09:14:36 +0000 2003
>Last-Modified:  Sat Apr 12 09:15:00 +0000 2003
>Originator:     
>Release:        netbsd-current 20000223
>Organization:
siteROCK corporation
>Environment:

System: NetBSD railgun.siteROCK.com 1.4T NetBSD 1.4T (RAILGUN) #1: Fri Feb 25 18:46:09 PST 2000 root@:/usr/src/sys/arch/i386/compile/RAILGUN i386


>Description:
	There is a non-matchable space at the beginning of keys retrieved
	from the mail.aliases and mail.byaddr maps from a solaris NIS server.
	This prevents pine (among others) from resolving mail aliases, even
	if you're set to forward to the mailhost and let it resolve.  This is
	arguably a different problem.
>How-To-Repeat:
	ypcat -k mail.aliases | head -1
	ypcat -k mail.byaddr | head -1
	[note leading space]
>Fix:

>Release-Note:
>Audit-Trail:

From: Michael Eriksson <eramore@era-t.ericsson.se>
To: greywolf@railgun.siteROCK.com
Cc: netbsd-bugs@netbsd.org, gnats-bugs@gnats.netbsd.org
Subject: Re: bin/9513: ypmatch fails on mail.aliases, mail.byaddr from Solaris
Date: Wed, 1 Mar 2000 17:04:37 +0100 (CET)

 > 	There is a non-matchable space at the beginning of keys retrieved
 > 	from the mail.aliases and mail.byaddr maps from a solaris NIS server.
 > 	This prevents pine (among others) from resolving mail aliases, even
 > 	if you're set to forward to the mailhost and let it resolve.  This is
 > 	arguably a different problem.

 There's no "non-matchable space". The problem is rather that each key
 (and each value) includes a trailing NUL byte, which happens to be
 sendmails traditional database format for /etc/sendmail.db.

 I happen to have some patches for that lying around, which adds an
 "-z" flag to ypmatch. I haven't really gotten around to send them in,
 so I guess this is a good time...

 Index: ypmatch.1
 ===================================================================
 RCS file: /cvsroot/basesrc/usr.bin/ypmatch/ypmatch.1,v
 retrieving revision 1.8
 diff -u -r1.8 ypmatch.1
 --- ypmatch.1	1999/11/19 01:12:43	1.8
 +++ ypmatch.1	2000/03/01 16:01:11
 @@ -36,7 +36,7 @@
  .Nd "print the values of one or more keys in a YP database"
  .Sh SYNOPSIS
  .Nm
 -.Op Fl kt
 +.Op Fl ktz
  .Op Fl d Ar domainname
  .Ar key ...
  .Ar mapname
 @@ -63,6 +63,10 @@
  to their corresponding map names.
  .It Fl x
  Display the map nickname table.
 +.It Fl z
 +Append a NUL character at the end of the key when doing the lookup.
 +This is useful for mail.aliases maps, which include a trailing NUL in
 +the keys.
  .El
  .Sh SEE ALSO
  .Xr domainname 1 ,
 Index: ypmatch.c
 ===================================================================
 RCS file: /cvsroot/basesrc/usr.bin/ypmatch/ypmatch.c,v
 retrieving revision 1.10
 diff -u -r1.10 ypmatch.c
 --- ypmatch.c	1997/07/18 07:05:36	1.10
 +++ ypmatch.c	2000/03/01 16:01:11
 @@ -78,13 +78,13 @@
  	char *inkey, *inmap, *outbuf;
  	extern char *optarg;
  	extern int optind;
 -	int outbuflen, key, notrans;
 -	int c, r, i;
 +	int outbuflen, key, null, notrans;
 +	int c, r, i, len;
  	int rval;

  	domainname = NULL;
 -	notrans = key = 0;
 -	while ((c = getopt(argc, argv, "xd:kt")) != -1) {
 +	notrans = key = null = 0;
 +	while ((c = getopt(argc, argv, "xd:ktz")) != -1) {
  		switch (c) {
  		case 'x':
  			for(i = 0;
 @@ -106,6 +106,10 @@
  			key++;
  			break;

 +		case 'z':
 +			null++;
 +			break;
 +
  		default:
  			usage();
  		}
 @@ -131,13 +135,17 @@
  	for(i = 0; i < (argc - 1); i++) {
  		inkey = argv[i];

 -		r = yp_match(domainname, inmap, inkey, strlen(inkey),
 +		len = strlen(inkey);
 +		if (null)
 +			len++;
 +		r = yp_match(domainname, inmap, inkey, len,
  		    &outbuf, &outbuflen);
  		switch (r) {
  		case 0:
  			if (key)
  				printf("%s: ", inkey);
 -			printf("%*.*s\n", outbuflen, outbuflen, outbuf);
 +			fwrite(outbuf, outbuflen, 1, stdout);
 +			putc('\n', stdout);
  			break;

  		case YPERR_YPBIND:
 @@ -158,7 +166,7 @@
  usage()
  {

 -	fprintf(stderr, "usage: %s [-d domain] [-t] [-k] key [key ...] "
 +	fprintf(stderr, "usage: %s [-d domain] [-t] [-k] [-z] key [key ...] "
  	    "mapname\n", __progname);
  	fprintf(stderr, "       %s -x\n", __progname);
  	exit(1);
 -- 
 Michael Eriksson <eramore@era-t.ericsson.se>
 NO CARRIER
State-Changed-From-To: open->closed 
State-Changed-By: christos 
State-Changed-When: Sat Apr 12 05:06:32 EDT 2003 
State-Changed-Why:  
fixed, thanks 

From: Christos Zoulas <christos@netbsd.org>
To: gnats-bugs@gnats.netbsd.org
Cc:  
Subject: pr/9513 CVS commit: src/usr.bin/ypmatch
Date: Sat, 12 Apr 2003 12:13:30 +0300 (EEST)

 Module Name:	src
 Committed By:	christos
 Date:		Sat Apr 12 09:13:29 UTC 2003

 Modified Files:
 	src/usr.bin/ypmatch: ypmatch.1 ypmatch.c

 Log Message:
 PR/9513: Graywolf: ypmatch fails on mail.aliases, mail.byaddr from Solaris


 To generate a diff of this commit:
 cvs rdiff -r1.11 -r1.12 src/usr.bin/ypmatch/ypmatch.1
 cvs rdiff -r1.13 -r1.14 src/usr.bin/ypmatch/ypmatch.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.