summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libexec/ftpd/Makefile5
-rw-r--r--libexec/ftpd/ftpd.c13
-rw-r--r--libexec/ftpd/pathnames.h3
-rw-r--r--sbin/pflogd/Makefile5
-rw-r--r--sbin/pflogd/pflogd.c12
-rw-r--r--sbin/rtsol/Makefile5
-rw-r--r--usr.sbin/mrouted/main.c10
-rw-r--r--usr.sbin/mrouted/pathnames.h2
-rw-r--r--usr.sbin/rarpd/Makefile4
-rw-r--r--usr.sbin/rarpd/pathnames.h31
-rw-r--r--usr.sbin/rarpd/rarpd.c13
-rw-r--r--usr.sbin/rbootd/Makefile4
-rw-r--r--usr.sbin/rbootd/conf.c6
-rw-r--r--usr.sbin/rbootd/defs.h4
-rw-r--r--usr.sbin/rbootd/pathnames.h3
-rw-r--r--usr.sbin/rbootd/rbootd.c17
-rw-r--r--usr.sbin/route6d/Makefile4
-rw-r--r--usr.sbin/route6d/route6d.c12
-rw-r--r--usr.sbin/route6d/route6d.h3
-rw-r--r--usr.sbin/rtadvd/Makefile6
-rw-r--r--usr.sbin/rtadvd/rtadvd.c17
-rw-r--r--usr.sbin/rtsold/Makefile5
-rw-r--r--usr.sbin/rtsold/rtsold.c17
-rw-r--r--usr.sbin/screenblank/Makefile6
-rw-r--r--usr.sbin/screenblank/pathnames.h3
-rw-r--r--usr.sbin/screenblank/screenblank.c19
-rw-r--r--usr.sbin/ypserv/common/ypdef.h3
-rw-r--r--usr.sbin/ypserv/ypserv/Makefile4
-rw-r--r--usr.sbin/ypserv/ypserv/ypserv.c12
29 files changed, 81 insertions, 167 deletions
diff --git a/libexec/ftpd/Makefile b/libexec/ftpd/Makefile
index 91a45ad5ed9..a78053d0b4b 100644
--- a/libexec/ftpd/Makefile
+++ b/libexec/ftpd/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.19 2001/05/29 21:35:16 millert Exp $
+# $OpenBSD: Makefile,v 1.20 2001/12/01 23:27:19 miod Exp $
# $NetBSD: Makefile,v 1.13 1996/02/16 02:07:41 cgd Exp $
# @(#)Makefile 8.2 (Berkeley) 4/4/94
@@ -20,6 +20,9 @@ CFLAGS += -I${LSDIR}
# not really used
CPPFLAGS+=-DINET6
+LDADD+= -lutil
+DPADD+= ${LIBUTIL}
+
.if (${TCP_WRAPPERS:L} == "yes")
CFLAGS+=-DTCPWRAPPERS
LDADD+= -lwrap
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index 9837313aeb9..0d031c2800c 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftpd.c,v 1.107 2001/11/17 19:54:56 deraadt Exp $ */
+/* $OpenBSD: ftpd.c,v 1.108 2001/12/01 23:27:20 miod Exp $ */
/* $NetBSD: ftpd.c,v 1.15 1995/06/03 22:46:47 mycroft Exp $ */
/*
@@ -73,7 +73,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)ftpd.c 8.4 (Berkeley) 4/16/94";
#else
-static char rcsid[] = "$OpenBSD: ftpd.c,v 1.107 2001/11/17 19:54:56 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: ftpd.c,v 1.108 2001/12/01 23:27:20 miod Exp $";
#endif
#endif /* not lint */
@@ -443,13 +443,8 @@ main(argc, argv, envp)
exit(1);
}
/* Stash pid in pidfile */
- if ((fp = fopen(_PATH_FTPDPID, "w")) == NULL)
- syslog(LOG_ERR, "can't open %s: %m", _PATH_FTPDPID);
- else {
- fprintf(fp, "%d\n", getpid());
- fchmod(fileno(fp), S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
- fclose(fp);
- }
+ if (pidfile(NULL))
+ syslog(LOG_ERR, "can't open pidfile: %m");
/*
* Loop forever accepting connection requests and forking off
* children to handle them.
diff --git a/libexec/ftpd/pathnames.h b/libexec/ftpd/pathnames.h
index 52ac8469df4..18a5451db40 100644
--- a/libexec/ftpd/pathnames.h
+++ b/libexec/ftpd/pathnames.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pathnames.h,v 1.4 1999/12/03 01:22:46 millert Exp $ */
+/* $OpenBSD: pathnames.h,v 1.5 2001/12/01 23:27:20 miod Exp $ */
/* $NetBSD: pathnames.h,v 1.5 1995/04/11 02:44:59 cgd Exp $ */
/*
@@ -43,5 +43,4 @@
#define _PATH_FTPWELCOME "/etc/ftpwelcome"
#define _PATH_FTPLOGINMESG "/etc/motd"
#define _PATH_FTPDSTATFILE "/var/log/ftpd"
-#define _PATH_FTPDPID "/var/run/ftpd.pid"
#define _PATH_CWDMESG ".message"
diff --git a/sbin/pflogd/Makefile b/sbin/pflogd/Makefile
index 9ce0baf0f89..318de8f0fd7 100644
--- a/sbin/pflogd/Makefile
+++ b/sbin/pflogd/Makefile
@@ -1,7 +1,8 @@
-# $OpenBSD: Makefile,v 1.1 2001/08/21 22:29:14 deraadt Exp $
+# $OpenBSD: Makefile,v 1.2 2001/12/01 23:27:23 miod Exp $
CFLAGS+=-Wall -Werror
-LDADD+= -lpcap
+LDADD+= -lpcap -lutil
+DPAPP+= ${LIBUTIL}
PROG= pflogd
SRCS= pflogd.c
diff --git a/sbin/pflogd/pflogd.c b/sbin/pflogd/pflogd.c
index 42b99bec812..66a7fc94d7a 100644
--- a/sbin/pflogd/pflogd.c
+++ b/sbin/pflogd/pflogd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pflogd.c,v 1.8 2001/10/10 14:30:08 mpech Exp $ */
+/* $OpenBSD: pflogd.c,v 1.9 2001/12/01 23:27:23 miod Exp $ */
/*
* Copyright (c) 2001 Theo de Raadt
@@ -44,6 +44,7 @@
#include <errno.h>
#include <stdarg.h>
#include <fcntl.h>
+#include <util.h>
#define DEF_SNAPLEN 96 /* default plus allow for larger header of pflog */
#define PCAP_TO_MS 500 /* pcap read timeout (ms) */
@@ -51,7 +52,6 @@
#define PCAP_OPT_FIL 0 /* filter optimization */
#define FLUSH_DELAY 60 /* flush delay */
-#define PFLOGD_PID_FILE "/var/run/pflogd.pid"
#define PFLOGD_LOG_FILE "/var/log/pflog"
#define PFLOGD_DEFAULT_IF "pflog0"
@@ -64,7 +64,6 @@ int gotsig_close, gotsig_alrm, gotsig_hup;
char *filename = PFLOGD_LOG_FILE;
char *interface = PFLOGD_DEFAULT_IF;
-char *pidfile = PFLOGD_PID_FILE;
char *filter = 0;
char errbuf[PCAP_ERRBUF_SIZE];
@@ -275,7 +274,6 @@ main(int argc, char **argv)
{
struct pcap_stat pstat;
int ch, np;
- FILE *fp;
while ((ch = getopt(argc, argv, "Dd:s:f:")) != -1) {
switch (ch) {
@@ -311,11 +309,7 @@ main(int argc, char **argv)
logmsg(LOG_WARNING, "Failed to become deamon: %s",
strerror(errno));
}
- fp = fopen(pidfile, "w");
- if (fp != NULL) {
- fprintf(fp, "%d\n", getpid());
- fclose(fp);
- }
+ pidfile(NULL);
}
(void)umask(S_IRWXG | S_IRWXO);
diff --git a/sbin/rtsol/Makefile b/sbin/rtsol/Makefile
index a93a7b9ab58..427d0698795 100644
--- a/sbin/rtsol/Makefile
+++ b/sbin/rtsol/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.3 2000/02/25 10:32:21 itojun Exp $
+# $OpenBSD: Makefile,v 1.4 2001/12/01 23:27:23 miod Exp $
PROG= rtsol
SRCS= rtsold.c rtsol.c if.c probe.c dump.c
@@ -8,6 +8,9 @@ CPPFLAGS+=-DINET6 -DHAVE_ARC4RANDOM -DHAVE_GETIFADDRS
#MAN= rtsold.8
NOMAN= yes
+LDADD+= -lutil
+DPADD+= ${LIBUTIL}
+
.PATH: ${.CURDIR}/../../usr.sbin/rtsold
.include <bsd.prog.mk>
diff --git a/usr.sbin/mrouted/main.c b/usr.sbin/mrouted/main.c
index d1e2ce4be89..536518f5831 100644
--- a/usr.sbin/mrouted/main.c
+++ b/usr.sbin/mrouted/main.c
@@ -26,6 +26,7 @@
#include <varargs.h>
#endif
#include <fcntl.h>
+#include <util.h>
#ifdef SNMP
#include "snmp.h"
@@ -33,13 +34,12 @@
#ifndef lint
static char rcsid[] =
- "@(#) $Id: main.c,v 1.6 2001/09/04 23:35:59 millert Exp $";
+ "@(#) $Id: main.c,v 1.7 2001/12/01 23:27:23 miod Exp $";
#endif
extern char *configfilename;
char versionstring[100];
-static char pidfilename[] = _PATH_MROUTED_PID;
static char dumpfilename[] = _PATH_MROUTED_DUMP;
static char cachefilename[] = _PATH_MROUTED_CACHE;
static char genidfilename[] = _PATH_MROUTED_GENID;
@@ -271,11 +271,7 @@ usage: fprintf(stderr,
if (debug)
fprintf(stderr, "pruning %s\n", pruning ? "on" : "off");
- fp = fopen(pidfilename, "w");
- if (fp != NULL) {
- fprintf(fp, "%d\n", (int)getpid());
- (void) fclose(fp);
- }
+ pidfile(NULL);
(void)signal(SIGALRM, fasttimer);
diff --git a/usr.sbin/mrouted/pathnames.h b/usr.sbin/mrouted/pathnames.h
index 27814ab1c19..1bdcfdcd9fe 100644
--- a/usr.sbin/mrouted/pathnames.h
+++ b/usr.sbin/mrouted/pathnames.h
@@ -12,12 +12,10 @@
#define _PATH_MROUTED_CONF "/etc/mrouted.conf"
#if (defined(BSD) && (BSD >= 199103))
-#define _PATH_MROUTED_PID "/var/run/mrouted.pid"
#define _PATH_MROUTED_GENID "/var/run/mrouted.genid"
#define _PATH_MROUTED_DUMP "/var/tmp/mrouted.dump"
#define _PATH_MROUTED_CACHE "/var/tmp/mrouted.cache"
#else
-#define _PATH_MROUTED_PID "/etc/mrouted.pid"
#define _PATH_MROUTED_GENID "/etc/mrouted.genid"
#define _PATH_MROUTED_DUMP "/usr/tmp/mrouted.dump"
#define _PATH_MROUTED_CACHE "/usr/tmp/mrouted.cache"
diff --git a/usr.sbin/rarpd/Makefile b/usr.sbin/rarpd/Makefile
index a4f5ce16086..caa4a639993 100644
--- a/usr.sbin/rarpd/Makefile
+++ b/usr.sbin/rarpd/Makefile
@@ -1,9 +1,11 @@
-# $OpenBSD: Makefile,v 1.4 2000/04/14 02:52:35 itojun Exp $
+# $OpenBSD: Makefile,v 1.5 2001/12/01 23:27:23 miod Exp $
PROG= rarpd
SRCS= rarpd.c arptab.c
MAN= rarpd.8
CPPFLAGS+=-DHAVE_IFADDRS_H
+LDADD+= -lutil
+DPADD+= ${LIBUTIL}
# Uncomment the following to require a boot file in TFTP_DIR
# to exist for a rarp reply to be sent.
diff --git a/usr.sbin/rarpd/pathnames.h b/usr.sbin/rarpd/pathnames.h
deleted file mode 100644
index 1f3e93a3c3c..00000000000
--- a/usr.sbin/rarpd/pathnames.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* $NetBSD: pathnames.h,v 1.1 1998/04/23 02:48:33 mrg Exp $ */
-
-/*
- * Copyright (c) 1998 Matthew R. Green
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
- #define _PATH_RARPDPID "/var/run/rarpd.pid"
diff --git a/usr.sbin/rarpd/rarpd.c b/usr.sbin/rarpd/rarpd.c
index cb22f20441e..ca425c15aeb 100644
--- a/usr.sbin/rarpd/rarpd.c
+++ b/usr.sbin/rarpd/rarpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rarpd.c,v 1.30 2001/06/13 20:13:29 markus Exp $ */
+/* $OpenBSD: rarpd.c,v 1.31 2001/12/01 23:27:23 miod Exp $ */
/* $NetBSD: rarpd.c,v 1.25 1998/04/23 02:48:33 mrg Exp $ */
/*
@@ -28,7 +28,7 @@ char copyright[] =
#endif /* not lint */
#ifndef lint
-static char rcsid[] = "$OpenBSD: rarpd.c,v 1.30 2001/06/13 20:13:29 markus Exp $";
+static char rcsid[] = "$OpenBSD: rarpd.c,v 1.31 2001/12/01 23:27:23 miod Exp $";
#endif
@@ -59,12 +59,11 @@ static char rcsid[] = "$OpenBSD: rarpd.c,v 1.30 2001/06/13 20:13:29 markus Exp $
#include <netdb.h>
#include <arpa/inet.h>
#include <dirent.h>
+#include <util.h>
#ifdef HAVE_IFADDRS_H
#include <ifaddrs.h>
#endif
-#include "pathnames.h"
-
#define FATAL 1 /* fatal error occurred */
#define NONFATAL 0 /* non fatal error occurred */
@@ -175,10 +174,7 @@ main(argc, argv)
}
/* write pid file */
- if ((fp = fopen(_PATH_RARPDPID, "w")) != NULL) {
- fprintf(fp, "%u\n", getpid());
- (void)fclose(fp);
- }
+ pidfile(NULL);
/* Fade into the background */
f = open("/dev/tty", O_RDWR);
@@ -1017,7 +1013,6 @@ va_dcl
vsyslog(LOG_ERR, fmt, ap);
va_end(ap);
if (fatal) {
- unlink(_PATH_RARPDPID);
exit(1);
}
/* NOTREACHED */
diff --git a/usr.sbin/rbootd/Makefile b/usr.sbin/rbootd/Makefile
index ad2ccea3285..11361492ec6 100644
--- a/usr.sbin/rbootd/Makefile
+++ b/usr.sbin/rbootd/Makefile
@@ -1,7 +1,9 @@
-# $OpenBSD: Makefile,v 1.2 1997/09/21 11:44:11 deraadt Exp $
+# $OpenBSD: Makefile,v 1.3 2001/12/01 23:27:23 miod Exp $
PROG= rbootd
SRCS= bpf.c conf.c parseconf.c rbootd.c rmpproto.c utils.c
MAN= rbootd.8
+LDADD+= -lutil
+DPADD+= ${LIBUTIL}
.include <bsd.prog.mk>
diff --git a/usr.sbin/rbootd/conf.c b/usr.sbin/rbootd/conf.c
index 13b6cdc469d..c504c16a348 100644
--- a/usr.sbin/rbootd/conf.c
+++ b/usr.sbin/rbootd/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.2 2001/01/17 00:33:03 pjanzen Exp $ */
+/* $OpenBSD: conf.c,v 1.3 2001/12/01 23:27:23 miod Exp $ */
/* $NetBSD: conf.c,v 1.5 1995/10/06 05:12:13 thorpej Exp $ */
/*
@@ -49,7 +49,7 @@
#ifndef lint
/*static char sccsid[] = "@(#)conf.c 8.1 (Berkeley) 6/4/93";*/
-static char rcsid[] = "$OpenBSD: conf.c,v 1.2 2001/01/17 00:33:03 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: conf.c,v 1.3 2001/12/01 23:27:23 miod Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -70,13 +70,11 @@ static char rcsid[] = "$OpenBSD: conf.c,v 1.2 2001/01/17 00:33:03 pjanzen Exp $"
*/
char MyHost[MAXHOSTNAMELEN+1]; /* host name */
-pid_t MyPid; /* process id */
int DebugFlg = 0; /* set true if debugging */
int BootAny = 0; /* set true if we boot anyone */
char *ConfigFile = NULL; /* configuration file */
char *DfltConfig = _PATH_RBOOTDCONF; /* default configuration file */
-char *PidFile = _PATH_RBOOTDPID; /* file w/pid of server */
char *BootDir = _PATH_RBOOTDLIB; /* directory w/boot files */
char *DbgFile = _PATH_RBOOTDDBG; /* debug output file */
diff --git a/usr.sbin/rbootd/defs.h b/usr.sbin/rbootd/defs.h
index 68491c2ceb4..f02a81c9abb 100644
--- a/usr.sbin/rbootd/defs.h
+++ b/usr.sbin/rbootd/defs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: defs.h,v 1.2 2001/01/17 00:33:03 pjanzen Exp $ */
+/* $OpenBSD: defs.h,v 1.3 2001/12/01 23:27:23 miod Exp $ */
/* $NetBSD: defs.h,v 1.5 1995/10/06 05:12:14 thorpej Exp $ */
/*
@@ -130,14 +130,12 @@ typedef struct rmpconn_s {
* All these variables are defined in "conf.c".
*/
extern char MyHost[]; /* this hosts' name */
-extern pid_t MyPid; /* this processes' ID */
extern int DebugFlg; /* set true if debugging */
extern int BootAny; /* set true if we can boot anyone */
extern char *ConfigFile; /* configuration file */
extern char *DfltConfig; /* default configuration file */
extern char *DbgFile; /* debug output file */
-extern char *PidFile; /* file containing pid of server */
extern char *BootDir; /* directory w/boot files */
extern FILE *DbgFp; /* debug file pointer */
diff --git a/usr.sbin/rbootd/pathnames.h b/usr.sbin/rbootd/pathnames.h
index fbe5c056152..191f49e4ab1 100644
--- a/usr.sbin/rbootd/pathnames.h
+++ b/usr.sbin/rbootd/pathnames.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pathnames.h,v 1.2 2001/01/17 00:33:03 pjanzen Exp $ */
+/* $OpenBSD: pathnames.h,v 1.3 2001/12/01 23:27:23 miod Exp $ */
/* $NetBSD: pathnames.h,v 1.3 1995/08/21 17:05:15 thorpej Exp $ */
/*
@@ -51,4 +51,3 @@
#define _PATH_RBOOTDCONF "/etc/rbootd.conf"
#define _PATH_RBOOTDDBG "/tmp/rbootd.dbg"
#define _PATH_RBOOTDLIB "/usr/mdec/rbootd"
-#define _PATH_RBOOTDPID "/var/run/rbootd.pid"
diff --git a/usr.sbin/rbootd/rbootd.c b/usr.sbin/rbootd/rbootd.c
index b55afe53670..6492d0c15f6 100644
--- a/usr.sbin/rbootd/rbootd.c
+++ b/usr.sbin/rbootd/rbootd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rbootd.c,v 1.8 2001/09/04 23:35:59 millert Exp $ */
+/* $OpenBSD: rbootd.c,v 1.9 2001/12/01 23:27:23 miod Exp $ */
/* $NetBSD: rbootd.c,v 1.5 1995/10/06 05:12:17 thorpej Exp $ */
/*
@@ -55,7 +55,7 @@ static char copyright[] =
#ifndef lint
/*static char sccsid[] = "@(#)rbootd.c 8.1 (Berkeley) 6/4/93";*/
-static char rcsid[] = "$OpenBSD: rbootd.c,v 1.8 2001/09/04 23:35:59 millert Exp $";
+static char rcsid[] = "$OpenBSD: rbootd.c,v 1.9 2001/12/01 23:27:23 miod Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -174,20 +174,11 @@ main(argc, argv)
}
MyHost[MAXHOSTNAMELEN] = '\0';
- MyPid = getpid();
-
/*
* Write proc's pid to a file.
*/
- {
- FILE *fp;
-
- if ((fp = fopen(PidFile, "w")) != NULL) {
- (void) fprintf(fp, "%d\n", (int) MyPid);
- (void) fclose(fp);
- } else {
- syslog(LOG_WARNING, "fopen: failed (%s)", PidFile);
- }
+ if (pidfile(NULL) < 0) {
+ syslog(LOG_WARNING, "pidfile: failed");
}
/*
diff --git a/usr.sbin/route6d/Makefile b/usr.sbin/route6d/Makefile
index a01e3f75fc7..b8834ae9263 100644
--- a/usr.sbin/route6d/Makefile
+++ b/usr.sbin/route6d/Makefile
@@ -1,7 +1,9 @@
-# $OpenBSD: Makefile,v 1.4 2001/02/07 13:52:23 itojun Exp $
+# $OpenBSD: Makefile,v 1.5 2001/12/01 23:27:23 miod Exp $
PROG= route6d
MAN= route6d.8
+LDADD+= -lutil
+DPADD+= ${LIBUTIL}
CPPFLAGS+= -DINET6
diff --git a/usr.sbin/route6d/route6d.c b/usr.sbin/route6d/route6d.c
index 01b2195fcda..6e110d3ddaa 100644
--- a/usr.sbin/route6d/route6d.c
+++ b/usr.sbin/route6d/route6d.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route6d.c,v 1.20 2001/11/17 19:49:00 deraadt Exp $ */
+/* $OpenBSD: route6d.c,v 1.21 2001/12/01 23:27:23 miod Exp $ */
/* $KAME: route6d.c,v 1.73 2001/09/05 01:12:34 itojun Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#if 0
-static char _rcsid[] = "$OpenBSD: route6d.c,v 1.20 2001/11/17 19:49:00 deraadt Exp $";
+static char _rcsid[] = "$OpenBSD: route6d.c,v 1.21 2001/12/01 23:27:23 miod Exp $";
#endif
#include <stdio.h>
@@ -50,6 +50,7 @@ static char _rcsid[] = "$OpenBSD: route6d.c,v 1.20 2001/11/17 19:49:00 deraadt E
#include <stddef.h>
#include <errno.h>
#include <err.h>
+#include <util.h>
#include <sys/types.h>
#include <sys/param.h>
@@ -283,7 +284,6 @@ main(argc, argv)
int error = 0;
struct ifc *ifcp;
sigset_t mask, omask;
- FILE *pidfile;
char *progname;
char *ep;
@@ -399,11 +399,7 @@ main(argc, argv)
}
#endif
}
- pid = getpid();
- if ((pidfile = fopen(ROUTE6D_PID, "w")) != NULL) {
- fprintf(pidfile, "%d\n", pid);
- fclose(pidfile);
- }
+ pidfile(NULL);
if ((ripbuf = (struct rip6 *)malloc(RIP6_MAXMTU)) == NULL) {
fatal("malloc");
diff --git a/usr.sbin/route6d/route6d.h b/usr.sbin/route6d/route6d.h
index 3ac73c4fc14..496d33de99a 100644
--- a/usr.sbin/route6d/route6d.h
+++ b/usr.sbin/route6d/route6d.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: route6d.h,v 1.5 2001/02/07 13:52:24 itojun Exp $ */
+/* $OpenBSD: route6d.h,v 1.6 2001/12/01 23:27:23 miod Exp $ */
/* $KAME: route6d.h,v 1.4 2001/01/15 03:50:54 inoue Exp $ */
/*
@@ -35,7 +35,6 @@
*/
#define ROUTE6D_DUMP "/var/run/route6d_dump"
-#define ROUTE6D_PID "/var/run/route6d.pid"
#define RIP6_VERSION 1
diff --git a/usr.sbin/rtadvd/Makefile b/usr.sbin/rtadvd/Makefile
index 6f14591aff9..1c43318ea5b 100644
--- a/usr.sbin/rtadvd/Makefile
+++ b/usr.sbin/rtadvd/Makefile
@@ -1,11 +1,11 @@
-# $OpenBSD: Makefile,v 1.2 2000/05/23 11:23:22 itojun Exp $
+# $OpenBSD: Makefile,v 1.3 2001/12/01 23:27:23 miod Exp $
PROG= rtadvd
SRCS= rtadvd.c rrenum.c advcap.c if.c config.c timer.c dump.c
CPPFLAGS+=-DINET6
-LDADD+= -lcompat
-DPADD+= ${LIBCOMPAT}
+LDADD+= -lcompat -lutil
+DPADD+= ${LIBCOMPAT} ${LIBUTIL}
MAN= rtadvd.8 rtadvd.conf.5
.include <bsd.prog.mk>
diff --git a/usr.sbin/rtadvd/rtadvd.c b/usr.sbin/rtadvd/rtadvd.c
index cd0d308b950..f0234f89de5 100644
--- a/usr.sbin/rtadvd/rtadvd.c
+++ b/usr.sbin/rtadvd/rtadvd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtadvd.c,v 1.11 2001/12/01 19:27:28 deraadt Exp $ */
+/* $OpenBSD: rtadvd.c,v 1.12 2001/12/01 23:27:23 miod Exp $ */
/* $KAME: rtadvd.c,v 1.50 2001/02/04 06:15:15 itojun Exp $ */
/*
@@ -55,6 +55,8 @@
#include <string.h>
#include <stdlib.h>
#include <syslog.h>
+#include <util.h>
+
#include "rtadvd.h"
#include "rrenum.h"
#include "advcap.h"
@@ -77,7 +79,6 @@ struct sockaddr_in6 from;
struct sockaddr_in6 sin6_allnodes = {sizeof(sin6_allnodes), AF_INET6};
struct in6_addr in6a_site_allrouters;
static char *dumpfilename = "/var/run/rtadvd.dump"; /* XXX: should be configurable */
-static char *pidfilename = "/var/run/rtadvd.pid"; /* should be configurable */
static char *mcastif;
int sock;
int rtsock = -1;
@@ -155,8 +156,6 @@ main(argc, argv)
struct timeval *timeout;
int i, ch;
int fflag = 0;
- FILE *pidfp;
- pid_t pid;
openlog("rtadvd", LOG_NDELAY|LOG_PID, LOG_DAEMON);
@@ -241,14 +240,10 @@ main(argc, argv)
daemon(1, 0);
/* record the current PID */
- pid = getpid();
- if ((pidfp = fopen(pidfilename, "w")) == NULL)
+ if (pidfile(NULL) < 0) {
syslog(LOG_ERR,
- "<%s> failed to open a log file(%s), run anyway.",
- __FUNCTION__, pidfilename);
- else {
- fprintf(pidfp, "%d\n", pid);
- fclose(pidfp);
+ "<%s> failed to open the pid log file, run anyway.",
+ __FUNCTION__);
}
FD_ZERO(&fdset);
diff --git a/usr.sbin/rtsold/Makefile b/usr.sbin/rtsold/Makefile
index 57ca7681c11..a7d148f726e 100644
--- a/usr.sbin/rtsold/Makefile
+++ b/usr.sbin/rtsold/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.3 2000/02/25 10:32:21 itojun Exp $
+# $OpenBSD: Makefile,v 1.4 2001/12/01 23:27:24 miod Exp $
PROG= rtsold
SRCS= rtsold.c rtsol.c if.c probe.c dump.c
@@ -8,4 +8,7 @@ CPPFLAGS+=-DINET6 -DHAVE_ARC4RANDOM -DHAVE_GETIFADDRS
MAN= rtsold.8
MLINKS= rtsold.8 rtsol.8
+LDADD+= -lutil
+DPADD+= ${LIBUTIL}
+
.include <bsd.prog.mk>
diff --git a/usr.sbin/rtsold/rtsold.c b/usr.sbin/rtsold/rtsold.c
index 5dfefa6ec18..b8443763675 100644
--- a/usr.sbin/rtsold/rtsold.c
+++ b/usr.sbin/rtsold/rtsold.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsold.c,v 1.12 2001/12/01 19:27:28 deraadt Exp $ */
+/* $OpenBSD: rtsold.c,v 1.13 2001/12/01 23:27:24 miod Exp $ */
/* $KAME: rtsold.c,v 1.32 2001/07/09 22:34:07 itojun Exp $ */
/*
@@ -50,6 +50,8 @@
#include <err.h>
#include <stdarg.h>
#include <ifaddrs.h>
+#include <util.h>
+
#include "rtsold.h"
struct ifinfo *iflist;
@@ -87,7 +89,6 @@ int main __P((int argc, char *argv[]));
static int mobile_node = 0;
volatile sig_atomic_t do_dump;
static char *dumpfilename = "/var/run/rtsold.dump"; /* XXX: should be configurable */
-static char *pidfilename = "/var/run/rtsold.pid"; /* should be configurable */
static int ifconfig __P((char *ifname));
#if 0
@@ -259,16 +260,10 @@ main(argc, argv)
/* dump the current pid */
if (!once) {
- pid_t pid = getpid();
- FILE *fp;
-
- if ((fp = fopen(pidfilename, "w")) == NULL)
+ if (pidfile(NULL) < 0) {
warnmsg(LOG_ERR, __FUNCTION__,
- "failed to open a log file(%s): %s",
- pidfilename, strerror(errno));
- else {
- fprintf(fp, "%d\n", pid);
- fclose(fp);
+ "failed to open a pid log file: %s",
+ strerror(errno));
}
}
diff --git a/usr.sbin/screenblank/Makefile b/usr.sbin/screenblank/Makefile
index c39644e4fb5..0b6d3ae072d 100644
--- a/usr.sbin/screenblank/Makefile
+++ b/usr.sbin/screenblank/Makefile
@@ -1,10 +1,10 @@
-# $OpenBSD: Makefile,v 1.3 2000/05/18 16:46:38 espie Exp $
+# $OpenBSD: Makefile,v 1.4 2001/12/01 23:27:24 miod Exp $
.if ${MACHINE} == "sparc" || ${MACHINE} == "sun3"
PROG= screenblank
-DPADD= ${LIBM}
-LDADD= -lm
+LDADD+= -lm -lutil
+DPADD+= ${LIBM} ${LIBUTIL}
.else
NOPROG=yes
.endif
diff --git a/usr.sbin/screenblank/pathnames.h b/usr.sbin/screenblank/pathnames.h
index 9028a34bfcf..2828cf15be5 100644
--- a/usr.sbin/screenblank/pathnames.h
+++ b/usr.sbin/screenblank/pathnames.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pathnames.h,v 1.2 1996/03/25 15:56:12 niklas Exp $ */
+/* $OpenBSD: pathnames.h,v 1.3 2001/12/01 23:27:24 miod Exp $ */
/* $NetBSD: pathnames.h,v 1.2 1996/02/28 01:18:30 thorpej Exp $ */
/*-
@@ -37,7 +37,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#define _PATH_SCREENBLANKPID "/var/run/screenblank.pid"
#define _PATH_KEYBOARD "/dev/kbd"
#define _PATH_MOUSE "/dev/mouse"
#define _PATH_FB "/dev/fb"
diff --git a/usr.sbin/screenblank/screenblank.c b/usr.sbin/screenblank/screenblank.c
index 41247201a32..697b2d5fa75 100644
--- a/usr.sbin/screenblank/screenblank.c
+++ b/usr.sbin/screenblank/screenblank.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screenblank.c,v 1.8 2001/11/17 00:02:34 deraadt Exp $ */
+/* $OpenBSD: screenblank.c,v 1.9 2001/12/01 23:27:24 miod Exp $ */
/* $NetBSD: screenblank.c,v 1.2 1996/02/28 01:18:34 thorpej Exp $ */
/*-
@@ -77,7 +77,6 @@ extern char *__progname;
static void add_dev __P((char *, int));
static void change_state __P((int, int));
static void cvt_arg __P((char *, struct timeval *));
-static void logpid __P((void));
static void sighandler __P((int));
static void usage __P((void));
@@ -169,7 +168,7 @@ main(argc, argv)
/* Detach. */
if (daemon(0, 0))
err(1, "daemon");
- logpid();
+ pidfile(NULL);
/* Start the state machine. */
for (;;) {
@@ -247,8 +246,7 @@ sighandler(sig)
int sig;
{
- /* Kill the pid file and re-enable the framebuffer before exit. */
- (void)unlink(_PATH_SCREENBLANKPID);
+ /* Re-enable the framebuffer before exit. */
change_state(FBVIDEO_ON, 1);
_exit(0);
}
@@ -313,17 +311,6 @@ cvt_arg(arg, tvp)
}
static void
-logpid()
-{
- FILE *fp;
-
- if ((fp = fopen(_PATH_SCREENBLANKPID, "w")) != NULL) {
- fprintf(fp, "%u\n", getpid());
- (void)fclose(fp);
- }
-}
-
-static void
usage()
{
diff --git a/usr.sbin/ypserv/common/ypdef.h b/usr.sbin/ypserv/common/ypdef.h
index aa960ddc232..813b11424e9 100644
--- a/usr.sbin/ypserv/common/ypdef.h
+++ b/usr.sbin/ypserv/common/ypdef.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ypdef.h,v 1.6 1997/03/30 20:51:14 maja Exp $ */
+/* $OpenBSD: ypdef.h,v 1.7 2001/12/01 23:27:24 miod Exp $ */
/*
* Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se>
@@ -65,7 +65,6 @@
#define YPXFR_PROC "/usr/sbin/ypxfr"
#define YPPUSH_PROC "/usr/sbin/yppush"
-#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/Makefile b/usr.sbin/ypserv/ypserv/Makefile
index 4f8e70a90e9..1119c74861f 100644
--- a/usr.sbin/ypserv/ypserv/Makefile
+++ b/usr.sbin/ypserv/ypserv/Makefile
@@ -1,9 +1,11 @@
-# $OpenBSD: Makefile,v 1.5 1997/08/09 23:10:11 maja Exp $
+# $OpenBSD: Makefile,v 1.6 2001/12/01 23:27:24 miod Exp $
PROG= ypserv
SRCS= ypserv.c ypserv_proc.c ypserv_db.c acl.c yplog.c ypdb.c ypserv_xdr.c \
ypserv_xdr_v1.c
MAN= ypserv.acl.5 securenet.5 ypserv.8
+LDADD+= -lutil
+DPADD+= ${LIBUTIL}
.PATH: ${.CURDIR}/../common
CFLAGS+=-DDAEMON -DOPTDB -I${.CURDIR}/../common
#CFLAGS=-DDAEMON -I${.CURDIR}/../common -DDEBUG -g
diff --git a/usr.sbin/ypserv/ypserv/ypserv.c b/usr.sbin/ypserv/ypserv/ypserv.c
index a081acd0471..29b2d743262 100644
--- a/usr.sbin/ypserv/ypserv/ypserv.c
+++ b/usr.sbin/ypserv/ypserv/ypserv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ypserv.c,v 1.16 2001/11/19 09:03:06 deraadt Exp $ */
+/* $OpenBSD: ypserv.c,v 1.17 2001/12/01 23:27:24 miod 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.16 2001/11/19 09:03:06 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: ypserv.c,v 1.17 2001/12/01 23:27:24 miod Exp $";
#endif
#include <sys/types.h>
@@ -497,13 +497,7 @@ main(argc, argv)
(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);
- }
- }
+ pidfile(NULL);
if ((_rpcfdtype == 0) || (_rpcfdtype == SOCK_DGRAM)) {
transp = svcudp_create(sock);