summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ypserv
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/ypserv')
-rw-r--r--usr.sbin/ypserv/yp_extern.h4
-rw-r--r--usr.sbin/ypserv/yp_main.c22
-rw-r--r--usr.sbin/ypserv/yp_server.c22
3 files changed, 30 insertions, 18 deletions
diff --git a/usr.sbin/ypserv/yp_extern.h b/usr.sbin/ypserv/yp_extern.h
index 0aaee26..4786cca 100644
--- a/usr.sbin/ypserv/yp_extern.h
+++ b/usr.sbin/ypserv/yp_extern.h
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: yp_extern.h,v 1.11 1997/02/22 16:15:11 peter Exp $
+ * $Id: yp_extern.h,v 1.12 1997/10/29 07:25:03 charnier Exp $
*/
#include <db.h>
@@ -68,6 +68,8 @@ extern int children;
extern int resfd;
extern char *progname;
extern char *yp_dir;
+extern pid_t yp_pid;
+
extern enum ypstat yp_errno;
extern void yp_error __P((const char *, ...));
#ifdef DB_CACHE
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);
}
}
diff --git a/usr.sbin/ypserv/yp_server.c b/usr.sbin/ypserv/yp_server.c
index 76cb5ea..b771468 100644
--- a/usr.sbin/ypserv/yp_server.c
+++ b/usr.sbin/ypserv/yp_server.c
@@ -33,7 +33,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: yp_server.c,v 1.26 1998/02/11 19:15:32 wpaul Exp $";
+ "$Id: yp_server.c,v 1.27 1999/02/10 16:16:14 wpaul Exp $";
#endif /* not lint */
#include "yp.h"
@@ -49,7 +49,6 @@ static const char rcsid[] =
#include <arpa/inet.h>
#include <rpc/rpc.h>
-int forked = 0;
int children = 0;
#define MASTER_STRING "YP_MASTER_NAME"
@@ -57,6 +56,17 @@ int children = 0;
#define ORDER_STRING "YP_LAST_MODIFIED"
#define ORDER_SZ sizeof(ORDER_STRING) - 1
+static pid_t yp_fork()
+{
+ if (yp_pid != getpid()) {
+ yp_error("child %d trying to fork!", getpid());
+ errno = EEXIST;
+ return(-1);
+ }
+
+ return(fork());
+}
+
/*
* NIS v2 support. This is where most of the action happens.
*/
@@ -350,7 +360,7 @@ ypproc_xfr_2_svc(ypreq_xfr *argp, struct svc_req *rqstp)
YPXFR_RETURN(YPXFR_REFUSED)
}
- switch(fork()) {
+ switch(yp_fork()) {
case 0:
{
char g[11], t[11], p[11];
@@ -380,7 +390,6 @@ ypproc_xfr_2_svc(ypreq_xfr *argp, struct svc_req *rqstp)
p, argp->map_parms.map,
NULL);
}
- forked++;
yp_error("ypxfr execl(%s): %s", ypxfr_command, strerror(errno));
YPXFR_RETURN(YPXFR_XFRERR)
break;
@@ -392,7 +401,6 @@ ypproc_xfr_2_svc(ypreq_xfr *argp, struct svc_req *rqstp)
default:
result.xfrstat = YPXFR_SUCC;
children++;
- forked = 0;
break;
}
@@ -507,9 +515,8 @@ ypproc_all_2_svc(ypreq_nokey *argp, struct svc_req *rqstp)
* async socket I/O?)
*/
if (!debug) {
- switch(fork()) {
+ switch(yp_fork()) {
case 0:
- forked++;
break;
case -1:
yp_error("ypall fork(): %s", strerror(errno));
@@ -518,7 +525,6 @@ ypproc_all_2_svc(ypreq_nokey *argp, struct svc_req *rqstp)
break;
default:
children++;
- forked = 0;
return (NULL);
break;
}
OpenPOWER on IntegriCloud