diff options
author | Mats O Jansson <maja@cvs.openbsd.org> | 1996-06-30 19:46:09 +0000 |
---|---|---|
committer | Mats O Jansson <maja@cvs.openbsd.org> | 1996-06-30 19:46:09 +0000 |
commit | e26419d0b3adeeeed94164d8c481ba14db5e7605 (patch) | |
tree | 7e292c44ffc1ee4c65e0f25480712fbea04f801b /usr.sbin | |
parent | 8f098e458860b324ca97bd210b4da5419e29bf15 (diff) |
Added support for SIGHUP in ypserv for reread of /var/yp/securenet or
aclfile.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ypserv/common/ypdef.h | 4 | ||||
-rw-r--r-- | usr.sbin/ypserv/ypserv/acl.c | 15 | ||||
-rw-r--r-- | usr.sbin/ypserv/ypserv/acl.h | 3 | ||||
-rw-r--r-- | usr.sbin/ypserv/ypserv/ypserv.8 | 14 | ||||
-rw-r--r-- | usr.sbin/ypserv/ypserv/ypserv.c | 29 |
5 files changed, 53 insertions, 12 deletions
diff --git a/usr.sbin/ypserv/common/ypdef.h b/usr.sbin/ypserv/common/ypdef.h index b2c9d6892e8..d056856be89 100644 --- a/usr.sbin/ypserv/common/ypdef.h +++ b/usr.sbin/ypserv/common/ypdef.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ypdef.h,v 1.4 1996/06/26 21:26:34 maja Exp $ */ +/* $OpenBSD: ypdef.h,v 1.5 1996/06/30 19:45:59 maja Exp $ */ /* * Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se> @@ -64,5 +64,7 @@ #endif #define YPXFR_PROC "/usr/sbin/ypxfr" +#define YPSERV_PID_PATH "/var/run/ypserv.pid" +#define YP_SECURENET_FILE "/var/yp/securenet" #endif /* !_YPDEF_H_ */ diff --git a/usr.sbin/ypserv/ypserv/acl.c b/usr.sbin/ypserv/ypserv/acl.c index d6787af887c..22494083799 100644 --- a/usr.sbin/ypserv/ypserv/acl.c +++ b/usr.sbin/ypserv/ypserv/acl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acl.c,v 1.3 1996/06/26 21:26:36 maja Exp $ */ +/* $OpenBSD: acl.c,v 1.4 1996/06/30 19:46:04 maja Exp $ */ /* * Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se> @@ -32,7 +32,7 @@ */ #ifndef LINT -static char rcsid[] = "$OpenBSD: acl.c,v 1.3 1996/06/26 21:26:36 maja Exp $"; +static char rcsid[] = "$OpenBSD: acl.c,v 1.4 1996/06/30 19:46:04 maja Exp $"; #endif #include <sys/types.h> @@ -598,3 +598,14 @@ char *file; } +void +acl_reset() +{ + struct aclent *p; + + while (acl_root != NULL) { + p = acl_root->next; + free(acl_root); + acl_root = p; + } +} diff --git a/usr.sbin/ypserv/ypserv/acl.h b/usr.sbin/ypserv/ypserv/acl.h index 6c3127e5089..215d7180141 100644 --- a/usr.sbin/ypserv/ypserv/acl.h +++ b/usr.sbin/ypserv/ypserv/acl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acl.h,v 1.3 1996/06/26 21:26:37 maja Exp $ */ +/* $OpenBSD: acl.h,v 1.4 1996/06/30 19:46:05 maja Exp $ */ /* * Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se> @@ -79,6 +79,7 @@ __BEGIN_DECLS int acl_check_host __P((struct in_addr *)); int acl_init __P((char *)); int acl_securenet __P((char *)); +void acl_reset __P((void)); __END_DECLS #endif /* !_ACL_H_ */ diff --git a/usr.sbin/ypserv/ypserv/ypserv.8 b/usr.sbin/ypserv/ypserv/ypserv.8 index df3f4215dc6..86a58b9af3b 100644 --- a/usr.sbin/ypserv/ypserv/ypserv.8 +++ b/usr.sbin/ypserv/ypserv/ypserv.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ypserv.8,v 1.4 1996/06/26 21:26:38 maja Exp $ +.\" $OpenBSD: ypserv.8,v 1.5 1996/06/30 19:46:06 maja Exp $ .\" Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se> .\" All rights reserved. .\" @@ -66,7 +66,15 @@ Before the author of this server had seen another format was implemented .Xr ypserv.acl 5 . This file format makes it possible to allow and deny hosts and networks -access to the server. +access to the server. This file can have any name since it's given by +the argument to +.Fl a +(use full path). +.Pp +The file used can be reread by sending a SIGHUP to ypserv. The process pid +can be found in the file +.Nm /var/run/ypserv.pid +. .Pp If a host isn't secure all queries to the server will result in a YP_NODOM result. It would be better to add the security to @@ -101,7 +109,7 @@ or .Bl -tag -width /var/yp/ypserv.log -compact .It Pa /var/yp/ypserv.log .It Pa /var/yp/securenet -.It Pa /var/yp/ypserv.acl +.It Pa /var/run/ypserv.pid .El .Sh SEE ALSO .Xr yp 8 , diff --git a/usr.sbin/ypserv/ypserv/ypserv.c b/usr.sbin/ypserv/ypserv/ypserv.c index def9d56e503..8b8ea228b5a 100644 --- a/usr.sbin/ypserv/ypserv/ypserv.c +++ b/usr.sbin/ypserv/ypserv/ypserv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypserv.c,v 1.4 1996/06/26 21:26:38 maja Exp $ */ +/* $OpenBSD: ypserv.c,v 1.5 1996/06/30 19:46:08 maja Exp $ */ /* * Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se> @@ -32,7 +32,7 @@ */ #ifndef LINT -static char rcsid[] = "$OpenBSD: ypserv.c,v 1.4 1996/06/26 21:26:38 maja Exp $"; +static char rcsid[] = "$OpenBSD: ypserv.c,v 1.5 1996/06/30 19:46:08 maja Exp $"; #endif #include "yp.h" @@ -57,10 +57,9 @@ static char rcsid[] = "$OpenBSD: ypserv.c,v 1.4 1996/06/26 21:26:38 maja Exp $"; #endif #include "acl.h" #include "yplog.h" +#include "ypdef.h" #include <sys/wait.h> -#define YP_SECURENET_FILE "/var/yp/securenet" - #ifdef __STDC__ #define SIG_PF void(*)(int) #endif @@ -76,8 +75,10 @@ static int _rpcsvcdirty; /* Still serving ? */ int usedns = FALSE; char *progname = "ypserv"; +char *aclfile = NULL; void sig_child(); +void sig_hup(); static void _msgout(char* msg) @@ -244,7 +245,6 @@ char *argv[]; int xflag = 0; char ch; extern char *optarg; - char *aclfile = NULL; while ((ch = getopt(argc, argv, "a:dx")) != EOF) switch (ch) { @@ -328,6 +328,13 @@ char *argv[]; chdir("/"); (void)signal(SIGCHLD, sig_child); + (void)signal(SIGHUP, sig_hup); + { FILE *pidfile = fopen(YPSERV_PID_PATH, "w"); + if (pidfile != NULL) { + fprintf(pidfile, "%d\n", getpid()); + fclose(pidfile); + } + } if ((_rpcfdtype == 0) || (_rpcfdtype == SOCK_DGRAM)) { transp = svcudp_create(sock); @@ -380,3 +387,15 @@ sig_child() while (wait3((int *)NULL, WNOHANG, (struct rusage *)NULL) > 0); } +void +sig_hup() +{ + acl_reset(); + if (aclfile != NULL) { + yplog("sig_hup: reread %s",aclfile); + (void)acl_init(aclfile); + } else { + yplog("sig_hup: reread %s",YP_SECURENET_FILE); + (void)acl_securenet(YP_SECURENET_FILE); + } +} |