summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/services4
-rw-r--r--etc/spamd.conf10
-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
6 files changed, 61 insertions, 25 deletions
diff --git a/etc/services b/etc/services
index 05f485abd84..aef55858a15 100644
--- a/etc/services
+++ b/etc/services
@@ -1,4 +1,4 @@
-# $OpenBSD: services,v 1.49 2003/01/24 06:43:29 millert Exp $
+# $OpenBSD: services,v 1.50 2003/03/09 19:22:25 beck Exp $
#
# Network services, Internet style
#
@@ -250,6 +250,8 @@ mysql 3306/tcp # MySQL
postgresql 5432/tcp # PostgreSQL
canna 5680/tcp # Kana->Kanji server
icb 7326/tcp # Internet Citizen's Band
+spamd 8025/tcp # spamd(8)
+spamd-cfg 8026/tcp # spamd(8) configuration
hunt 26740/udp # hunt(6)
#
# Appletalk
diff --git a/etc/spamd.conf b/etc/spamd.conf
index 4b6588ecd68..16d5f34d7e7 100644
--- a/etc/spamd.conf
+++ b/etc/spamd.conf
@@ -1,6 +1,8 @@
-# $OpenBSD: spamd.conf,v 1.2 2003/03/08 21:39:50 deraadt Exp $
+# $OpenBSD: spamd.conf,v 1.3 2003/03/09 19:22:25 beck Exp $
#
-# spamd config file, read by spamd.conf(5) and spamd-setup(8)
+# spamd config file, read by spamd-setup(8) for spamd(8)
+#
+# See spamd.conf(5)
#
# Configures whitelists and blacklists for spamd
#
@@ -31,14 +33,14 @@ spews2:\
china:\
:black:\
- :msg="SPAM. Your address %A appears to be from china\n\
+ :msg="SPAM. Your address %A appears to be from China\n\
See http://www.okean.com/asianspamblocks.html for more details":\
:method=http:\
:file=www.okean.com/chinacidr.txt:
korea:\
:black:\
- :msg="SPAM. Your address %A appears to be from korea\n\
+ :msg="SPAM. Your address %A appears to be from Korea\n\
See http://www.okean.com/asianspamblocks.html for more details":\
:method=http:\
:file=www.okean.com/koreacidr.txt:
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");