summaryrefslogtreecommitdiff
path: root/libexec
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
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')
-rw-r--r--libexec/spamd-setup/spamd-setup.810
-rw-r--r--libexec/spamd-setup/spamd-setup.c24
-rw-r--r--libexec/spamd/spamd.820
-rw-r--r--libexec/spamd/spamd.c18
4 files changed, 52 insertions, 20 deletions
diff --git a/libexec/spamd-setup/spamd-setup.8 b/libexec/spamd-setup/spamd-setup.8
index caad3085f8a..4bf43a0394a 100644
--- a/libexec/spamd-setup/spamd-setup.8
+++ b/libexec/spamd-setup/spamd-setup.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: spamd-setup.8,v 1.3 2003/03/08 21:36:12 jmc Exp $
+.\" $OpenBSD: spamd-setup.8,v 1.4 2003/03/09 19:22:26 beck Exp $
.\"
.\" Copyright (c) 2003 Jason L. Wright (jason@thought.net)
.\" All rights reserved.
@@ -66,7 +66,12 @@ Output is concatenated to build up a table for
Then the blacklist addresses are sent to a running
.Xr spamd 8
along with the message spamd will give on mail rejection when a
-matching client connects.
+matching client connects. The configuration port for
+.Xr spamd 8
+is found from
+.Xr services 5 ,
+by looking for the named service
+.Em spamd-cfg .
.Pp
.Nm
reads all configuration information from a
@@ -79,5 +84,6 @@ file.
.Sh SEE ALSO
.Xr ftp 1 ,
.Xr pf 4 ,
+.Xr services 5 ,
.Xr spamd.conf 5 ,
.Xr spamd 8
diff --git a/libexec/spamd-setup/spamd-setup.c b/libexec/spamd-setup/spamd-setup.c
index 7a171e6fb3a..9a1e5b60e4a 100644
--- a/libexec/spamd-setup/spamd-setup.c
+++ b/libexec/spamd-setup/spamd-setup.c
@@ -1,13 +1,13 @@
-/* $OpenBSD: spamd-setup.c,v 1.4 2003/03/09 02:50:54 beck Exp $ */
+/* $OpenBSD: spamd-setup.c,v 1.5 2003/03/09 19:22:26 beck Exp $ */
/*
* Copyright (c) 2003 Bob Beck. All rights reserved.
*
- * Redistribution and use in source and binary forms, with or withou
+ * 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 copyrigh
+ * 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 copyrigh
+ * 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.
*
@@ -15,10 +15,10 @@
* 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, BU
+ * 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 TOR
+ * 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.
*/
@@ -35,12 +35,13 @@
#include <unistd.h>
#include <err.h>
#include <netinet/ip_ipsp.h>
+#include <netdb.h>
+#include <machine/endian.h>
#define PATH_FTP "/usr/bin/ftp"
#define PATH_PFCTL "/sbin/pfctl"
#define PATH_SPAMD_CONF "/etc/spamd.conf"
#define SPAMD_ARG_MAX 256 /* max # of args to an exec */
-#define SPAMD_CONFIG_PORT 8026
struct cidr {
u_int32_t addr;
@@ -712,6 +713,11 @@ main(int argc, char *argv[])
char **db_array, *buf;
char *name;
int i;
+ struct servent *ent;
+
+ if ((ent = getservbyname("spamd-cfg", "tcp")) == NULL)
+ errx(1, "Can't find service \"spamd-cfg\" in /etc/services");
+ ent->s_port = ntohs(ent->s_port);
dbs = argc + 2;
dbc = 0;
@@ -758,10 +764,10 @@ main(int argc, char *argv[])
cidrs = collapse_blacklist(blists[i].bl, blists[i].blc);
if (cidrs == NULL)
errx(1, "Malloc failed");
- if (configure_spamd(SPAMD_CONFIG_PORT, blists[i].name,
+ if (configure_spamd(ent->s_port, blists[i].name,
blists[i].message, cidrs) == -1)
err(1, "Can't connect to spamd on port %d",
- SPAMD_CONFIG_PORT);
+ ent->s_port);
if (configure_pf(cidrs) == -1)
err(1, "pfctl failed");
tmp = cidrs;
diff --git a/libexec/spamd/spamd.8 b/libexec/spamd/spamd.8
index 48b3ebce676..1587646992f 100644
--- a/libexec/spamd/spamd.8
+++ b/libexec/spamd/spamd.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: spamd.8,v 1.24 2003/03/08 22:03:53 beck Exp $
+.\" $OpenBSD: spamd.8,v 1.25 2003/03/09 19:22:25 beck Exp $
.\"
.\" Copyright (c) 2002 Theo de Raadt. All rights reserved.
.\"
@@ -64,9 +64,13 @@ This defaults to 450.
.It Fl c
The maximum number of concurrent connections to allow.
.It Fl p
-Specify a different port number from the default of 8025 that
+Specify a different port number from the default port that
.Nm
-should listen for redirected SMTP connections on.
+should listen for redirected SMTP connections on. The default port is found
+by looking for the named service
+.Em spamd
+using
+.Xr getservbyname 5 .
.It Fl n
The SMTP version banner that is reported upon initial connection.
.El
@@ -143,9 +147,12 @@ may be removed from the relevant blacklists.
.Pp
.Sh CONFIGURATION CONNECTIONS
.Nm
-listens for configuration connections one port above the one on which
-it listens for redirected SMTP connections, The default is port
-8026. The configuration socket listens only on on the INADDR_LOOPBACK
+listens for configuration connections on the port identified by the
+named service
+.Em spamd-cfg
+(see
+.Xr services 5 ).
+The configuration socket listens only on on the INADDR_LOOPBACK
address. Configuration of spamd is done by connecting to the
configuration socket, and sending blacklist information, one blacklist
per line. Each blacklist consists of a name, a message to reject mail
@@ -170,6 +177,7 @@ is normally used to configure this information.
.Pp
.Sh SEE ALSO
.Xr pf.conf 5 ,
+.Xr services 5 ,
.Xr spamd.conf 5 ,
.Xr pfctl 8 ,
.Xr spamd-setup 8
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");