summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-03-02 20:32:06 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-03-02 20:32:06 +0000
commit0e65599226cd7239a161c1620c96efa27caa4b5b (patch)
tree91554dc460c3d1723e1b90479e239e0dad665d55 /libexec
parent852973698263dc64fb39a8b72c2b5f943a0b61f5 (diff)
knf
Diffstat (limited to 'libexec')
-rw-r--r--libexec/spamd/sdl.c6
-rw-r--r--libexec/spamd/spamd-setup.838
-rw-r--r--libexec/spamd/spamd.816
-rw-r--r--libexec/spamd/spamd.c170
4 files changed, 114 insertions, 116 deletions
diff --git a/libexec/spamd/sdl.c b/libexec/spamd/sdl.c
index 811aa320be7..70fb5795920 100644
--- a/libexec/spamd/sdl.c
+++ b/libexec/spamd/sdl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdl.c,v 1.1 2003/03/02 19:22:00 beck Exp $ */
+/* $OpenBSD: sdl.c,v 1.2 2003/03/02 20:32:05 deraadt Exp $ */
/*
* Copyright (c) 2003 Bob Beck. All rights reserved.
*
@@ -104,7 +104,7 @@ sdl_add (char *sdname, char *sdstring, char ** addrs, int addrc)
m = &blacklists[index].addrs[i].sdm;
j = sscanf(addrs[i], "%39[^/]/%u", astring, &maskbits);
- if (j != 2)
+ if (j != 2)
goto parse_error;
if (maskbits > 128)
goto parse_error;
@@ -132,7 +132,7 @@ sdl_add (char *sdname, char *sdstring, char ** addrs, int addrc)
while (maskbits >= 32) {
m->addr32[k++] = 0xffffffff;
maskbits -= 32;
- }
+ }
for (j = 31; j > 31 - maskbits; --j)
m->addr32[k] |= (1 << j);
if (maskbits)
diff --git a/libexec/spamd/spamd-setup.8 b/libexec/spamd/spamd-setup.8
index 9265961d02c..042c10f7c49 100644
--- a/libexec/spamd/spamd-setup.8
+++ b/libexec/spamd/spamd-setup.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: spamd-setup.8,v 1.4 2003/03/02 19:22:00 beck Exp $
+.\" $OpenBSD: spamd-setup.8,v 1.5 2003/03/02 20:32:05 deraadt Exp $
.\"
.\" Copyright (c) 2003 Jason L. Wright (jason@thought.net)
.\" All rights reserved.
@@ -43,25 +43,25 @@
.Op Fl 2
.Op Fl f Ar file
.Op Fl w Ar file
-.Op Ar file ...
+.Op Ar file ...
.Sh DESCRIPTION
The
.Nm
-utility adds blacklists by adding addresses to the
+utility adds blacklists by adding addresses to the
.Xr pf 4
table
.Aq spamd ,
as well as configuring mail rejection messages for
-the added list of addresses in
+the added list of addresses in
.Xr spamd 8 .
The
.Aq spamd
table is used in conjuction with a
.Xr pf 4
redirection rule can be used to selectively redirect mail connections
-to the
+to the
.Xr spamd 8 .
-daemon .
+daemon .
Sources and actions are as follows:
.Bl -tag -width XXXXXXXXXX
.It Fl s
@@ -75,20 +75,20 @@ Synonym for
.It Fl 2
The SPEWS level 2 database is fetched via
.Xr ftp 1
-and used in a blacklist named
+and used in a blacklist named
.Li spews-2
.It Fl c
-The chinese netblock datbase is fetched via
+The chinese netblock datbase is fetched via
.Xr ftp 1
-and used in a blacklist named
+and used in a blacklist named
.Li china
.It Fl k
-The korean netblock database is fetched via
+The korean netblock database is fetched via
.Xr ftp 1
-and used in a blacklist named
+and used in a blacklist named
.Li korea
.It Fl f Ar file
-The local file specified is used in a black-list named
+The local file specified is used in a black-list named
.Li local
.It Fl w Ar file
The local file specified is added to the white-list.
@@ -102,7 +102,7 @@ Then, all of the addresses from the white-list are removed.
Then, the blacklist address, are sent to a running
.Xr spamd 8
along with the message spamd will give on mail rejection when
-a matching client connects.
+a matching client connects.
The input file is expected to consist of one network block or address
per line (optionally followed by a space and text that is ignored).
Comment lines beginning with
@@ -124,7 +124,7 @@ the following example:
additional files given as parameters to
.Nm
will be read to configure blacklists. The blacklist file format is
-as follows.
+as follows.
.Bd -literal -offset indent
.Ic SPAMD_SOURCE;mylist;"Sorry %A, You are a probably spammer\enBye\en"
.Ic file:/usr/local/share/spammers.txt
@@ -145,15 +145,15 @@ given to any connections that match this list. the message must
be enclosed in double quotes
and may include \en to produce a newline in the output. \e\" will produce
a double quote in the output, and %% will produce a single % in the output.
-%A will be expanded by
+%A will be expanded by
.Xr spamd 8
to display the connecting IP address in the output.
.Pp
-Following the
+Following the
.Li SPAMD_SOURCE
-should be URL's, one per line, from which to fetch the
-network blocks to blacklist.
-Following the
+should be URL's, one per line, from which to fetch the
+network blocks to blacklist.
+Following the
.Li SPAMD_SOURCE_REMOVE
line may be further URL's, one per line, from which to
fetch network blocks that will be removed from this blacklist.
diff --git a/libexec/spamd/spamd.8 b/libexec/spamd/spamd.8
index 9eea8d0e559..85451af3e45 100644
--- a/libexec/spamd/spamd.8
+++ b/libexec/spamd/spamd.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: spamd.8,v 1.12 2003/03/02 19:22:00 beck Exp $
+.\" $OpenBSD: spamd.8,v 1.13 2003/03/02 20:32:05 deraadt Exp $
.\"
.\" Copyright (c) 2002 Theo de Raadt. All rights reserved.
.\"
@@ -106,13 +106,13 @@ The rules can be loaded into an
.Em table
to simplify handling.
.Bd -literal
- table <spamd>
+ table <spamd>
rdr proto tcp from { <spamd> } to any port smtp -> 127.0.0.1 port 8025
.Ed
.Pp
Any addresses in table
.Aq spamd
-are then redirected to
+are then redirected to
.Nm
running on port 25.
Addresses can then be can be loaded into the
@@ -125,7 +125,7 @@ like:
.Xr spamd-setup 8
can also be used to load addresses into the
.Aq spamd
-table.
+table.
.Xr spamd-setup 8
also has the added benefit of being able to remove addresses from
blacklists, and will connect to
@@ -133,12 +133,12 @@ blacklists, and will connect to
over a localhost socket, giving
.Nm
information about each source of blacklist addresses, as well as custom
-rejection messages for each blacklist source
+rejection messages for each blacklist source
that can be used to let any real person whose mail
is deferred by spamd know why their address has been listed
from sending mail. This is important as it allows legitimate mail
senders to pressure spam sources into behaving properly so that they
-may be removed from the relevant blacklists.
+may be removed from the relevant blacklists.
.Pp
.Sh CONFIGURATION CONNECTIONS
.Nm
@@ -158,9 +158,9 @@ be used to produce a single % in the output, \e\e will produce a
single \e.
.Nm
will reject mail by displaying all the messages from all blacklists in which
-a connecting address is matched.
+a connecting address is matched.
.Xr spamd-setup 8
-is normally used to configure this informaiton.
+is normally used to configure this informaiton.
.Pp
.Sh SEE ALSO
.Xr pf.conf 5 ,
diff --git a/libexec/spamd/spamd.c b/libexec/spamd/spamd.c
index 245ec334438..5c9581de40a 100644
--- a/libexec/spamd/spamd.c
+++ b/libexec/spamd/spamd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spamd.c,v 1.11 2003/03/02 19:22:00 beck Exp $ */
+/* $OpenBSD: spamd.c,v 1.12 2003/03/02 20:32:05 deraadt Exp $ */
/*
* Copyright (c) 2002 Theo de Raadt. All rights reserved.
@@ -53,7 +53,7 @@ extern struct sdlist *blacklists;
int conffd = -1;
char *cb;
-size_t cbs, cbu;
+size_t cbs, cbu;
time_t t;
@@ -120,81 +120,82 @@ grow_obuf(struct con *cp, int off)
int
parse_configline(char *line)
{
- char *cp, prev, *name, *msg;
- static char **av = NULL;
- static size_t ac = 0;
- size_t au = 0;
- int mdone = 0;
-
- if (debug)
- printf("read config line %40s ...\n", line);
-
- name = line;
-
- for (cp = name; *cp != ';'; cp++);
- *cp++ = '\0';
- msg = cp;
- if (*cp++ != '"')
- goto parse_error;
- prev = '\0';
- for (;!mdone;cp++) {
- switch (*cp) {
- case '\\':
+ char *cp, prev, *name, *msg;
+ static char **av = NULL;
+ static size_t ac = 0;
+ size_t au = 0;
+ int mdone = 0;
+
+ if (debug)
+ printf("read config line %40s ...\n", line);
+
+ name = line;
+
+ for (cp = name; *cp != ';'; cp++)
+ ;
+ *cp++ = '\0';
+ msg = cp;
+ if (*cp++ != '"')
+ goto parse_error;
+ prev = '\0';
+ for (; !mdone; cp++) {
+ switch (*cp) {
+ case '\\':
if (!prev)
prev = *cp;
- else
+ else
prev = '\0';
break;
- case '"':
- if (prev != '\\') {
- cp++;
- if (*cp == ';') {
- mdone = 1;
- *cp = '\0';
- } else
- goto parse_error;
- }
+ case '"':
+ if (prev != '\\') {
+ cp++;
+ if (*cp == ';') {
+ mdone = 1;
+ *cp = '\0';
+ } else
+ goto parse_error;
+ }
break;
- case '\0':
- goto parse_error;
- default:
- prev = '\0';
- }
-
- }
-
- do {
- if (ac == au) {
- char **tmp;
- tmp = realloc(av, (ac + 2048) * sizeof(char *));
- if (tmp == NULL) {
- return (-1);
- }
- av = tmp;
- ac += 2048;
- }
- } while ((av[au++] = strsep(&cp, ";")) != NULL);
- if (au < 2)
- goto parse_error;
- else
- sdl_add(name, msg, av, au - 1);
- return(0);
+ case '\0':
+ goto parse_error;
+ default:
+ prev = '\0';
+ }
+ }
- parse_error:
- if (debug > 0)
- printf("bogus config line - need 'tag;message;a/m;a/m;a/m...'\n");
- return (-1);
+ do {
+ if (ac == au) {
+ char **tmp;
-}
+ tmp = realloc(av, (ac + 2048) * sizeof(char *));
+ if (tmp == NULL)
+ return (-1);
+ av = tmp;
+ ac += 2048;
+ }
+ } while ((av[au++] = strsep(&cp, ";")) != NULL);
+
+ if (au < 2)
+ goto parse_error;
+ else
+ sdl_add(name, msg, av, au - 1);
+ return(0);
+ parse_error:
+ if (debug > 0)
+ printf("bogus config line - need 'tag;message;a/m;a/m;a/m...'\n");
+ return (-1);
+}
void
-parse_configs(void) {
+parse_configs(void)
+{
int i;
char *start, *end;
- if (cbu == cbs) {
- char * tmp;
+ if (cbu == cbs) {
+ char *tmp;
+
tmp = realloc(cb, cbs + 8192);
if (tmp == NULL) {
if (debug > 0)
@@ -216,15 +217,13 @@ parse_configs(void) {
if (end > start + 1)
parse_configline(start);
start = ++end;
- }
- else
+ } else
++end;
}
if (end > start + 1)
parse_configline(start);
}
-
void
do_config(void)
{
@@ -233,8 +232,9 @@ do_config(void)
if (debug > 0)
printf("got configuration connection\n");
- if (cbu == cbs) {
- char * tmp;
+ if (cbu == cbs) {
+ char *tmp;
+
tmp = realloc(cb, cbs + 8192);
if (tmp == NULL) {
if (debug > 0)
@@ -249,7 +249,7 @@ do_config(void)
n = read(conffd, cb+cbu, cbs-cbu);
if (debug > 0)
- printf("read %d config bytes\n", n);
+ printf("read %d config bytes\n", n);
if (n == 0) {
parse_configs();
goto configdone;
@@ -257,10 +257,10 @@ do_config(void)
if (debug > 0)
perror("read()");
goto configdone;
- } else {
- cbu += n;
- }
+ } else
+ cbu += n;
return;
+
configdone:
cbu = 0;
close(conffd);
@@ -278,9 +278,9 @@ append_error_string (struct con *cp, size_t off, char *fmt, int af, void *ia)
size_t len = cp->osize - off;
int i = 0;
- if (off == 0) {
+ if (off == 0)
lastcont = 0;
- }
+
if (lastcont != 0)
cp->obuf[lastcont] = '-';
i += snprintf(c, len, "%s ", nreply);
@@ -288,8 +288,9 @@ append_error_string (struct con *cp, size_t off, char *fmt, int af, void *ia)
if (*s == '"')
s++;
while (*s) {
- /* make sure we at minimum, have room to add a
- * format code (4 bytes), and a v6 address(39 bytes)
+ /*
+ * Make sure we at minimum, have room to add a
+ * format code (4 bytes), and a v6 address(39 bytes)
* and a byte saved in sav.
*/
if (i >= len - 46) {
@@ -344,7 +345,7 @@ append_error_string (struct con *cp, size_t off, char *fmt, int af, void *ia)
if (sav)
c[i++] = sav;
c[i++] = *s;
- sav='\0';
+ sav='\0';
c[i] = '\0';
break;
}
@@ -386,7 +387,7 @@ build_reply(struct con * cp)
off += used;
left -= used;
if (cp->obuf[off - 1] != '\n') {
- if ( left < 1) {
+ if (left < 1) {
c = grow_obuf(cp, off);
if (c == NULL) {
if (cp->osize)
@@ -412,9 +413,8 @@ bad:
/* we're having a really bad day.. */
cp->obufalloc = 0; /* know not to free or mangle */
cp->obuf="450 Try again\r\n";
- } else {
+ } else
cp->osize = strlen(cp->obuf) + 1;
- }
}
void
@@ -423,8 +423,7 @@ doreply(struct con *cp)
if (reply) {
if (!cp->obufalloc)
err(1, "shouldn't happen");
- snprintf(cp->obuf, cp->osize,
- "%s %s\n", nreply, reply);
+ snprintf(cp->obuf, cp->osize, "%s %s\n", nreply, reply);
return;
}
build_reply(cp);
@@ -490,7 +489,7 @@ closecon(struct con *cp)
if (cp->osize > 0 && cp->obufalloc) {
free(cp->obuf);
cp->obuf = NULL;
- cp->osize = 0;
+ cp->osize = 0;
}
close(cp->fd);
clients--;
@@ -849,11 +848,10 @@ main(int argc, char *argv[])
FD_SET(s, fdsr);
/* only one active config conn at a time */
- if (conffd == -1)
+ if (conffd == -1)
FD_SET(conflisten, fdsr);
else
FD_SET(conffd, fdsr);
-
if (writers == 0) {
tvp = NULL;