Makefile.yp:

- Add a 'pushpw' target that only yppushes the various passwd maps
  and sends a YPPROC_CLEAR to the local ypserv. This will be used by
  rpc.yppasswdd once I merge in the in-place update changes.

yp_access.c:

- Make the yp_access() function print RPC program and procedure numbers
  that it doesn't know about in literal form. This will allow it to work
  with other prgrams that it doesn't know about, like rpc.ypxfrd I'm going
  to import shortly.

yp_dblookup.c:

- Take out the __inline keywords. They weren't really helping me anyway.

- Somehow I broke yp_next() when DB_CACHE wasn't #defined. Fix it.

- Also fix potential case where yp_next() might loop forever; make sure
  it checks the return values of all the (dbp->seq)()/R_NEXT calls that
  it does as well as comparing keys.
This commit is contained in:
Bill Paul 1996-06-05 02:01:31 +00:00
parent b487e9d356
commit b3e932340d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=16118
3 changed files with 51 additions and 20 deletions

View File

@ -1,7 +1,7 @@
#
# Makefile for the NIS databases
#
# $Id: Makefile.yp,v 1.4 1996/04/28 04:38:46 wpaul Exp $
# $Id: Makefile.yp,v 1.5 1996/06/03 16:24:32 wpaul Exp $
#
# This Makefile should only be run on the NIS master server of a domain.
# All updated maps will be pushed to all NIS slave servers listed in the
@ -136,6 +136,20 @@ aliases: mail.aliases
master.passwd: master.passwd.byname master.passwd.byuid
#
# This is a special target used only when doing in-place updates with
# rpc.yppasswdd. In this case, the maps will be updated by the rpc.yppasswdd
# server and won't need to be remade. They will have to be pushed to the
# slaves however. Calling this target implicitly insures that this will
# happen.
#
pushpw:
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byname ; fi
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byuid ; fi
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byname ; fi
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byuid ; fi
mail.aliases: $(ALIASES)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
@ -356,7 +370,8 @@ services.byname: $(SERVICES)
$(CAT) $(SERVICES) | \
$(AWK) \
'$$1 !~ "#" { if (index($$2,"udp")) { printf("%s/udp",$$1) } \
else { printf("%s/tcp",$$1) }; print "\t"$$0 \
else { printf("%s/tcp",$$1) }; print "\t"$$0 ; \
print $$2"\t"$$0 ; \
}' $^ | $(DBLOAD) -i $(SERVICES) -o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c

View File

@ -52,7 +52,7 @@
#endif
#ifndef lint
static const char rcsid[] = "$Id: yp_access.c,v 1.7 1996/04/28 04:38:47 wpaul Exp $";
static const char rcsid[] = "$Id: yp_access.c,v 1.2 1996/05/01 02:39:54 wpaul Exp $";
#endif
extern int debug;
@ -218,9 +218,17 @@ int yp_access(map, rqstp)
struct securenet *tmp;
#endif
char *yp_procedure = NULL;
char procbuf[50];
yp_procedure = rqstp->rq_prog == YPPASSWDPROG ? "yppasswdprog_update" :
yp_procs[rqstp->rq_proc + (12 * (rqstp->rq_vers - 1))];
if (rqstp->rq_prog != YPPASSWDPROG && rqstp->rq_prog != YPPROG) {
snprintf(procbuf, sizeof(procbuf), "#%lu/#%lu", rqstp->rq_prog,
rqstp->rq_proc);
yp_procedure = (char *)&procbuf;
} else {
yp_procedure = rqstp->rq_prog == YPPASSWDPROG ?
"yppasswdprog_update" :
yp_procs[rqstp->rq_proc + (12 * (rqstp->rq_vers - 1))];
}
rqhost = svc_getcaller(rqstp->rq_xprt);

View File

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: yp_dblookup.c,v 1.9 1996/05/01 02:33:52 wpaul Exp $
* $Id: yp_dblookup.c,v 1.13 1996/06/04 04:08:21 wpaul Exp $
*
*/
#include <stdio.h>
@ -47,7 +47,7 @@
#include "yp_extern.h"
#ifndef lint
static const char rcsid[] = "$Id: yp_dblookup.c,v 1.9 1996/05/01 02:33:52 wpaul Exp $";
static const char rcsid[] = "$Id: yp_dblookup.c,v 1.13 1996/06/04 04:08:21 wpaul Exp $";
#endif
int ypdb_debug = 0;
@ -57,7 +57,7 @@ int yp_errno = YP_TRUE;
HASHINFO openinfo = {
4096, /* bsize */
32, /* ffactor */
512, /* nelem */
256, /* nelem */
2048 * 512, /* cachesize */
NULL, /* hash */
0, /* lorder */
@ -93,7 +93,7 @@ void yp_init_dbs()
* Zorch a single entry in the dbent table and release
* all its resources.
*/
static __inline void yp_flush(i)
static void yp_flush(i)
register int i;
{
(void)(dbs[i]->dbp->close)(dbs[i]->dbp);
@ -128,7 +128,7 @@ void yp_flush_all()
* a new entry when all our slots are already filled, we have to kick
* out the entry in the last slot to make room.
*/
static __inline void yp_add_db(dbp, name, size)
static void yp_add_db(dbp, name, size)
DB *dbp;
char *name;
int size;
@ -190,7 +190,7 @@ static __inline void yp_add_db(dbp, name, size)
* array so that it will be easier to find if another request for
* the same database comes in later.
*/
static __inline DB *yp_find_db(name, key, size)
static DB *yp_find_db(name, key, size)
char *name;
char *key;
int size;
@ -202,12 +202,11 @@ static __inline DB *yp_find_db(name, key, size)
if (dbs[i]->name != NULL && !strcmp(dbs[i]->name, name)) {
if (size) {
if (size != dbs[i]->size ||
strncmp(dbs[i]->key, key, size))
strncmp(dbs[i]->key, key, size))
continue;
} else {
if (dbs[i]->size) {
if (dbs[i]->size)
continue;
}
}
if (i > 0) {
tmp = dbs[i];
@ -218,6 +217,7 @@ static __inline DB *yp_find_db(name, key, size)
return(dbs[0]->dbp);
}
}
return(NULL);
}
@ -235,6 +235,9 @@ DB *yp_open_db_cache(domain, map, key, size)
{
DB *dbp = NULL;
char buf[MAXPATHLEN + 2];
/*
snprintf(buf, sizeof(buf), "%s/%s", domain, map);
*/
strcpy(buf, domain);
strcat(buf, "/");
@ -451,17 +454,22 @@ int yp_next_record(dbp,key,data,all,allow)
key->size, key->data);
if (!all) {
#ifndef DB_CACHE
if (key->size != lkey.size ||
strncmp(key->data, lkey.data, key->size)) {
#else
if (!dbs[0]->size) {
#ifdef DB_CACHE
if (!dbs[0]->key) {
#endif
(dbp->seq)(dbp,&lkey,&ldata,R_FIRST);
while(strncmp((char *)key->data,lkey.data,
(int)key->size) || key->size != lkey.size)
(dbp->seq)(dbp,&lkey,&ldata,R_NEXT);
if ((dbp->seq)(dbp,&lkey,&ldata,R_NEXT)) {
#ifdef DB_CACHE
dbs[0]->size = 0;
#endif
return(YP_NOKEY);
}
#ifdef DB_CACHE
}
#endif
}
if ((dbp->seq)(dbp,key,data,R_NEXT)) {