Changes since 4.0.0b1
+- Use different paths for PID and lease files when running in DHCPv4
+ or DHCPv6 mode, so that servers for both protcols can be run
+ simultaneously on a single interface.
+
- Fixed a buffer overflow error which could have allowed a denial
of service under unusual server configurations
-static const char rcsid[] = "$Header: /tmp/cvstest/DHCP/dst/dst_support.c,v 1.1 2001/02/22 07:22:08 mellon Exp $";
+static const char rcsid[] = "$Header: /tmp/cvstest/DHCP/dst/dst_support.c,v 1.2 2007/10/27 19:15:32 each Exp $";
/*
}
bp = strchr(*buf, '\n'); /* find length of input line */
if (bp != NULL)
- *bp = (u_char) NULL;
+ *bp = '\0';
blen = b64_pton(*buf, bstr, sizeof(bstr));
if (blen <= 0) {
#ifndef _PATH_DHCPD_PID
#define _PATH_DHCPD_PID "/etc/dhcpd.pid"
#endif
+#ifndef _PATH_DHCPD6_PID
+#define _PATH_DHCPD6_PID "/etc/dhcpd6.pid"
+#endif
#ifndef _PATH_DHCLIENT_PID
#define _PATH_DHCLIENT_PID "/etc/dhclient.pid"
#endif
#ifndef _PATH_DHCPD_PID
#define _PATH_DHCPD_PID "/var/run/dhcpd.pid"
#endif
+#ifndef _PATH_DHCPD6_PID
+#define _PATH_DHCPD6_PID "/var/run/dhcpd6.pid"
+#endif
#ifndef _PATH_DHCLIENT_PID
#define _PATH_DHCLIENT_PID "/var/run/dhclient.pid"
#endif
#ifndef _PATH_DHCPD_PID
#define _PATH_DHCPD_PID "/var/run/dhcpd.pid"
#endif
+#ifndef _PATH_DHCPD6_PID
+#define _PATH_DHCPD6_PID "/var/run/dhcpd6.pid"
+#endif
#ifndef _PATH_DHCPD_DB
#define _PATH_DHCPD_DB "/var/db/dhcpd.leases"
#endif
+#ifndef _PATH_DHCPD6_DB
+#define _PATH_DHCPD6_DB "/var/db/dhcpd6.leases"
+#endif
#ifndef _PATH_DHCLIENT_PID
#define _PATH_DHCLIENT_PID "/var/run/dhclient.pid"
#endif
#ifndef _PATH_DHCPD_PID
#define _PATH_DHCPD_PID "//e/etc/dhcpd.pid"
#endif
+#ifndef _PATH_DHCPD6_PID
+#define _PATH_DHCPD6_PID "//e/etc/dhcpd6.pid"
+#endif
#ifndef _PATH_DHCPD_DB
#define _PATH_DHCPD_DB "//e/etc/dhcpd.leases"
#endif
+#ifndef _PATH_DHCPD6_DB
+#define _PATH_DHCPD6_DB "//e/etc/dhcpd6.leases"
+#endif
#ifndef _PATH_DHCPD_CONF
#define _PATH_DHCPD_CONF "//e/etc/dhcpd.conf"
#endif
#ifndef _PATH_DHCPD_PID
#define _PATH_DHCPD_PID "/var/run/dhcpd.pid"
#endif
+#ifndef _PATH_DHCPD6_PID
+#define _PATH_DHCPD6_PID "/var/run/dhcpd6.pid"
+#endif
#ifndef _PATH_DHCPD_DB
#define _PATH_DHCPD_DB "/var/db/dhcpd.leases"
#endif
+#ifndef _PATH_DHCPD6_DB
+#define _PATH_DHCPD6_DB "/var/db/dhcpd6.leases"
+#endif
#ifndef _PATH_DHCLIENT_PID
#define _PATH_DHCLIENT_PID "/var/run/dhclient.pid"
#endif
#ifndef _PATH_DHCPD_PID
#define _PATH_DHCPD_PID "/etc/dhcpd.pid"
#endif
+#ifndef _PATH_DHCPD6_PID
+#define _PATH_DHCPD6_PID "/etc/dhcpd6.pid"
+#endif
#ifndef _PATH_DHCLIENT_PID
#define _PATH_DHCLIENT_PID "/etc/dhclient.pid"
#endif
#include <net/if_arp.h>
#define _PATH_DHCPD_CONF "/usr/local/etc/dhcpd.conf"
-#define _PATH_DHCPD_DB "/usr/local/etc/dhcp/dhcpd.leases"
+#ifndef _PATH_DHCPD_DB
+#define _PATH_DHCPD_DB "/usr/local/etc/dhcp/dhcpd.leases"
+#endif
+#ifndef _PATH_DHCPD6_DB
+#define _PATH_DHCPD6_DB "/usr/local/etc/dhcp/dhcpd6.leases"
+#endif
#ifndef _PATH_DHCPD_PID
#define _PATH_DHCPD_PID "/etc/dhcpd.pid"
#endif
+#ifndef _PATH_DHCPD6_PID
+#define _PATH_DHCPD6_PID "/etc/dhcpd6.pid"
+#endif
#ifndef _PATH_DHCLIENT_PID
#define _PATH_DHCLIENT_PID "/etc/dhclient.pid"
#endif
#ifndef _PATH_DHCPD_DB
#define _PATH_DHCPD_DB "/var/state/dhcp/dhcpd.leases"
#endif
+#ifndef _PATH_DHCPD6_DB
+#define _PATH_DHCPD6_DB "/var/state/dhcp/dhcpd6.leases"
+#endif
#ifndef _PATH_DHCLIENT_DB
#define _PATH_DHCLIENT_DB "/var/state/dhcp/dhclient.leases"
#ifndef _PATH_DHCPD_PID
#define _PATH_DHCPD_PID "/var/run/dhcpd.pid"
#endif
+#ifndef _PATH_DHCPD6_PID
+#define _PATH_DHCPD6_PID "/var/run/dhcpd6.pid"
+#endif
#ifndef _PATH_DHCPD_DB
#define _PATH_DHCPD_DB "/var/db/dhcpd.leases"
#endif
+#ifndef _PATH_DHCPD6_DB
+#define _PATH_DHCPD6_DB "/var/db/dhcpd6.leases"
+#endif
#ifndef _PATH_DHCLIENT_PID
#define _PATH_DHCLIENT_PID "/var/run/dhclient.pid"
#endif
# define _PATH_DHCPD_PID "/etc/dhcpd.pid"
#endif
+#if !defined (_PATH_DHCPD6_PID)
+# define _PATH_DHCPD6_PID "/etc/dhcpd6.pid"
+#endif
+
#if !defined (_PATH_DHCLIENT_PID)
# define _PATH_DHCLIENT_PID "/etc/dhclient.pid"
#endif
#ifndef _PATH_DHCPD_PID
#define _PATH_DHCPD_PID "/var/run/dhcpd.pid"
#endif
+#ifndef _PATH_DHCPD6_PID
+#define _PATH_DHCPD6_PID "/var/run/dhcpd6.pid"
+#endif
#ifndef _PATH_DHCPD_DB
#define _PATH_DHCPD_DB "/var/db/dhcpd.leases"
#endif
+#ifndef _PATH_DHCPD6_DB
+#define _PATH_DHCPD6_DB "/var/db/dhcpd6.leases"
+#endif
#ifndef _PATH_DHCLIENT_PID
#define _PATH_DHCLIENT_PID "/var/run/dhclient.pid"
#endif
#ifndef _PATH_DHCPD_PID
#define _PATH_DHCPD_PID "/etc/dhcpd.pid"
#endif
+#ifndef _PATH_DHCPD6_PID
+#define _PATH_DHCPD6_PID "/etc/dhcpd6.pid"
+#endif
#ifndef _PATH_DHCLIENT_PID
#define _PATH_DHCLIENT_PID "/etc/dhclient.pid"
#endif
#ifndef _PATH_DHCPD_PID
#define _PATH_DHCPD_PID "/var/run/dhcpd.pid"
#endif
+#ifndef _PATH_DHCPD6_PID
+#define _PATH_DHCPD6_PID "/var/run/dhcpd6.pid"
+#endif
#ifndef _PATH_DHCPD_DB
#define _PATH_DHCPD_DB "/var/db/dhcpd.leases"
#endif
+#ifndef _PATH_DHCPD6_DB
+#define _PATH_DHCPD6_DB "/var/db/dhcpd6.leases"
+#endif
#ifndef _PATH_DHCLIENT_PID
#define _PATH_DHCLIENT_PID "/var/run/dhclient.pid"
#endif
#ifndef _PATH_DHCPD_PID
#define _PATH_DHCPD_PID "/etc/dhcpd.pid"
#endif
+#ifndef _PATH_DHCPD6_PID
+#define _PATH_DHCPD6_PID "/etc/dhcpd6.pid"
+#endif
#ifndef _PATH_DHCLIENT_PID
#define _PATH_DHCLIENT_PID "/etc/dhclient.pid"
#endif
+#ifndef _PATH_DHCLIENT6_PID
+#define _PATH_DHCLIENT6_PID "/etc/dhclient6.pid"
+#endif
#ifndef _PATH_DHCRELAY_PID
#define _PATH_DHCRELAY_PID "/etc/dhcrelay.pid"
#endif
#ifndef _PATH_DHCPD_PID
#define _PATH_DHCPD_PID "/etc/dhcpd.pid"
#endif
+#ifndef _PATH_DHCPD6_PID
+#define _PATH_DHCPD6_PID "/etc/dhcpd6.pid"
+#endif
#ifndef _PATH_DHCLIENT_PID
#define _PATH_DHCLIENT_PID "/etc/dhclient.pid"
#endif
#ifndef _PATH_DHCPD_DB
#define _PATH_DHCPD_DB "/etc/dhcpd.leases"
#endif
+#ifndef _PATH_DHCPD6_DB
+#define _PATH_DHCPD6_DB "/etc/dhcpd6.leases"
+#endif
#ifndef _PATH_DHCLIENT_DB
#define _PATH_DHCLIENT_DB "/etc/dhclient.leases"
#endif
#ifndef _PATH_DHCPD_PID
#define _PATH_DHCPD_PID "/etc/dhcpd.pid"
#endif
+#ifndef _PATH_DHCPD6_PID
+#define _PATH_DHCPD6_PID "/etc/dhcpd6.pid"
+#endif
#ifndef _PATH_DHCLIENT_PID
#define _PATH_DHCLIENT_PID "/etc/dhclient.pid"
#endif
#ifndef _PATH_DHCPD_PID
#define _PATH_DHCPD_PID "/etc/dhcpd.pid"
#endif
+#ifndef _PATH_DHCPD6_PID
+#define _PATH_DHCPD6_PID "/etc/dhcpd6.pid"
+#endif
#ifndef _PATH_DHCLIENT_PID
#define _PATH_DHCLIENT_PID "/etc/dhclient.pid"
#endif
#ifndef _PATH_DHCPD_PID
#define _PATH_DHCPD_PID "/etc/dhcpd.pid"
#endif
+#ifndef _PATH_DHCPD6_PID
+#define _PATH_DHCPD6_PID "/etc/dhcpd6.pid"
+#endif
#ifndef _PATH_DHCLIENT_PID
#define _PATH_DHCLIENT_PID "/etc/dhclient.pid"
#endif
#define SV_DO_REVERSE_UPDATES 51
#define SV_FQDN_REPLY 52
#define SV_PREFER_LIFETIME 53
+#define SV_DHCPV6_LEASE_FILE_NAME 54
+#define SV_DHCPV6_PID_FILE_NAME 55
#if !defined (DEFAULT_PING_TIMEOUT)
# define DEFAULT_PING_TIMEOUT 1
#define _PATH_DHCPD_CONF "dhcpd.conf"
#undef _PATH_DHCPD_DB
#define _PATH_DHCPD_DB "dhcpd.leases"
+#undef _PATH_DHCPD6_DB
+#define _PATH_DHCPD6_DB "dhcpd6.leases"
#undef _PATH_DHCPD_PID
#define _PATH_DHCPD_PID "dhcpd.pid"
+#undef _PATH_DHCPD6_PID
+#define _PATH_DHCPD6_PID "dhcpd6.pid"
#else /* !DEBUG */
+
#ifndef _PATH_DHCPD_CONF
#define _PATH_DHCPD_CONF "/etc/dhcpd.conf"
#endif /* DEBUG */
#define _PATH_DHCPD_DB LOCALSTATEDIR"/db/dhcpd.leases"
#endif
+#ifndef _PATH_DHCPD6_DB
+#define _PATH_DHCPD6_DB LOCALSTATEDIR"/db/dhcpd6.leases"
+#endif
+
#ifndef _PATH_DHCPD_PID
#define _PATH_DHCPD_PID LOCALSTATEDIR"/run/dhcpd.pid"
#endif
+
+#ifndef _PATH_DHCPD6_PID
+#define _PATH_DHCPD6_PID LOCALSTATEDIR"/run/dhcpd6.pid"
#endif
+#endif /* DEBUG */
+
#ifndef _PATH_DHCLIENT_CONF
#define _PATH_DHCLIENT_CONF "/etc/dhclient.conf"
#endif
} else if (!strcmp (argv [i], "-q")) {
quiet = 1;
quiet_interface_discovery = 1;
+#ifdef DHCPv6
} else if (!strcmp(argv[i], "-4")) {
if (local_family_set && (local_family != AF_INET)) {
log_fatal("Server cannot run in both IPv4 and "
}
local_family = AF_INET6;
local_family_set = 1;
+#endif /* DHCPv6 */
} else if (!strcmp (argv [i], "--version")) {
log_info("isc-dhcpd-%s", PACKAGE_VERSION);
exit (0);
if (!no_dhcpd_conf && (s = getenv ("PATH_DHCPD_CONF"))) {
path_dhcpd_conf = s;
}
- if (!no_dhcpd_db && (s = getenv ("PATH_DHCPD_DB"))) {
- path_dhcpd_db = s;
- }
- if (!no_dhcpd_pid && (s = getenv ("PATH_DHCPD_PID"))) {
- path_dhcpd_pid = s;
- }
+
+#ifdef DHCPv6
+ if (local_family == AF_INET6) {
+ /* DHCPv6: override DHCPv4 lease and pid filenames */
+ if (!no_dhcpd_db) {
+ if ((s = getenv ("PATH_DHCPD6_DB")))
+ path_dhcpd_db = s;
+ else
+ path_dhcpd_db = _PATH_DHCPD6_DB;
+ }
+ if (!no_dhcpd_pid) {
+ if ((s = getenv ("PATH_DHCPD6_PID")))
+ path_dhcpd_pid = s;
+ else
+ path_dhcpd_pid = _PATH_DHCPD6_PID;
+ }
+ } else
+#else /* !DHCPv6 */
+ {
+ if (!no_dhcpd_db && (s = getenv ("PATH_DHCPD_DB"))) {
+ path_dhcpd_db = s;
+ }
+ if (!no_dhcpd_pid && (s = getenv ("PATH_DHCPD_PID"))) {
+ path_dhcpd_pid = s;
+ }
+ }
+#endif /* DHCPv6 */
/*
* convert relative path names to absolute, for files that need
data_string_forget (&db, MDL);
path_dhcpd_db = s;
}
-
+
oc = lookup_option (&server_universe, options, SV_PID_FILE_NAME);
if (oc &&
evaluate_option_cache (&db, (struct packet *)0,
path_dhcpd_pid = s;
}
+#ifdef DHCPv6
+ if (local_family == AF_INET6) {
+ /*
+ * Override lease file name with dhcpv6 lease file name,
+ * if it was set; then, do the same with the pid file name
+ */
+ oc = lookup_option(&server_universe, options,
+ SV_DHCPV6_LEASE_FILE_NAME);
+ if (oc &&
+ evaluate_option_cache(&db, NULL, NULL, NULL,
+ options, NULL, &global_scope,
+ oc, MDL)) {
+ s = dmalloc (db.len + 1, MDL);
+ if (!s)
+ log_fatal ("no memory for lease db filename.");
+ memcpy (s, db.data, db.len);
+ s [db.len] = 0;
+ data_string_forget (&db, MDL);
+ path_dhcpd_db = s;
+ }
+
+ oc = lookup_option(&server_universe, options,
+ SV_DHCPV6_PID_FILE_NAME);
+ if (oc &&
+ evaluate_option_cache(&db, NULL, NULL, NULL,
+ options, NULL, &global_scope,
+ oc, MDL)) {
+ s = dmalloc (db.len + 1, MDL);
+ if (!s)
+ log_fatal ("no memory for lease db filename.");
+ memcpy (s, db.data, db.len);
+ s [db.len] = 0;
+ data_string_forget (&db, MDL);
+ path_dhcpd_pid = s;
+ }
+ }
+#endif /* DHCPv6 */
+
omapi_port = -1;
oc = lookup_option (&server_universe, options, SV_OMAPI_PORT);
if (oc &&
log_info(arr);
log_fatal("Usage: dhcpd [-p <UDP port #>] [-f] [-d] [-q] [-t|-T]\n"
+#ifdef DHCPv6
" [-4|-6] [-cf config-file] [-lf lease-file]\n"
+#else /* !DHCPv6 */
+ " [-cf config-file] [-lf lease-file]\n"
+#endif /* DHCPv6 */
#if defined (TRACING)
" [-tf trace-output-file]\n"
" [-play trace-input-file]\n"
.\" see ``http://www.vix.com''. To learn more about Nominum, Inc., see
.\" ``http://www.nominum.com''.
.\"
-.\" $Id: dhcpd.conf.5,v 1.88 2007/09/17 10:13:07 shane Exp $
+.\" $Id: dhcpd.conf.5,v 1.89 2007/10/27 19:15:36 each Exp $
.\"
.TH dhcpd.conf 5
.SH NAME
should be the name of the DHCP server's lease file. By default, this
is DBDIR/dhcpd.leases. This statement \fBmust\fR appear in the outer
scope of the configuration file - if it appears in some other scope,
-it will have no effect.
+it will have no effect. Furthermore, it has no effect if overridden
+by the
+.B -lf
+flag or the
+.B PATH_DHCPD_DB
+environment variable.
+.RE
+.PP
+The
+.I dhcpv6-lease-file-name
+statement
+.RS 0.25i
+.PP
+.B dhcpv6-lease-file-name \fIname\fB;\fR
+.PP
+.I Name
+is the name of the lease file to use if and only if the server is running
+in DHCPv6 mode. By default, this is DBDIR/dhcpd6.leases. This statement,
+like
+.I lease-file-name,
+\fBmust\fR appear in the outer scope of the configuration file. It
+has no effect if overridden by the
+.B -lf
+flag or the
+.B PATH_DHCPD6_DB
+environment variable. If
+.I dhcpv6-lease-file-name
+is not specified, but
+.I lease-file-name
+is, the latter value will be used.
.RE
.PP
The
should be the name of the DHCP server's process ID file. This is the
file in which the DHCP server's process ID is stored when the server
starts. By default, this is RUNDIR/dhcpd.pid. Like the
-lease-file-name statement, this statement must appear in the outer scope
-of the configuration file.
+.I lease-file-name
+statement, this statement must appear in the outer scope
+of the configuration file. It has no effect if overridden by the
+.B -pf
+flag or the
+.B PATH_DHCPD_PID
+environment variable.
+.PP
+The
+.I dhcpv6-pid-file-name
+statement
+.RS 0.25i
+.PP
+.B dhcpv6-pid-file-name \fIname\fB;\fR
+.PP
+.I Name
+is the name of the pid file to use if and only if the server is running
+in DHCPv6 mode. By default, this is DBDIR/dhcpd6.pid. This statement,
+like
+.I pid-file-name,
+\fBmust\fR appear in the outer scope of the configuration file. It
+has no effect if overridden by the
+.B -pf
+flag or the
+.B PATH_DHCPD6_PID
+environment variable. If
+.I dhcpv6-pid-file-name
+is not specified, but
+.I pid-file-name
+is, the latter value will be used.
.RE
.PP
The
{ "do-reverse-updates", "f", &server_universe, 51, 1 },
{ "fqdn-reply", "f", &server_universe, 52, 1 },
{ "preferred-lifetime", "T", &server_universe, 53, 1 },
+ { "dhcpv6-lease-file-name", "t", &server_universe, 54, 1 },
+ { "dhcpv6-pid-file-name", "t", &server_universe, 55, 1 },
{ NULL, NULL, NULL, 0, 0 }
};