Re: spamlogd (how to specify port?)

2007-03-19 Thread Peter
Le Lundi 19 Mars 2007 05:09, Joachim Schipper a icrit :
> On Sun, Mar 18, 2007 at 05:56:04PM -0600, Bob Beck wrote:
> > * Joachim Schipper <[EMAIL PROTECTED]> [2007-03-18 16:16]:
> > > On Sun, Mar 18, 2007 at 08:57:32PM +, Stuart Henderson wrote:
> > > > On 2007/03/18 16:35, Peter wrote:
> > > > > On OpenBSD 4.0, how do I specify what port spamlogd should consider
> > > > > SMTP?  My MTA is running on a non-standard port.
> > > >
> > > > edit /usr/src/libexec/spamlogd/spamlogd.c and recompile -
> > > > it's hardcoded "ip and port 25 ..."
> > >
> > > Would something like the following not do the trick?
> > >
> > >
> >
> > Sorry, Absolutely not. I am not putting in a knob for this
> >
> > If you're crazy enough to run an MTA on a non-standard port
> > you know enough to recompile.
>
> Hmmm... yes, you are right. Oh well, I suppose the OP can now try
> either.

Thank you.  I compiled and it seems to be working.  But I, for one, would like
that extra knob.  ;)

Pedro



Re: spamlogd (how to specify port?)

2007-03-19 Thread Joachim Schipper
On Sun, Mar 18, 2007 at 05:56:04PM -0600, Bob Beck wrote:
> 
> * Joachim Schipper <[EMAIL PROTECTED]> [2007-03-18 16:16]:
> > On Sun, Mar 18, 2007 at 08:57:32PM +, Stuart Henderson wrote:
> > > On 2007/03/18 16:35, Peter wrote:
> > > > On OpenBSD 4.0, how do I specify what port spamlogd should consider 
> > > > SMTP?  My 
> > > > MTA is running on a non-standard port.
> > > 
> > > edit /usr/src/libexec/spamlogd/spamlogd.c and recompile -
> > > it's hardcoded "ip and port 25 ..."
> > 
> > Would something like the following not do the trick?

> >
>
>   Sorry, Absolutely not. I am not putting in a knob for this
> 
>   If you're crazy enough to run an MTA on a non-standard port
> you know enough to recompile.

Hmmm... yes, you are right. Oh well, I suppose the OP can now try
either.

Joachim



Re: spamlogd (how to specify port?)

2007-03-18 Thread Bob Beck
Sorry, Absolutely not. I am not putting in a knob for this

If you're crazy enough to run an MTA on a non-standard port
you know enough to recompile.

-Bob

