Subject: bin/729: ypbind detaches from tty too soon
To: None <gnats-admin@NetBSD.ORG>
From: Jason R. Thorpe <thorpej@nas.nasa.gov>
List: netbsd-bugs
Date: 01/12/1995 23:20:05
>Number: 729
>Category: bin
>Synopsis: ypbind detaches from tty too soon
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jan 12 23:20:03 1995
>Originator: Jason R. Thorpe
>Organization:
Numerical Aerodynamic Simulation Project
>Release: 1.0
>Environment:
System: NetBSD nosferatu 1.0 NetBSD 1.0 (NOSFERATU) #4: Fri Jan 6 13:51:45 PST 1995 root@nosferatu:/usr/src/sys/arch/i386/compile/NOSFERATU i386
>Description:
On a fast machine, such as a 66MHz 486 or an hp380 or hp433, ypbind
returns to the shell too quickly, allowing other YP-dependant
programs to run before the binding is in place. On a slower machine
one might not notice, because, chances are, the domain will be
bound by the time the shell gets around to running the next
program in line, which is often mountd and/or amd.
This especially poses a problem if one gets netgroups and/or
amd maps out of YP. If mountd exports to a netgroup, the export
will fail, as no netgroups are available out of the YP space until
the domain is bound. This is also true for amd, sometimes
requiring a HUP before the system will automount filesystems.
>How-To-Repeat:
Get netgroups and/or amd maps out of YP. On a fast system, the
above behavior will appear.
>Fix:
The following patch is derived from the ypbind shipped with
NetBSD 1.0. I know that there have been some changes to ypbind
since, so minor adjustments may be necessary.
Essentially, this patch prevents ypbind from detaching from the
controlling tty (and thereby prevents it from giving control back
to the shell) until the domain binds. This behavior is like that
of the ypbind shipped by some vendors.
*** ypbind.c.orig Thu Jan 12 22:55:06 1995
--- ypbind.c Thu Jan 12 23:00:34 1995
***************
*** 284,290 ****
char path[MAXPATHLEN];
struct timeval tv;
fd_set fdsr;
! int width;
int i;
yp_get_default_domain(&domainname);
--- 284,290 ----
char path[MAXPATHLEN];
struct timeval tv;
fd_set fdsr;
! int in_init, width;
int i;
yp_get_default_domain(&domainname);
***************
*** 302,322 ****
/* blow away everything in BINDINGDIR */
-
-
- #ifdef DAEMON
- switch(fork()) {
- case 0:
- break;
- case -1:
- perror("fork");
- exit(1);
- default:
- exit(0);
- }
- setsid();
- #endif
-
pmap_unset(YPBINDPROG, YPBINDVERS);
udptransp = svcudp_create(RPC_ANYSOCK);
--- 302,307 ----
***************
*** 376,382 ****
--- 361,394 ----
(void)unlink(path);
width = getdtablesize();
+
+ /*
+ * Ensure that the initial binding is successful.
+ * This behaves like other ypbinds...it waits.
+ */
+ for (in_init = 1;;) {
+ goto do_meat;
+ init_loop:
+ if (ypbindlist->dom_alive)
+ break;
+ }
+ in_init = 0;
+
+ #ifdef DAEMON
+ switch(fork()) {
+ case 0:
+ break;
+ case -1:
+ perror("fork");
+ exit(1);
+ default:
+ exit(0);
+ }
+ setsid();
+ #endif
+
while(1) {
+ do_meat:
fdsr = svc_fdset;
FD_SET(rpcsock, &fdsr);
FD_SET(pingsock, &fdsr);
***************
*** 404,409 ****
--- 416,423 ----
checkwork();
break;
}
+ if (in_init)
+ goto init_loop;
}
}
>Audit-Trail:
>Unformatted: