diff options
author | Bill Paul <wpaul@FreeBSD.org> | 1998-02-11 19:15:32 +0000 |
---|---|---|
committer | Bill Paul <wpaul@FreeBSD.org> | 1998-02-11 19:15:32 +0000 |
commit | 0d15a95009aa7efb44f0a1ac8262adf4a45dd828 (patch) | |
tree | 09ae1e0a382971569a1cae1607c0cc8a9b3196f1 /usr.sbin/ypserv | |
parent | a293037f7cea835c7a3c6d5be51cd36e7a6edda8 (diff) | |
download | src-0d15a95009aa7efb44f0a1ac8262adf4a45dd828.tar.gz src-0d15a95009aa7efb44f0a1ac8262adf4a45dd828.zip |
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.
Notes
Notes:
svn path=/head/; revision=33250
Diffstat (limited to 'usr.sbin/ypserv')
-rw-r--r-- | usr.sbin/ypserv/Makefile | 4 | ||||
-rw-r--r-- | usr.sbin/ypserv/yp_dblookup.c | 14 | ||||
-rw-r--r-- | usr.sbin/ypserv/yp_main.c | 4 | ||||
-rw-r--r-- | usr.sbin/ypserv/yp_server.c | 6 |
4 files changed, 16 insertions, 12 deletions
diff --git a/usr.sbin/ypserv/Makefile b/usr.sbin/ypserv/Makefile index 76fe709e0d9e..937c467f8d13 100644 --- a/usr.sbin/ypserv/Makefile +++ b/usr.sbin/ypserv/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.3 1997/11/10 21:22:17 wpaul Exp $ +# $Id: Makefile,v 1.12 1997/11/10 22:17:09 wpaul Exp $ PROG= ypserv SRCS= yp_svc.c yp_server.c yp_dblookup.c yp_dnslookup.c \ @@ -33,7 +33,7 @@ afterinstall: ${.CURDIR}/Makefile.yp \ ${DESTDIR}/var/yp/Makefile.dist ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 555 \ - ${.CURDIR}/ypinit.sh ${BINDIR}/ypinit + ${.CURDIR}/ypinit.sh ${DESTDIR}/${BINDIR}/ypinit @if [ ! -f ${DESTDIR}/var/yp/Makefile.dist ]; then \ ln -s ${DESTDIR}/var/yp/Makefile.dist \ ${DESTDIR}/var/yp/Makefile; fi diff --git a/usr.sbin/ypserv/yp_dblookup.c b/usr.sbin/ypserv/yp_dblookup.c index 9041c097559b..b271497a554e 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); diff --git a/usr.sbin/ypserv/yp_main.c b/usr.sbin/ypserv/yp_main.c index 6aaa7e34049d..1b2546d23ed0 100644 --- a/usr.sbin/ypserv/yp_main.c +++ b/usr.sbin/ypserv/yp_main.c @@ -32,7 +32,7 @@ #ifndef lint static const char rcsid[] = - "$Id$"; + "$Id: yp_main.c,v 1.1 1997/11/09 20:54:38 wpaul Exp wpaul $"; #endif /* not lint */ /* @@ -83,7 +83,7 @@ extern int _rpc_dtablesize __P((void)); extern int _rpcsvcstate; /* Set when a request is serviced */ char *progname = "ypserv"; char *yp_dir = _PATH_YP; -int debug = 0; +/*int debug = 0;*/ int do_dns = 0; int resfd; diff --git a/usr.sbin/ypserv/yp_server.c b/usr.sbin/ypserv/yp_server.c index 9927f6be1eaf..3b645a8cea03 100644 --- a/usr.sbin/ypserv/yp_server.c +++ b/usr.sbin/ypserv/yp_server.c @@ -33,7 +33,7 @@ #ifndef lint static const char rcsid[] = - "$Id$"; + "$Id: yp_server.c,v 1.1 1997/11/09 20:54:38 wpaul Exp wpaul $"; #endif /* not lint */ #include "yp.h" @@ -143,7 +143,7 @@ ypproc_match_2_svc(ypreq_key *argp, struct svc_req *rqstp) return (&result); } - if (yp_select_map(argp->map, argp->domain, &argp->key, 1) != YP_TRUE) { + if (yp_select_map(argp->map, argp->domain, NULL, 1) != YP_TRUE) { result.stat = yp_errno; return(&result); } @@ -204,7 +204,7 @@ ypproc_first_2_svc(ypreq_nokey *argp, struct svc_req *rqstp) return (&result); } - if (yp_select_map(argp->map, argp->domain, &result.key, 0) != YP_TRUE) { + if (yp_select_map(argp->map, argp->domain, NULL, 0) != YP_TRUE) { result.stat = yp_errno; return(&result); } |