diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2004-03-10 00:32:55 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2004-03-10 00:32:55 +0000 |
commit | dbba56e4a3fed136af84cf1dc610d3299c62ebf2 (patch) | |
tree | b39407941e46bee35d3e7c5dc390a4bb245713c6 /libexec | |
parent | 920f2a982554cc17e283313419dbfbe6f39510a6 (diff) |
add -b option to specify local bind address, sent by
yongari@kt-is.co.kr
ok deraadt@
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/spamd/spamd.8 | 11 | ||||
-rw-r--r-- | libexec/spamd/spamd.c | 22 |
2 files changed, 26 insertions, 7 deletions
diff --git a/libexec/spamd/spamd.8 b/libexec/spamd/spamd.8 index 8f77c8c625d..fae78cd88b5 100644 --- a/libexec/spamd/spamd.8 +++ b/libexec/spamd/spamd.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: spamd.8,v 1.44 2004/03/01 18:17:42 xsa Exp $ +.\" $OpenBSD: spamd.8,v 1.45 2004/03/10 00:32:54 beck Exp $ .\" .\" Copyright (c) 2002 Theo de Raadt. All rights reserved. .\" @@ -32,6 +32,7 @@ .Nm spamd .Bk -words .Op Fl 45dgv +.Op Fl b Ar address .Op Fl c Ar maxcon .Op Fl G Ar passtime:greyexp:whiteexp .Op Fl n Ar name @@ -56,6 +57,14 @@ The options are as follows: Return error code 450 to the spammer (default). .It Fl 5 Return error code 550 to the spammer. +.It Fl b Ar address +Specify the local address to which +.Nm +is to +.Xr bind 2 . +By default +.Nm +listens on all local addresses. .It Fl c Ar maxcon The maximum number of concurrent connections to allow. The default is 800. diff --git a/libexec/spamd/spamd.c b/libexec/spamd/spamd.c index 4b8239abce1..343246a0fb4 100644 --- a/libexec/spamd/spamd.c +++ b/libexec/spamd/spamd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spamd.c,v 1.55 2004/02/28 00:03:59 beck Exp $ */ +/* $OpenBSD: spamd.c,v 1.56 2004/03/10 00:32:54 beck Exp $ */ /* * Copyright (c) 2002 Theo de Raadt. All rights reserved. @@ -135,10 +135,11 @@ void usage(void) { fprintf(stderr, - "usage: spamd [-45dgv] [-c maxcon] [-G mins:hours:hours] [-n name]" - "[-p port] [-r reply] [-s secs]\n"); + "usage: spamd [-45dgv] [-b address] [-c maxcon]\n"); fprintf(stderr, - " [-w window]\n"); + " [-G mins:hours:hours] [-n name] [-p port]\n"); + fprintf(stderr, + " [-r reply] [-s secs] [-w window]\n"); exit(1); } @@ -851,6 +852,7 @@ main(int argc, char *argv[]) struct servent *ent; struct rlimit rlp; pid_t pid; + char *bind_address = NULL; tzset(); openlog_r("spamd", LOG_PID | LOG_NDELAY, LOG_DAEMON, &sdata); @@ -865,7 +867,7 @@ main(int argc, char *argv[]) if (gethostname(hostname, sizeof hostname) == -1) err(1, "gethostname"); - while ((ch = getopt(argc, argv, "45c:p:dgG:r:s:n:vw:")) != -1) { + while ((ch = getopt(argc, argv, "45b:c:p:dgG:r:s:n:vw:")) != -1) { switch (ch) { case '4': nreply = "450"; @@ -873,6 +875,9 @@ main(int argc, char *argv[]) case '5': nreply = "550"; break; + case 'b': + bind_address = optarg; + break; case 'c': i = atoi(optarg); if (i > MAXCON) @@ -908,6 +913,7 @@ main(int argc, char *argv[]) if (i < 0 || i > 10) usage(); stutter = i; + break; case 'n': spamd = optarg; break; @@ -968,7 +974,11 @@ main(int argc, char *argv[]) memset(&sin, 0, sizeof sin); sin.sin_len = sizeof(sin); - sin.sin_addr.s_addr = htonl(INADDR_ANY); + if (bind_address) { + if (inet_pton(AF_INET, bind_address, &sin.sin_addr) != 1) + err(1, "inet_pton"); + } else + sin.sin_addr.s_addr = htonl(INADDR_ANY); sin.sin_family = AF_INET; sin.sin_port = htons(port); |