diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2003-03-09 19:22:27 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2003-03-09 19:22:27 +0000 |
commit | 4405d0b19a4cf40129a42295ad626d24b9d8991e (patch) | |
tree | 5e2e4a9fe3ee1f0240b6adbac2e52968c231f441 /libexec/spamd-setup | |
parent | 639fb7626d3306f86850a074d8b53cf57a307e19 (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-setup')
-rw-r--r-- | libexec/spamd-setup/spamd-setup.8 | 10 | ||||
-rw-r--r-- | libexec/spamd-setup/spamd-setup.c | 24 |
2 files changed, 23 insertions, 11 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; |