In environments with multiple NIS servers (a master and several slaves)

one ypbind broadcast can yield several responses. This can lead to
some confusion: the syslog message from ypbind will indicate a rebinding
to the first server that responds, but we may subsequently change our
binding to another server when the other responses arrive. This results
in ypbind reporting 'server OK' to one address and ypwhich reporting a
binding to another.

The behavior of the rpc_received() function has been changed to prevent
this: subsequent responses received after a binding has already been
established are ignored. Rebinding gratuitously each time we get a
new response is silly anyway.

Also backed out the non-fix I made in my last ypbind commit. (Pass
me the extra large conical hat, please.)

(At some point I'm going to seriously re-work ypbind and the _yp_dobind()
library function to bring them in line with SunOS's documented behavior:
binding requests are supposed to be 'client-driven.' The _yp_dobind()
function should be responsible for retrying connections in response to
calls from client programs rather than having ypbind broadcasting
continously until a server responds. The current setup works okay in
normal operation, but we broadcast far too often than we should.)
This commit is contained in:
Bill Paul 1995-04-15 23:35:46 +00:00
parent 99390fb82f
commit a00f731551
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=7864

View File

@ -28,7 +28,7 @@
*/
#ifndef LINT
static char rcsid[] = "$Id: ypbind.c,v 1.4 1995/02/26 04:42:48 wpaul Exp $";
static char rcsid[] = "$Id: ypbind.c,v 1.5 1995/04/02 03:10:55 wpaul Exp $";
#endif
#include <sys/param.h>
@ -671,6 +671,16 @@ int force;
if( strcmp(ypdb->dom_domain, dom) == 0)
break;
if (ypdb != NULL && ypdb->dom_vers == YPVERS && ypdb->dom_alive == 1 &&
ypdb->dom_server_addr.sin_addr.s_addr != raddrp->sin_addr.s_addr)
/*
* We're received a second response to one of our broadcasts
* from another server, and we've already bound: drop
* the response on the floor. No sense changing servers
* for no reason.
*/
return;
if(ypdb==NULL) {
if(force==0)
return;
@ -713,15 +723,15 @@ int force;
sprintf(path, "%s/%s.%d", BINDINGDIR,
ypdb->dom_domain, ypdb->dom_vers);
#ifdef O_SHLOCK
if( (fd=open(path, O_CREAT|O_SHLOCK|O_RDWR|O_TRUNC, 0644)) < 0) {
if( (fd=open(path, O_CREAT|O_SHLOCK|O_RDWR|O_TRUNC, 0644)) == -1) {
(void)mkdir(BINDINGDIR, 0755);
if( (fd=open(path, O_CREAT|O_SHLOCK|O_RDWR|O_TRUNC, 0644)) < 0)
if( (fd=open(path, O_CREAT|O_SHLOCK|O_RDWR|O_TRUNC, 0644)) == -1)
return;
}
#else
if( (fd=open(path, O_CREAT|O_RDWR|O_TRUNC, 0644)) < 0) {
if( (fd=open(path, O_CREAT|O_RDWR|O_TRUNC, 0644)) == -1) {
(void)mkdir(BINDINGDIR, 0755);
if( (fd=open(path, O_CREAT|O_RDWR|O_TRUNC, 0644)) < 0)
if( (fd=open(path, O_CREAT|O_RDWR|O_TRUNC, 0644)) == -1)
return;
}
flock(fd, LOCK_SH);