Subject: Re: bin/9513: ypmatch fails on mail.aliases, mail.byaddr from Solaris
To: None <greywolf@railgun.siteROCK.com>
From: Michael Eriksson <eramore@era-t.ericsson.se>
List: netbsd-bugs
Date: 03/01/2000 17:04:37
> 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