summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ypserv/yp_main.c
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>1999-04-29 20:24:00 +0000
committerwpaul <wpaul@FreeBSD.org>1999-04-29 20:24:00 +0000
commitbcdf933fad0276458853d00c92945926de3b1381 (patch)
tree129833c0be36d80e1276a9a68011ffd8e7af8173 /usr.sbin/ypserv/yp_main.c
parent7634f5f76b08db127fd33f5f3285d870f9d640a0 (diff)
downloadFreeBSD-src-bcdf933fad0276458853d00c92945926de3b1381.zip
FreeBSD-src-bcdf933fad0276458853d00c92945926de3b1381.tar.gz
Add some extra checks to make sure that a child ypserv process doesn't
try to fork() a child of its own, which could result in several children ypservs running at once. I'm still not sure exactly what leads to this condition, but these fixes should stop it from causing trouble. A new function, yp_fork() checks to see if the current process is already a child of the parent ypserv, and returns failure (and logs an error message) rather than spawning another child.
Diffstat (limited to 'usr.sbin/ypserv/yp_main.c')
-rw-r--r--usr.sbin/ypserv/yp_main.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/usr.sbin/ypserv/yp_main.c b/usr.sbin/ypserv/yp_main.c
index f20ccb3..dbd38fe 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: yp_main.c,v 1.18 1998/06/04 15:11:14 wpaul Exp $";
+ "$Id: yp_main.c,v 1.19 1999/02/10 16:16:14 wpaul Exp $";
#endif /* not lint */
/*
@@ -99,6 +99,8 @@ void _msgout(char* msg)
syslog(LOG_ERR, msg);
}
+pid_t yp_pid;
+
static void
yp_svc_run()
{
@@ -108,12 +110,11 @@ yp_svc_run()
int readfds;
#endif /* def FD_SETSIZE */
extern int forked;
- int pid;
int fd_setsize = _rpc_dtablesize();
struct timeval timeout;
/* Establish the identity of the parent ypserv process. */
- pid = getpid();
+ yp_pid = getpid();
for (;;) {
#ifdef FD_SETSIZE
@@ -135,16 +136,19 @@ yp_svc_run()
warn("svc_run: - select failed");
return;
case 0:
- yp_prune_dnsq();
+ if (getpid() == yp_pid)
+ yp_prune_dnsq();
break;
default:
- if (FD_ISSET(resfd, &readfds)) {
- yp_run_dnsq();
- FD_CLR(resfd, &readfds);
+ if (getpid() == yp_pid) {
+ if (FD_ISSET(resfd, &readfds)) {
+ yp_run_dnsq();
+ FD_CLR(resfd, &readfds);
+ }
+ svc_getreqset(&readfds);
}
- svc_getreqset(&readfds);
}
- if (forked && pid != getpid())
+ if (yp_pid != getpid())
_exit(0);
}
}
OpenPOWER on IntegriCloud