summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2008-05-25 22:36:17 +0000
committermillert <millert@openbsd.org>2008-05-25 22:36:17 +0000
commit5382abf832d51a85bd891fefe311af18cbfa3d4a (patch)
tree676b6d9dcbeb28e3222bd3f6de2f433d6e11b93c
parentFix breakage introduced in rev 1.8 wrt rdisting symlinks. Push the (diff)
downloadwireguard-openbsd-5382abf832d51a85bd891fefe311af18cbfa3d4a.tar.xz
wireguard-openbsd-5382abf832d51a85bd891fefe311af18cbfa3d4a.zip
Don't error out if dhcpd-sync does not exist in /etc/services and no
sync options were specified. OK deraadt@
-rw-r--r--usr.sbin/dhcpd/dhcpd.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/usr.sbin/dhcpd/dhcpd.c b/usr.sbin/dhcpd/dhcpd.c
index 79f2f514776..a8bbc39f92f 100644
--- a/usr.sbin/dhcpd/dhcpd.c
+++ b/usr.sbin/dhcpd/dhcpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpd.c,v 1.36 2008/05/08 07:28:08 beck Exp $ */
+/* $OpenBSD: dhcpd.c,v 1.37 2008/05/25 22:36:17 millert Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@cvs.openbsd.org>
@@ -61,7 +61,6 @@ int gotpipe = 0;
int syncrecv;
int syncsend;
pid_t pfproc_pid = -1;
-u_short sync_port;
char *path_dhcpd_conf = _PATH_DHCPD_CONF;
char *path_dhcpd_db = _PATH_DHCPD_DB;
char *abandoned_tab = NULL;
@@ -76,15 +75,30 @@ main(int argc, char *argv[])
extern char *__progname;
char *sync_iface = NULL;
char *sync_baddr = NULL;
+ u_short sync_port;
struct servent *ent;
/* Initially, log errors to stderr as well as to syslogd. */
openlog_r(__progname, LOG_PID | LOG_NDELAY, DHCPD_LOG_FACILITY, &sdata);
- if ((ent = getservbyname("dhcpd-sync", "udp")) == NULL)
- errx(1, "Can't find service \"dhcpd-sync\" in /etc/services");
- sync_port = ntohs(ent->s_port);
+ opterr = 0;
+ while ((ch = getopt(argc, argv, "Y:y:")) != -1)
+ switch (ch) {
+ case 'Y':
+ syncsend = 1;
+ break;
+ case 'y':
+ syncrecv = 1;
+ break;
+ }
+ if (syncsend || syncrecv) {
+ if ((ent = getservbyname("dhcpd-sync", "udp")) == NULL)
+ errx(1, "Can't find service \"dhcpd-sync\" in "
+ "/etc/services");
+ sync_port = ntohs(ent->s_port);
+ }
+ optreset = optind = opterr = 1;
while ((ch = getopt(argc, argv, "A:C:L:c:dfl:nY:y:")) != -1)
switch (ch) {
case 'A':
@@ -117,11 +131,11 @@ main(int argc, char *argv[])
case 'Y':
if (sync_addhost(optarg, sync_port) != 0)
sync_iface = optarg;
- syncsend++;
+ syncsend = 1;
break;
case 'y':
sync_baddr = optarg;
- syncrecv++;
+ syncrecv = 1;
break;
default:
usage();