summaryrefslogtreecommitdiff
path: root/libexec/spamd/spamd.c
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2003-03-09 19:22:27 +0000
committerBob Beck <beck@cvs.openbsd.org>2003-03-09 19:22:27 +0000
commit4405d0b19a4cf40129a42295ad626d24b9d8991e (patch)
tree5e2e4a9fe3ee1f0240b6adbac2e52968c231f441 /libexec/spamd/spamd.c
parent639fb7626d3306f86850a074d8b53cf57a307e19 (diff)
Fix a few typos, Make spamd and spamd-setup use /etc/services to find
their ports. Adds "spamd" and "spamd-cfg" services to /etc/services. Mostly from Daniel Lucq <daniel@lucq.org>.
Diffstat (limited to 'libexec/spamd/spamd.c')
-rw-r--r--libexec/spamd/spamd.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/libexec/spamd/spamd.c b/libexec/spamd/spamd.c
index 6753f7a81f5..a249dcc17b0 100644
--- a/libexec/spamd/spamd.c
+++ b/libexec/spamd/spamd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spamd.c,v 1.22 2003/03/08 22:05:20 deraadt Exp $ */
+/* $OpenBSD: spamd.c,v 1.23 2003/03/09 19:22:25 beck Exp $ */
/*
* Copyright (c) 2002 Theo de Raadt. All rights reserved.
@@ -42,6 +42,10 @@
#include <syslog.h>
#include <unistd.h>
+#include <netdb.h>
+#include <sys/types.h>
+#include <machine/endian.h>
+
#include "sdl.h"
struct con {
@@ -700,11 +704,19 @@ main(int argc, char *argv[])
struct passwd *pw;
int ch, s, s2, conflisten = 0, i, omax = 0;
int sinlen, one = 1;
- u_short port = 8025;
+ u_short port, cfg_port;
+ struct servent *ent;
tzset();
openlog_r("spamd", LOG_PID | LOG_NDELAY, LOG_DAEMON, &sdata);
+ if ((ent = getservbyname("spamd", "tcp")) == NULL)
+ errx(1, "Can't find service \"spamd\" in /etc/services");
+ port = ntohs(ent->s_port);
+ if ((ent = getservbyname("spamd-cfg", "tcp")) == NULL)
+ errx(1, "Can't find service \"spamd-cff\" in /etc/services");
+ cfg_port = ntohs(ent->s_port);
+
if (gethostname(hostname, sizeof hostname) == -1)
err(1, "gethostname");
@@ -785,7 +797,7 @@ main(int argc, char *argv[])
lin.sin_len = sizeof(sin);
lin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
lin.sin_family = AF_INET;
- lin.sin_port = htons(port + 1);
+ lin.sin_port = htons(cfg_port);
if (bind(conflisten, (struct sockaddr *)&lin, sizeof lin) == -1)
err(1, "bind local");