support /var/run/rarpd.pid
This commit is contained in:
parent
63babb7549
commit
b7e46f9175
|
@ -0,0 +1,31 @@
|
|||
/* $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"
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rarpd.c,v 1.24 1998/04/15 15:06:06 mrg Exp $ */
|
||||
/* $NetBSD: rarpd.c,v 1.25 1998/04/23 02:48:33 mrg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -28,7 +28,7 @@ __COPYRIGHT(
|
|||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: rarpd.c,v 1.24 1998/04/15 15:06:06 mrg Exp $");
|
||||
__RCSID("$NetBSD: rarpd.c,v 1.25 1998/04/23 02:48:33 mrg Exp $");
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -70,6 +70,8 @@ __RCSID("$NetBSD: rarpd.c,v 1.24 1998/04/15 15:06:06 mrg Exp $");
|
|||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "pathnames.h"
|
||||
|
||||
#define FATAL 1 /* fatal error occurred */
|
||||
#define NONFATAL 0 /* non fatal error occurred */
|
||||
|
||||
|
@ -172,6 +174,8 @@ main(argc, argv)
|
|||
init_one(ifname);
|
||||
|
||||
if ((!fflag) && (!dflag)) {
|
||||
FILE *fp;
|
||||
|
||||
pid = fork();
|
||||
if (pid > 0)
|
||||
/* Parent exits, leaving child in background. */
|
||||
|
@ -181,6 +185,13 @@ main(argc, argv)
|
|||
rarperr(FATAL, "cannot fork");
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/* write pid file */
|
||||
if ((fp = fopen(_PATH_RARPDPID, "w")) != NULL) {
|
||||
fprintf(fp, "%u\n", getpid());
|
||||
(void)fclose(fp);
|
||||
}
|
||||
|
||||
/* Fade into the background */
|
||||
f = open("/dev/tty", O_RDWR);
|
||||
if (f >= 0) {
|
||||
|
@ -717,6 +728,7 @@ lookup_ipaddr(ifname, addrp, netmaskp)
|
|||
*addrp = ((struct sockaddr_in *) & ifr.ifr_addr)->sin_addr.s_addr;
|
||||
if (ioctl(fd, SIOCGIFNETMASK, (char *) &ifr) < 0) {
|
||||
perror("SIOCGIFNETMASK");
|
||||
unlink(_PATH_RARPDPID);
|
||||
exit(1);
|
||||
}
|
||||
*netmaskp = ((struct sockaddr_in *) & ifr.ifr_addr)->sin_addr.s_addr;
|
||||
|
@ -915,8 +927,10 @@ va_dcl
|
|||
}
|
||||
vsyslog(LOG_ERR, fmt, ap);
|
||||
va_end(ap);
|
||||
if (fatal)
|
||||
if (fatal) {
|
||||
unlink(_PATH_RARPDPID);
|
||||
exit(1);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue