summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ypserv/yp_dblookup.c
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>1998-02-11 19:15:32 +0000
committerwpaul <wpaul@FreeBSD.org>1998-02-11 19:15:32 +0000
commit02d038fd998585a7608df56138da13e4055bdfd9 (patch)
tree5ae4bf5154055f173471b14854e0c97cf969c450 /usr.sbin/ypserv/yp_dblookup.c
parent2f8caa4fd654ed1b60b4125cc7de07882455bddb (diff)
downloadFreeBSD-src-02d038fd998585a7608df56138da13e4055bdfd9.zip
FreeBSD-src-02d038fd998585a7608df56138da13e4055bdfd9.tar.gz
Fix a bug in the database handle caching. This has to do with the way the
underlying database code works. When dealing with first/next queries, you have the notion of a database 'cursor,' which is essentially a file pointer for the database. To select the first entry, you do a fetch with the R_FIRST flag set, then you can use the R_NEXT flag to enumerate the other entries in the database. Unfortunately, doing a direct fetch with no flag does _not_ set the 'cursor,' so you can't do a direct fetch and then enumerate the table from there. The bug is that cached handles generated as the result of a YPPROC_MATCH were being treated as though they were the same as handles generated by a YPPROC_FIRST, which is not the case. The manifestation is that if you do a 'ypmatch first-key-in-map map' followed by a yp_first()/yp_next() pair, the yp_first() and yp_next() both return the first key in the table, which makes the entry appear to be duplicated. A couple smaller things since I'm here: - yp_main.c and yp_error.c both have a global 'int debug' in them. For some reason, our cc/ld doesn't flag this as a multiply defined symbol even though it should. Removed the declaration from yp_main.c; we want the one in yp_error.c. - The Makefile wasn't installing ypinit in the right place.
Diffstat (limited to 'usr.sbin/ypserv/yp_dblookup.c')
-rw-r--r--usr.sbin/ypserv/yp_dblookup.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.sbin/ypserv/yp_dblookup.c b/usr.sbin/ypserv/yp_dblookup.c
index 9041c09..b271497 100644
--- a/usr.sbin/ypserv/yp_dblookup.c
+++ b/usr.sbin/ypserv/yp_dblookup.c
@@ -32,7 +32,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id$";
+ "$Id: yp_dblookup.c,v 1.1 1997/11/09 20:54:38 wpaul Exp wpaul $";
#endif /* not lint */
#include <db.h>
@@ -512,8 +512,8 @@ int yp_get_record(domain,map,key,data,allow)
#ifdef DB_CACHE
if (qhead.cqh_first->dbptr->size) {
- qhead.cqh_first->dbptr->key = key->data;
- qhead.cqh_first->dbptr->size = key->size;
+ qhead.cqh_first->dbptr->key = "";
+ qhead.cqh_first->dbptr->size = 0;
}
#else
bcopy((char *)data->data, (char *)&buf, data->size);
@@ -679,8 +679,12 @@ ypstat yp_select_map(map, domain, key, allow)
keydat *key;
int allow;
{
- yp_currmap_db = yp_open_db_cache(domain, map, key->keydat_val,
- key->keydat_len);
+ if (key == NULL)
+ yp_currmap_db = yp_open_db_cache(domain, map, NULL, 0);
+ else
+ yp_currmap_db = yp_open_db_cache(domain, map,
+ key->keydat_val,
+ key->keydat_len);
yp_allow_db = allow;
return(yp_errno);
OpenPOWER on IntegriCloud