summaryrefslogtreecommitdiff
path: root/relay
diff options
context:
space:
mode:
authorShawn Routhier <sar@isc.org>2011-04-15 21:58:12 +0000
committerShawn Routhier <sar@isc.org>2011-04-15 21:58:12 +0000
commit4a5bfeacbe463cb577f6edbf0143916847ea5feb (patch)
tree7cb9b6f08069c1f19b7b55a5a72d715bdc8a20ac /relay
parentc7aa4dd4a4a3434f6f6ce017d2f4391882730049 (diff)
downloadisc-dhcp-4a5bfeacbe463cb577f6edbf0143916847ea5feb.tar.gz
Add the option "--no-pid" to the client, relay and server code,
to disable writing a pid file. Add the option "-pf pidfile" to the relay to allow the user to supply the pidfile name at runtime. Add the "with-relay6-pid-file" option to configure to allow the user to supply the pidfile name for the relay in v6 mode at configure time. [ISC-Bugs #23351] [ISC-Bugs #17541]
Diffstat (limited to 'relay')
-rw-r--r--relay/dhcrelay.825
-rw-r--r--relay/dhcrelay.c70
2 files changed, 69 insertions, 26 deletions
diff --git a/relay/dhcrelay.8 b/relay/dhcrelay.8
index 0177071c..eef0ece7 100644
--- a/relay/dhcrelay.8
+++ b/relay/dhcrelay.8
@@ -1,6 +1,6 @@
.\" dhcrelay.8
.\"
-.\" Copyright (c) 2009-2010 by Internet Systems Consortium, Inc. ("ISC")
+.\" Copyright (c) 2009-2011 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 2004,2007 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 1997-2003 by Internet Software Consortium
.\"
@@ -28,7 +28,7 @@
.\" Support and other services are available for ISC products - see
.\" https://www.isc.org for more information or to learn more about ISC.
.\"
-.\" $Id: dhcrelay.8,v 1.18 2010/07/02 23:09:14 sar Exp $
+.\" $Id: dhcrelay.8,v 1.19 2011/04/15 21:58:12 sar Exp $
.\"
.TH dhcrelay 8
.SH NAME
@@ -54,6 +54,13 @@ dhcrelay - Dynamic Host Configuration Protocol Relay Agent
.I length
]
[
+.B -pf
+.I pid-file
+]
+[
+.B --no-pid
+]
+[
.B -m
.I append
|
@@ -89,6 +96,13 @@ dhcrelay - Dynamic Host Configuration Protocol Relay Agent
.B -c
.I count
]
+[
+.B -pf
+.I pid-file
+]
+[
+.B --no-pid
+]
.B -l
.I lower0
[
@@ -150,6 +164,13 @@ purposes. Default is port 67 for DHCPv4/BOOTP, or port 547 for DHCPv6.
-q
Quiet mode. Prevents dhcrelay6 from printing its network configuration
on startup.
+.TP
+-pf pid-file
+Path to alternate pid file.
+.TP
+--no-pid
+Option to disable writing pid files. By default the program
+will write a pid file.
.PP
\fIOptions available in DHCPv4 mode only:\fR
.TP
diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c
index b127328a..62689fbc 100644
--- a/relay/dhcrelay.c
+++ b/relay/dhcrelay.c
@@ -3,7 +3,7 @@
DHCP/BOOTP Relay Agent. */
/*
- * Copyright(c) 2004-2009 by Internet Systems Consortium, Inc.("ISC")
+ * Copyright(c) 2004-2011 by Internet Systems Consortium, Inc.("ISC")
* Copyright(c) 1997-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
@@ -49,6 +49,9 @@ char *token_line;
char *tlname;
const char *path_dhcrelay_pid = _PATH_DHCRELAY_PID;
+isc_boolean_t no_dhcrelay_pid = ISC_FALSE;
+/* False (default) => we write and use a pid file */
+isc_boolean_t no_pid_file = ISC_FALSE;
int bogus_agent_drops = 0; /* Packets dropped because agent option
field was specified and we're not relaying
@@ -138,10 +141,12 @@ static const char url[] =
#define DHCRELAY_USAGE \
"Usage: dhcrelay [-4] [-d] [-q] [-a] [-D]\n"\
" [-A <length>] [-c <hops>] [-p <port>]\n" \
+" [-pf <pid-file>] [--no-pid]\n"\
" [-m append|replace|forward|discard]\n" \
" [-i interface0 [ ... -i interfaceN]\n" \
" server0 [ ... serverN]\n\n" \
" dhcrelay -6 [-d] [-q] [-I] [-c <hops>] [-p <port>]\n" \
+" [-pf <pid-file>] [--no-pid]\n"\
" -l lower0 [ ... -l lowerN]\n" \
" -u upper0 [ ... -u upperN]\n" \
" lower (client link): [address%%]interface[#index]\n" \
@@ -149,6 +154,7 @@ static const char url[] =
#else
#define DHCRELAY_USAGE \
"Usage: dhcrelay [-d] [-q] [-a] [-D] [-A <length>] [-c <hops>] [-p <port>]\n" \
+" [-pf <pid-file>] [--no-pid]\n"\
" [-m append|replace|forward|discard]\n" \
" [-i interface0 [ ... -i interfaceN]\n" \
" server0 [ ... serverN]\n\n"
@@ -350,6 +356,13 @@ main(int argc, char **argv) {
sl->next = upstreams;
upstreams = sl;
#endif
+ } else if (!strcmp(argv[i], "-pf")) {
+ if (++i == argc)
+ usage();
+ path_dhcrelay_pid = argv[i];
+ no_dhcrelay_pid = ISC_TRUE;
+ } else if (!strcmp(argv[i], "--no-pid")) {
+ no_pid_file = ISC_TRUE;
} else if (!strcmp(argv[i], "--version")) {
log_info("isc-dhcrelay-%s", PACKAGE_VERSION);
exit(0);
@@ -394,18 +407,24 @@ main(int argc, char **argv) {
}
}
- if (local_family == AF_INET) {
- path_dhcrelay_pid = getenv("PATH_DHCRELAY_PID");
- if (path_dhcrelay_pid == NULL)
- path_dhcrelay_pid = _PATH_DHCRELAY_PID;
- }
+ /*
+ * If the user didn't specify a pid file directly
+ * find one from environment variables or defaults
+ */
+ if (no_dhcrelay_pid == ISC_FALSE) {
+ if (local_family == AF_INET) {
+ path_dhcrelay_pid = getenv("PATH_DHCRELAY_PID");
+ if (path_dhcrelay_pid == NULL)
+ path_dhcrelay_pid = _PATH_DHCRELAY_PID;
+ }
#ifdef DHCPv6
- else {
- path_dhcrelay_pid = getenv("PATH_DHCRELAY6_PID");
- if (path_dhcrelay_pid == NULL)
- path_dhcrelay_pid = _PATH_DHCRELAY6_PID;
- }
+ else {
+ path_dhcrelay_pid = getenv("PATH_DHCRELAY6_PID");
+ if (path_dhcrelay_pid == NULL)
+ path_dhcrelay_pid = _PATH_DHCRELAY6_PID;
+ }
#endif
+ }
if (!quiet) {
log_info("%s %s", message, PACKAGE_VERSION);
@@ -519,20 +538,23 @@ main(int argc, char **argv) {
else if (pid)
exit(0);
- pfdesc = open(path_dhcrelay_pid,
- O_CREAT | O_TRUNC | O_WRONLY, 0644);
+ if (no_pid_file == ISC_FALSE) {
+ pfdesc = open(path_dhcrelay_pid,
+ O_CREAT | O_TRUNC | O_WRONLY, 0644);
- if (pfdesc < 0) {
- log_error("Can't create %s: %m", path_dhcrelay_pid);
- } else {
- pf = fdopen(pfdesc, "w");
- if (!pf)
- log_error("Can't fdopen %s: %m",
- path_dhcrelay_pid);
- else {
- fprintf(pf, "%ld\n",(long)getpid());
- fclose(pf);
- }
+ if (pfdesc < 0) {
+ log_error("Can't create %s: %m",
+ path_dhcrelay_pid);
+ } else {
+ pf = fdopen(pfdesc, "w");
+ if (!pf)
+ log_error("Can't fdopen %s: %m",
+ path_dhcrelay_pid);
+ else {
+ fprintf(pf, "%ld\n",(long)getpid());
+ fclose(pf);
+ }
+ }
}
close(0);