diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2009-04-20 17:42:22 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2009-04-20 17:42:22 +0000 |
commit | 9590e221dea9f02970fb68ad6a509c908645947a (patch) | |
tree | 7bd5f307424e2a84d564d1659159597157c4e561 /libexec | |
parent | 214f2446612824e04d9e824aaa841c2cf89a71f9 (diff) |
PR 6090 - from Olli Hauer <ohauer@gmx.de>
A number of small improvements:
- patch for empty lines and comments in alloweddomains_file
- remove some whitespaces at end of line.
- document comment and empty line handling
- Remove unused parameter 'r' from getopt in spamd.c, it is removed in the 'switch statement'
but not in getopt.
http://www.openbsd.org/cgi-bin/cvsweb/src/libexec/spamd/spamd.c.diff?r1=1.94;r2=1.95;f=h
- replace atoi with strtonum
- make debug output more usefull, display only what will be synced and not a second
message which prints always "sync trapped %s"
- some cosemtic and whitespace fixes.
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/spamd/grey.c | 21 | ||||
-rw-r--r-- | libexec/spamd/spamd.8 | 8 | ||||
-rw-r--r-- | libexec/spamd/spamd.c | 8 | ||||
-rw-r--r-- | libexec/spamd/sync.c | 9 |
4 files changed, 29 insertions, 17 deletions
diff --git a/libexec/spamd/grey.c b/libexec/spamd/grey.c index 88dc8f8571e..d46af4bb4b5 100644 --- a/libexec/spamd/grey.c +++ b/libexec/spamd/grey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grey.c,v 1.46 2009/02/25 19:00:36 beck Exp $ */ +/* $OpenBSD: grey.c,v 1.47 2009/04/20 17:42:21 beck Exp $ */ /* * Copyright (c) 2004-2006 Bob Beck. All rights reserved. @@ -316,12 +316,24 @@ readsuffixlists(void) struct mail_addr *m; while (!SLIST_EMPTY(&match_suffix)) { - m = SLIST_FIRST(&match_suffix); + m = SLIST_FIRST(&match_suffix); SLIST_REMOVE_HEAD(&match_suffix, entry); free(m); } if ((fp = fopen(alloweddomains_file, "r")) != NULL) { while ((buf = fgetln(fp, &len))) { + /* strip white space-characters */ + while (len > 0 && isspace(buf[len-1])) + len--; + while (len > 0 && isspace(*buf)) { + buf++; + len--; + } + if (len == 0) + continue; + /* jump over comments and blank lines */ + if (*buf == '#' || *buf == '\n') + continue; if (buf[len-1] == '\n') len--; if ((m = malloc(sizeof(struct mail_addr))) == NULL) @@ -533,8 +545,7 @@ db_notin(DB *db, char *key) memset(&dbk, 0, sizeof(dbk)); dbk.size = strlen(key); dbk.data = key; - memset(&dbd, 0, - sizeof(dbd)); + memset(&dbd, 0, sizeof(dbd)); i = db->get(db, &dbk, &dbd, 0); if (i == -1) return (-1); @@ -838,7 +849,7 @@ greyupdate(char *dbname, char *helo, char *ip, char *from, char *to, int sync, if (sync && low_prio_mx_ip && (strcmp(cip, low_prio_mx_ip) == 0) && ((startup + 60) < now)) { - /* we haven't seen a greylist entry for this tuple, + /* we haven't seen a greylist entry for this tuple, * and yet the connection was to a low priority MX * which we know can't be hit first if the client * is adhering to the RFC's - soo.. kill it! diff --git a/libexec/spamd/spamd.8 b/libexec/spamd/spamd.8 index f38e5c90bd5..1c6baf525fa 100644 --- a/libexec/spamd/spamd.8 +++ b/libexec/spamd/spamd.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: spamd.8,v 1.112 2009/02/17 22:07:11 jmc Exp $ +.\" $OpenBSD: spamd.8,v 1.113 2009/04/20 17:42:21 beck Exp $ .\" .\" Copyright (c) 2002 Theo de Raadt. All rights reserved. .\" @@ -22,7 +22,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: February 17 2009 $ +.Dd $Mdocdate: April 20 2009 $ .Dt SPAMD 8 .Os .Sh NAME @@ -397,6 +397,10 @@ which must match each destination email address in the greylist. Any destination address which does not match one of the suffixes listed in .Pa spamd.alloweddomains will be trapped, exactly as if it were sent to a spamtrap address. +Comment lines beginning with +.Ar # +and empty lines are ignored. + .Pp For example, if .Pa spamd.alloweddomains diff --git a/libexec/spamd/spamd.c b/libexec/spamd/spamd.c index 2e0670a7e68..2432cdc5810 100644 --- a/libexec/spamd/spamd.c +++ b/libexec/spamd/spamd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spamd.c,v 1.104 2008/07/11 15:05:59 reyk Exp $ */ +/* $OpenBSD: spamd.c,v 1.105 2009/04/20 17:42:21 beck Exp $ */ /* * Copyright (c) 2002-2007 Bob Beck. All rights reserved. @@ -1063,7 +1063,7 @@ main(int argc, char *argv[]) if (maxblack > maxfiles) maxblack = maxfiles; while ((ch = - getopt(argc, argv, "45l:c:B:p:bdG:h:r:s:S:M:n:vw:y:Y:")) != -1) { + getopt(argc, argv, "45l:c:B:p:bdG:h:s:S:M:n:vw:y:Y:")) != -1) { switch (ch) { case '4': nreply = "450"; @@ -1116,8 +1116,8 @@ main(int argc, char *argv[]) errx(1, "-h arg too long"); break; case 's': - i = atoi(optarg); - if (i < 0 || i > 10) + i = strtonum(optarg, 0, 10, &errstr); + if (errstr) usage(); stutter = i; break; diff --git a/libexec/spamd/sync.c b/libexec/spamd/sync.c index 2087bba98e2..98b87361df7 100644 --- a/libexec/spamd/sync.c +++ b/libexec/spamd/sync.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sync.c,v 1.7 2008/05/22 19:54:11 deraadt Exp $ */ +/* $OpenBSD: sync.c,v 1.8 2009/04/20 17:42:21 beck Exp $ */ /* * Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -523,7 +523,8 @@ sync_addr(time_t now, time_t expire, char *ip, u_int16_t type) u_int hmac_len; if (debug) - fprintf(stderr, "sync trapped %s\n", ip); + fprintf(stderr, "sync %s %s\n", + type == SPAM_SYNC_WHITE ? "white" : "trapped", ip); bzero(&hdr, sizeof(hdr)); bzero(&sd, sizeof(sd)); @@ -570,15 +571,11 @@ sync_addr(time_t now, time_t expire, char *ip, u_int16_t type) void sync_white(time_t now, time_t expire, char *ip) { - if (debug) - fprintf(stderr, "sync white address %s\n", ip); sync_addr(now, expire, ip, SPAM_SYNC_WHITE); } void sync_trapped(time_t now, time_t expire, char *ip) { - if (debug) - fprintf(stderr, "sync trapped address %s\n", ip); sync_addr(now, expire, ip, SPAM_SYNC_TRAPPED); } |