* Joachim Schipper <[EMAIL PROTECTED]> [2007-03-18 16:16]:
> On Sun, Mar 18, 2007 at 08:57:32PM +, Stuart Henderson wrote:
> > On 2007/03/18 16:35, Peter wrote:
> > > On OpenBSD 4.0, how do I specify what port spamlogd should consider SMTP? 
> > >  My 
> > > MTA is running on a non-standard port.
> > 
> > edit /usr/src/libexec/spamlogd/spamlogd.c and recompile -
> > it's hardcoded "ip and port 25 ..."
> 
> Would something like the following not do the trick?
> 
> (Warning to the original poster: please wait for a while for more
> clueful people to tell me I screwed up before actually trying to run
> with this diff - there is no obvious reason why it wouldn't work, but I
> didn't test it, can not claim familiarity with this code, and still have
> a lot to learn. Stuart seems to think the general idea would work,
> though.)
> 
> Another warning: this diff is against the version in my (-current)
> source tree, which is rather recent. So it might not be the newest, but
> it's certainly removed somewhat from the 4.0 spamlogd.
> 
>   Joachim
> 
> Index: spamlogd.8
> ===
> RCS file: /var/nfs/cvsync/src/libexec/spamlogd/spamlogd.8,v
> retrieving revision 1.12
> diff -u -b -B -u -r1.12 spamlogd.8
> --- spamlogd.84 Mar 2007 09:58:22 -   1.12
> +++ spamlogd.818 Mar 2007 21:23:52 -
> @@ -37,7 +37,7 @@
>  updates the
>  .Pa /var/db/spamd
>  whitelist entries whenever a connection
> -to port 25 is logged to the
> +to the specified port (port 25 by default) is logged to the
>  .Xr pflog 4
>  interface.
>  The source addresses of inbound connections are whitelisted
> @@ -77,6 +77,9 @@
>  interface to listen for connection notifications.
>  The default is to watch for connections logged on
>  .Dq pflog0 .
> +.It Fl p mailport
> +port on which incoming mail will arrive.
> +The default is to watch for connections to port 25.
>  .It Fl Y Ar synctarget
>  Add a target to receive synchronisation messages; see
>  .Sx SYNCHRONISATION
> Index: spamlogd.c
> ===
> RCS file: /var/nfs/cvsync/src/libexec/spamlogd/spamlogd.c,v
> retrieving revision 1.19
> diff -u -b -B -u -r1.19 spamlogd.c
> --- spamlogd.c5 Mar 2007 14:55:09 -   1.19
> +++ spamlogd.c18 Mar 2007 21:21:52 -
> @@ -70,6 +70,7 @@
>  u_int8_t  flag_inbound = 0;
>  char *networkif = NULL;
>  char *pflogif = "pflog0";
> +int   mailport = 25;
>  char  errbuf[PCAP_ERRBUF_SIZE];
>  pcap_t   *hpcap = NULL;
>  struct syslog_datasdata  = SYSLOG_DATA_INIT;
> @@ -109,8 +110,9 @@
>  init_pcap(void)
>  {
>   struct bpf_program  bpfp;
> - charfilter[PCAPFSIZ] = "ip and port 25 and action pass "
> - "and tcp[13]&0x12=0x2";
> + charfilter[PCAPFSIZ];
> +
> + snprintf(filter, sizeof(filter), "ip and port %d and action pass and 
> tcp[13]&0x12=0x2", mailport);
>  
>   if ((hpcap = pcap_open_live(pflogif, PCAPSNAP, 1, PCAPTIMO,
>   errbuf)) == NULL) {
> @@ -299,6 +301,7 @@
>   struct servent *ent;
>   char *sync_iface = NULL;
>   char *sync_baddr = NULL;
> + const char *errstr;
>  
>   if ((ent = getservbyname("spamd-sync", "udp")) == NULL)
>   errx(1, "Can't find service \"spamd-sync\" in /etc/services");
> @@ -317,6 +320,11 @@
>   break;
>   case 'l':
>   pflogif = optarg;
> + break;
> + case 'p':
> + mailport = strtonum(optarg, 0, 65535, &errstr);
> + if (errstr)
> + errx(1, "The mail port is %s: %s", errstr, 
> optarg);
>   break;
>   case 'Y':
>   if (sync_addhost(optarg, sync_port) != 0)
> 

-- 
#!/usr/bin/perl
if ((not 0 && not 1) !=  (! 0 && ! 1)) {
   print "Larry and Tom must smoke some really primo stuff...\n"; 
}



Re: spamlogd (how to specify port?)

2007-03-18 Thread Joachim Schipper
On Sun, Mar 18, 2007 at 08:57:32PM +, Stuart Henderson wrote:
> On 2007/03/18 16:35, Peter wrote:
> > On OpenBSD 4.0, how do I specify what port spamlogd should consider SMTP?  
> > My 
> > MTA is running on a non-standard port.
> 
> edit /usr/src/libexec/spamlogd/spamlogd.c and recompile -
> it's hardcoded "ip and port 25 ..."

Would something like the following not do the trick?

(Warning to the original poster: please wait for a while for more
clueful people to tell me I screwed up before actually trying to run
with this diff - there is no obvious reason why it wouldn't work, but I
didn't test it, can not claim familiarity with this code, and still have
a lot to learn. Stuart seems to think the general idea would work,
though.)

Another warning: this diff is against the version in my (-current)
source tree, which is rather recent. So it might not be the newest, but
it's certainly removed somewhat from the 4.0 spamlogd.

Joachim

Index: spamlogd.8
===
RCS file: /var/nfs/cvsync/src/libexec/spamlogd/spamlogd.8,v
retrieving revision 1.12
diff -u -b -B -u -r1.12 spamlogd.8
--- spamlogd.8  4 Mar 2007 09:58:22 -   1.12
+++ spamlogd.8  18 Mar 2007 21:23:52 -
@@ -37,7 +37,7 @@
 updates the
 .Pa /var/db/spamd
 whitelist entries whenever a connection
-to port 25 is logged to the
+to the specified port (port 25 by default) is logged to the
 .Xr pflog 4
 interface.
 The source addresses of inbound connections are whitelisted
@@ -77,6 +77,9 @@
 interface to listen for connection notifications.
 The default is to watch for connections logged on
 .Dq pflog0 .
+.It Fl p mailport
+port on which incoming mail will arrive.
+The default is to watch for connections to port 25.
 .It Fl Y Ar synctarget
 Add a target to receive synchronisation messages; see
 .Sx SYNCHRONISATION
Index: spamlogd.c
===
RCS file: /var/nfs/cvsync/src/libexec/spamlogd/spamlogd.c,v
retrieving revision 1.19
diff -u -b -B -u -r1.19 spamlogd.c
--- spamlogd.c  5 Mar 2007 14:55:09 -   1.19
+++ spamlogd.c  18 Mar 2007 21:21:52 -
@@ -70,6 +70,7 @@
 u_int8_tflag_inbound = 0;
 char   *networkif = NULL;
 char   *pflogif = "pflog0";
+int mailport = 25;
 charerrbuf[PCAP_ERRBUF_SIZE];
 pcap_t *hpcap = NULL;
 struct syslog_data  sdata  = SYSLOG_DATA_INIT;
@@ -109,8 +110,9 @@
 init_pcap(void)
 {
struct bpf_program  bpfp;
-   charfilter[PCAPFSIZ] = "ip and port 25 and action pass "
-   "and tcp[13]&0x12=0x2";
+   charfilter[PCAPFSIZ];
+
+   snprintf(filter, sizeof(filter), "ip and port %d and action pass and 
tcp[13]&0x12=0x2", mailport);
 
if ((hpcap = pcap_open_live(pflogif, PCAPSNAP, 1, PCAPTIMO,
errbuf)) == NULL) {
@@ -299,6 +301,7 @@
struct servent *ent;
char *sync_iface = NULL;
char *sync_baddr = NULL;
+   const char *errstr;
 
if ((ent = getservbyname("spamd-sync", "udp")) == NULL)
errx(1, "Can't find service \"spamd-sync\" in /etc/services");
@@ -317,6 +320,11 @@
break;
case 'l':
pflogif = optarg;
+   break;
+   case 'p':
+   mailport = strtonum(optarg, 0, 65535, &errstr);
+   if (errstr)
+   errx(1, "The mail port is %s: %s", errstr, 
optarg);
break;
case 'Y':
if (sync_addhost(optarg, sync_port) != 0)



Re: spamlogd (how to specify port?)

2007-03-18 Thread Peter
Le Dimanche 18 Mars 2007 16:50, Darren Spruell a icrit :
> On 3/18/07, Peter <[EMAIL PROTECTED]> wrote:
> > On OpenBSD 4.0, how do I specify what port spamlogd should consider SMTP?
> >  My MTA is running on a non-standard port.
>
> spamd sees your inbound SMTP traffic by virtue of the PF rdr rules
> that direct connections to it. Refer to those rules and adjust ports
> as needed.

I'm talking about spamlogd not spamd.

Pedro



Re: spamlogd (how to specify port?)

2007-03-18 Thread Stuart Henderson
On 2007/03/18 16:35, Peter wrote:
> On OpenBSD 4.0, how do I specify what port spamlogd should consider SMTP?  My 
> MTA is running on a non-standard port.

edit /usr/src/libexec/spamlogd/spamlogd.c and recompile -
it's hardcoded "ip and port 25 ..."



Re: spamlogd (how to specify port?)

2007-03-18 Thread Darren Spruell

On 3/18/07, Peter <[EMAIL PROTECTED]> wrote:

On OpenBSD 4.0, how do I specify what port spamlogd should consider SMTP?  My
MTA is running on a non-standard port.


spamd sees your inbound SMTP traffic by virtue of the PF rdr rules
that direct connections to it. Refer to those rules and adjust ports
as needed.

DS



spamlogd (how to specify port?)

2007-03-18 Thread Peter
On OpenBSD 4.0, how do I specify what port spamlogd should consider SMTP?  My 
MTA is running on a non-standard port.

Pedro