summaryrefslogtreecommitdiffstats
path: root/lib/libc/yp
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>1995-04-09 19:26:23 +0000
committerwpaul <wpaul@FreeBSD.org>1995-04-09 19:26:23 +0000
commit568d625957b319da764d6dccc31fef4ae64cc429 (patch)
treef5a27ea5fc84f68d18e36167c48209ad9ccdf945 /lib/libc/yp
parent409c5ad6ef29d6e9945433b439e43780609d38d9 (diff)
downloadFreeBSD-src-568d625957b319da764d6dccc31fef4ae64cc429.zip
FreeBSD-src-568d625957b319da764d6dccc31fef4ae64cc429.tar.gz
Fix behavior of YP library routines in environments with multiple domains,
where one or more of the non-default domains are not yet bound. If we make a YP request for a domain other than the default domain, and there is no binding for the new domain yet, _yp_dobind() sees that the /var/yp/binding/DOMAIN.VERS file for the unbound domain is not locked (by ypbind) and from this it concludes that the NIS system is dead, so it gives up. This behavior has been changed: before giving up in this case, we now make a second check to see if the binding file for the *default* domain is also not locked. Only if the default domain binding file is also unlocked to we now assume that ypbind has bought the farm and bail out. (Note: this assumes that the user hasn't changed the default domain while ypbind is running.) With this change, _do_ypbind() is allowed to proceed into the next section of code wherein it prods ypbind into establishing a binding for the new domain. This first call times out after ten seconds, after which it should retry and succeed. From then on, the binding for the second domain should be handled normally.
Diffstat (limited to 'lib/libc/yp')
-rw-r--r--lib/libc/yp/yplib.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/lib/libc/yp/yplib.c b/lib/libc/yp/yplib.c
index 198365c..b0b6b8b 100644
--- a/lib/libc/yp/yplib.c
+++ b/lib/libc/yp/yplib.c
@@ -28,7 +28,7 @@
*/
#ifndef LINT
-static char *rcsid = "$Id: yplib.c,v 1.2 1995/03/21 00:48:55 wpaul Exp $";
+static char *rcsid = "$Id: yplib.c,v 1.4 1995/03/24 21:21:37 wpaul Exp $";
#endif
#include <sys/param.h>
@@ -180,6 +180,7 @@ struct dom_binding **ypdb;
int clnt_sock, fd, gpid;
CLIENT *client;
int new=0, r;
+ char *_defaultdom;
gpid = getpid();
if( !(pid==-1 || pid==gpid) ) {
@@ -251,10 +252,27 @@ again:
goto gotit;
} else {
/* no lock on binding file, YP is dead. */
+ /*
+ * XXX Not necessarily: the caller might be asking
+ * for a domain that we simply aren't bound to yet.
+ * Check that the binding file for the default domain
+ * is also unlocked before giving up.
+ */
close(fd);
- if(new)
- free(ysd);
- return YPERR_YPBIND;
+ if (new) {
+ if (yp_get_default_domain(&_defaultdom))
+ return YPERR_NODOM;
+ sprintf(path, "%s/%s.%d", BINDINGDIR, _defaultdom, 2);
+ if((fd=open(path, O_RDONLY)) > 0 &&
+ (flock(fd, LOCK_EX|LOCK_NB)) == -1 &&
+ errno==EWOULDBLOCK) {
+ close(fd);
+ } else {
+ close(fd); /* for paranoia's sake */
+ free(ysd);
+ return YPERR_YPBIND;
+ }
+ }
}
}
#endif
@@ -262,7 +280,7 @@ again:
bzero((char *)&clnt_sin, sizeof clnt_sin);
clnt_sin.sin_family = AF_INET;
clnt_sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
-
+
clnt_sock = RPC_ANYSOCK;
client = clnttcp_create(&clnt_sin, YPBINDPROG, YPBINDVERS, &clnt_sock,
0, 0);
@@ -279,7 +297,7 @@ again:
xdr_domainname, dom, xdr_ypbind_resp, &ypbr, tv);
if(r != RPC_SUCCESS) {
fprintf(stderr,
- "YP: server for domain %s not responding, still trying\n", dom);
+ "YP: server for domain %s not responding, retrying\n", dom);
clnt_destroy(client);
ysd->dom_vers = -1;
goto again;
OpenPOWER on IntegriCloud