Re: [Dovecot] new antispam plugin

2007-10-03 Thread Johannes Berg
On Tue, 2007-10-02 at 20:26 +0200, Andreas Schneider wrote:

  If you're building against libdspam you can't define -DHAVE_CONFIG_H or 
  dspam
  will look for its own dpsam config.h.


Ok I looked into this and it's really crappy. dovecot really *requires*
its config.h because of compat.h; you added a bunch of things to the
CFLAGS line but it's totally different here so fails with this error:

/usr/include/stdint.h:111: error: conflicting types for ‘uint_fast32_t’
../dovecot-1.0.5/src/lib/compat.h:46: error: previous declaration of
‘uint_fast32_t’ was here
/usr/include/stdint.h:141: error: conflicting types for ‘uintmax_t’
../dovecot-1.0.5/src/lib/compat.h:38: error: previous declaration of
‘uintmax_t’ was here

In fact, I can't easily make it compile at all without config.h. Maybe
we can have dovecot install its config.h as dovecot-config.h and simply
include it first thing everywhere?

Right now it looks as though we'll have to compile the different files
with different CFLAGS because otherwise I can't guarantee that the other
files can compile.

johannes


signature.asc
Description: This is a digitally signed message part


Re: [Dovecot] new antispam plugin

2007-10-02 Thread Johannes Berg
Hi,

 PACKAGE_VERSION is only defined if you're building in the dovecot source tree.
 It is set in the config.h file.

Hmm. That's too bad, it'd be nice to have the dovecot version built into
the plugin.

 If you're building against libdspam you can't define -DHAVE_CONFIG_H or dspam
 will look for its own dpsam config.h.

Hah. Hmm we can do some makefile tricks to only define that for
antispam-plugin.c rather than the backends.

johannes


signature.asc
Description: This is a digitally signed message part


Re: [Dovecot] new antispam plugin

2007-10-02 Thread Andreas Schneider
Johannes Berg wrote:
 Hi,

Hello,

 If you're building against libdspam you can't define -DHAVE_CONFIG_H or dspam
 will look for its own dpsam config.h.

 Hah. Hmm we can do some makefile tricks to only define that for
 antispam-plugin.c rather than the backends.

This would be a workaround but not really nice. What about reading the output
of dovecot --version and adding it.

I've updated the plugin it should work now. The problem is that it always
fails for me. It makes no difference if I use the dpsam-exec or dspam-library
backend. It looks like call_dspam() is never called.

It reports Failed to call dspam. I've added a debug message at the beginning
of call_dspam() and it gets never displayed.


 johannes

-- andreas


-- 
http://www.cynapses.org/ - cybernetic synapses

diff --git a/Makefile b/Makefile
index 5f1e362..dca50d0 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 -include .config
 
 # includes/flags we need for building a dovecot plugin
-CFLAGS += -DHAVE_CONFIG_H
+CFLAGS += $(DOVECOT_CFLAGS)
 CFLAGS += -I$(DOVECOT)/
 CFLAGS += -I$(DOVECOT)/src/
 CFLAGS += -I$(DOVECOT)/src/lib/
@@ -44,6 +44,12 @@ endif
 ifeq ($(BACKEND), dspam-exec)
 objs += signature.o
 endif
+ifeq ($(BACKEND), dspam-library)
+CFLAGS += -I$(DSPAM)/
+CFLAGS += -DLOGDIR=$(DSPAM_LOGDIR) -DCONFIG_DEFAULT=$(DSPAM_CONFIG)
+LDFLAGS += -ldspam
+objs += signature.o
+endif
 ifeq ($(BACKEND), signature-log)
 objs += signature.o
 endif
diff --git a/README b/README
index 328ef0f..a0a73ea 100644
--- a/README
+++ b/README
@@ -69,6 +69,10 @@ BACKENDS
  (2) when many users retrain many messages at once server load may
  spike
 
+dspam library backend (dspam specific)
+
+This backend instantly retrains by calling dspam trough libdspam.
+
 email sender backend (spam filter agnostic)
 
 This backend sends mail to [EMAIL PROTECTED] or [EMAIL PROTECTED]
@@ -127,6 +131,13 @@ CONFIGURATION
 # antispam_dspam_args = --user;%u  # % expansion done by dovecot
 # antispam_dspam_args = --mode=teft
 
+#===
+# dspam-library plugin
+
+# dspam home
+# The data directory of dspam
+antispam_dspam_home = /var/lib/dspam
+
 #=
 # mail sending plugin
 
diff --git a/antispam-plugin.c b/antispam-plugin.c
index ea7e426..876e5c9 100644
--- a/antispam-plugin.c
+++ b/antispam-plugin.c
@@ -139,4 +139,6 @@ void antispam_plugin_deinit(void)
 }
 
 /* put dovecot version we built against into plugin for checking */
-const char *antispam_plugin_version = PACKAGE_VERSION;
+#ifdef HAVE_CONFIG_H
+const char *antispam_plugin_version1.0.5;
+#endif
diff --git a/defconfig b/defconfig
index 31348dd..42e3f4b 100644
--- a/defconfig
+++ b/defconfig
@@ -17,18 +17,30 @@
 # point DOVECOT= to the installed headers too.
 DOVECOT=../dovecot-1.0.5
 #DOVECOT=../dovecot-1.1
+
+# Buliding in source
+DOVECOT_CFLAGS=-DHAVE_CONFIG_H
+
 #DOVECOT=/usr/include/dovecot
+# Buliding out of source
+#DOVECOT_CFLAGS=-DUOFF_T_LONG -DHAVE_SOCKLEN_T -DHAVE_STRUCT_IOVEC
 
 # Dovecot version to build against
 DOVECOT_VERSION=1.0
 #DOVECOT_VERSION=1.1	# CURRENTLY BROKEN
 
+# DSPAM header directory
+#DSPAM=/usr/include/dspam
+#DSPAM_LOGDIR=/var/log/dspam
+#DSPAM_CONFIG=/etc/dspam.conf
+
 # backend
 #  dspam-exec		- direct dspam training by calling dspam executable
 #  signature-log	- signature logging using dovecot's dict API
 #  mailtrain		- send mail to special addresses for training
 #  crm114-exec		- direct crm114 training by calling mailreaver.crm
 #BACKEND=dspam-exec
+#BACKEND=dspam-library
 #BACKEND=signature-log
 #BACKEND=mailtrain
 #BACKEND=crm114-exec
diff --git a/dspam-library.c b/dspam-library.c
new file mode 100644
index 000..b942532
--- /dev/null
+++ b/dspam-library.c
@@ -0,0 +1,146 @@
+/*
+ * dspam backend for dovecot antispam plugin
+ *
+ * Copyright (C) 2004-2007  Johannes Berg [EMAIL PROTECTED]
+ *2006  Frank Cusack
+ *2007  Andreas Schneider [EMAIL PROTECTED]
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License Version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ */
+
+#include stdlib.h
+#include libdspam.h
+
+#include lib.h
+#include mail-storage-private.h
+
+#include antispam-plugin.h
+#include signature.h
+
+static const char *dspam_home = /var/lib/dspam;
+
+static int call_dspam(const char *signature, enum classification wanted)
+{
+	

Re: [Dovecot] new antispam plugin

2007-10-02 Thread Johannes Berg
Hi,

 This would be a workaround but not really nice. What about reading the output
 of dovecot --version and adding it.

Hmm. No, we need the version we're building against not the running
version.

 I've updated the plugin it should work now. The problem is that it always
 fails for me. It makes no difference if I use the dpsam-exec or dspam-library
 backend. It looks like call_dspam() is never called.

Hmm. There was a bug in the crm114 backend after I'd copied it, but I
need to verify in the dspam-exec backend. But that shouldn't affect your
dspam-library.

 It reports Failed to call dspam. I've added a debug message at the beginning
 of call_dspam() and it gets never displayed.

Weird. I'll take a look. crm114-exec definitely works, might be worth
comparing. I'm out starting immediately until tomorrow night, will take
a look then.

johannes


signature.asc
Description: This is a digitally signed message part


Re: [Dovecot] new antispam plugin

2007-10-02 Thread Andreas Schneider
Johannes Berg wrote:
 
 Weird. I'll take a look. crm114-exec definitely works, might be worth
 comparing. I'm out starting immediately until tomorrow night, will take
 a look then.

dspam-exec doesn't work too.

 
 johannes

-- andreas

-- 
http://www.cynapses.org/ - cybernetic synapses




signature.asc
Description: OpenPGP digital signature


Re: [Dovecot] new antispam plugin

2007-10-01 Thread Johannes Berg
On Sun, 2007-09-30 at 16:04 +0200, Johannes Berg wrote:

 Timothy, you could write the mysql logger as a backend too.

I looked into that using the dict API but had quite a few problems. See
here:
http://git.sipsolutions.net/?p=dovecot-antispam.git;a=commitdiff;h=306addd1d2987bf0df182910ad741d4edb52ba55

johannes


signature.asc
Description: This is a digitally signed message part


Re: [Dovecot] new antispam plugin

2007-10-01 Thread Johannes Berg
I just implemented a new feature with which you can easily implement
pristine training or such:

http://git.sipsolutions.net/?p=dovecot-antispam.git;a=commitdiff;h=4ee8b72dab4a5bc0309a956942ee2dc9d2f7258f

johannes


signature.asc
Description: This is a digitally signed message part


Re: [Dovecot] new antispam plugin

2007-10-01 Thread Andreas Schneider
Johannes Berg wrote:
 I just implemented a new feature with which you can easily implement
 pristine training or such:
 
 http://git.sipsolutions.net/?p=dovecot-antispam.git;a=commitdiff;h=4ee8b72dab4a5bc0309a956942ee2dc9d2f7258f

Hi Johannes,

I've just implemented the dspam library backend. I've found some problems.

PACKAGE_VERSION is only defined if you're building in the dovecot source tree.
It is set in the config.h file.

If you're building against libdspam you can't define -DHAVE_CONFIG_H or dspam
will look for its own dpsam config.h.

I haven't tested the plugin yet, cause I'm traveling atm and on this wifi I
can't connect to our VPN enviroment to access my workstation to compile it
with the right system.

 
 johannes

Best regards,


-- andreas

-- 
http://www.cynapses.org/ - cybernetic synapses

diff --git a/Makefile b/Makefile
index 5f1e362..dca50d0 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 -include .config
 
 # includes/flags we need for building a dovecot plugin
-CFLAGS += -DHAVE_CONFIG_H
+CFLAGS += $(DOVECOT_CFLAGS)
 CFLAGS += -I$(DOVECOT)/
 CFLAGS += -I$(DOVECOT)/src/
 CFLAGS += -I$(DOVECOT)/src/lib/
@@ -44,6 +44,12 @@ endif
 ifeq ($(BACKEND), dspam-exec)
 objs += signature.o
 endif
+ifeq ($(BACKEND), dspam-library)
+CFLAGS += -I$(DSPAM)/
+CFLAGS += -DLOGDIR=$(DSPAM_LOGDIR) -DCONFIG_DEFAULT=$(DSPAM_CONFIG)
+LDFLAGS += -ldspam
+objs += signature.o
+endif
 ifeq ($(BACKEND), signature-log)
 objs += signature.o
 endif
diff --git a/README b/README
index 328ef0f..a0a73ea 100644
--- a/README
+++ b/README
@@ -69,6 +69,10 @@ BACKENDS
  (2) when many users retrain many messages at once server load may
  spike
 
+dspam library backend (dspam specific)
+
+This backend instantly retrains by calling dspam trough libdspam.
+
 email sender backend (spam filter agnostic)
 
 This backend sends mail to [EMAIL PROTECTED] or [EMAIL PROTECTED]
@@ -127,6 +131,13 @@ CONFIGURATION
 # antispam_dspam_args = --user;%u  # % expansion done by dovecot
 # antispam_dspam_args = --mode=teft
 
+#===
+# dspam-library plugin
+
+# dspam home
+# The data directory of dspam
+antispam_dspam_home = /var/lib/dspam
+
 #=
 # mail sending plugin
 
diff --git a/antispam-plugin.c b/antispam-plugin.c
index ea7e426..876e5c9 100644
--- a/antispam-plugin.c
+++ b/antispam-plugin.c
@@ -139,4 +139,6 @@ void antispam_plugin_deinit(void)
 }
 
 /* put dovecot version we built against into plugin for checking */
-const char *antispam_plugin_version = PACKAGE_VERSION;
+#ifdef HAVE_CONFIG_H
+const char *antispam_plugin_version1.0.5;
+#endif
diff --git a/defconfig b/defconfig
index 31348dd..42e3f4b 100644
--- a/defconfig
+++ b/defconfig
@@ -17,18 +17,30 @@
 # point DOVECOT= to the installed headers too.
 DOVECOT=../dovecot-1.0.5
 #DOVECOT=../dovecot-1.1
+
+# Buliding in source
+DOVECOT_CFLAGS=-DHAVE_CONFIG_H
+
 #DOVECOT=/usr/include/dovecot
+# Buliding out of source
+#DOVECOT_CFLAGS=-DUOFF_T_LONG -DHAVE_SOCKLEN_T -DHAVE_STRUCT_IOVEC
 
 # Dovecot version to build against
 DOVECOT_VERSION=1.0
 #DOVECOT_VERSION=1.1	# CURRENTLY BROKEN
 
+# DSPAM header directory
+#DSPAM=/usr/include/dspam
+#DSPAM_LOGDIR=/var/log/dspam
+#DSPAM_CONFIG=/etc/dspam.conf
+
 # backend
 #  dspam-exec		- direct dspam training by calling dspam executable
 #  signature-log	- signature logging using dovecot's dict API
 #  mailtrain		- send mail to special addresses for training
 #  crm114-exec		- direct crm114 training by calling mailreaver.crm
 #BACKEND=dspam-exec
+#BACKEND=dspam-library
 #BACKEND=signature-log
 #BACKEND=mailtrain
 #BACKEND=crm114-exec
diff --git a/dspam-library.c b/dspam-library.c
new file mode 100644
index 000..b942532
--- /dev/null
+++ b/dspam-library.c
@@ -0,0 +1,146 @@
+/*
+ * dspam backend for dovecot antispam plugin
+ *
+ * Copyright (C) 2004-2007  Johannes Berg [EMAIL PROTECTED]
+ *2006  Frank Cusack
+ *2007  Andreas Schneider [EMAIL PROTECTED]
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License Version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ */
+
+#include stdlib.h
+#include libdspam.h
+
+#include lib.h
+#include mail-storage-private.h
+
+#include antispam-plugin.h
+#include signature.h
+
+static const char *dspam_home = /var/lib/dspam;
+
+static int call_dspam(const char *signature, 

Re: [Dovecot] new antispam plugin

2007-10-01 Thread Marcus Rueckert
On 2007-10-02 05:51:38 +0200, Andreas Schneider wrote:
 Johannes Berg wrote:
  I just implemented a new feature with which you can easily implement
  pristine training or such:
  
  http://git.sipsolutions.net/?p=dovecot-antispam.git;a=commitdiff;h=4ee8b72dab4a5bc0309a956942ee2dc9d2f7258f
 
 Hi Johannes,
 
 I've just implemented the dspam library backend. I've found some problems.
 
 PACKAGE_VERSION is only defined if you're building in the dovecot source tree.
 It is set in the config.h file.
 
 If you're building against libdspam you can't define -DHAVE_CONFIG_H or dspam
 will look for its own dpsam config.h.
 
 I haven't tested the plugin yet, cause I'm traveling atm and on this wifi I
 can't connect to our VPN enviroment to access my workstation to compile it
 with the right system.

packages should never ever ship config.h conflicting macros like
PACKAGE_VERSIONS and HAVE_* can cause a lot of trouble.

darix

-- 
   openSUSE - SUSE Linux is my linux
   openSUSE is good for you
   www.opensuse.org


[Dovecot] new antispam plugin

2007-09-30 Thread Johannes Berg
Sparked from the discussion on the list, I've put my antispam plugin
into git and split up the code into a frontend and possibly multiple
backends. See http://git.sipsolutions.net/dovecot-antispam.git/ (URL
functions as both gitweb and git URL)

Andreas, I took your README file and adjusted it, I hope you don't mind.
I didn't fork from your git tree because you'd already implemented the
libdspam backend there. Maybe you could take a look at the new
backend/frontend separation and implement a libdspam backend.

Aria, it should be possible to write a spamassassin plugin, quite easily
if spamassassin supports training based on signatures, not quite so
easily otherwise though I intend to plan this.

Timothy, you could write the mysql logger as a backend too.

I take patches :)

Oh and as always thanks to Timo for implementing such a nice server and
string, memory and mail handling API.

johannes


signature.asc
Description: This is a digitally signed message part


Re: [Dovecot] new antispam plugin

2007-09-30 Thread Johannes Berg
On Sun, 2007-09-30 at 16:04 +0200, Johannes Berg wrote:
 Sparked from the discussion on the list, I've put my antispam plugin
 into git and split up the code into a frontend and possibly multiple
 backends. See http://git.sipsolutions.net/dovecot-antispam.git/ (URL
 functions as both gitweb and git URL)

Just added a new feature that should help those who need --user given on
the dspam command line:

http://git.sipsolutions.net/?p=dovecot-antispam.git;a=commit;h=b61c062501065d35c95fc6eb538d3468baf6fac3

---%---
dspam-exec backend: allow extra arguments

This allows people who need --user given on the command line to
add something like this to the configuration:

antispam_dspam_args = --user;%u

where the semicolon is the separator between arguments to build
the dspam command line as indicated by the dspam manual page:

dspam [--user user1 user2 ...]
---%---


johannes


signature.asc
Description: This is a digitally signed message part


Re: [Dovecot] new antispam plugin

2007-09-30 Thread Andraž 'ruskie' Levstik
On 16:04:18 2007-09-30 Johannes Berg [EMAIL PROTECTED] wrote:
 Sparked from the discussion on the list, I've put my antispam plugin
 into git and split up the code into a frontend and possibly multiple
 backends. See http://git.sipsolutions.net/dovecot-antispam.git/ (URL
 functions as both gitweb and git URL)
 

Hmm if I'm reading the code correctly one can define multiple spam folders?

Would be nice to include a sample config i.e. all the variables that can be
set
and possible settings etc...

--
Andraž ruskie Levstik
Source Mage GNU/Linux Games grimoire guru
Geek/Hacker/Tinker

Be sure brain is in gear before engaging mouth.

Key id = F4C1F89C
Key fingerprint = 6FF2 8F20 4C9D DB36 B5B6  F134 884D 72CC F4C1 F89C



Re: [Dovecot] new antispam plugin

2007-09-30 Thread Johannes Berg
On Sun, 2007-09-30 at 18:12 +0200, Andraž 'ruskie' Levstik wrote:
 On 16:04:18 2007-09-30 Johannes Berg [EMAIL PROTECTED] wrote:
  Sparked from the discussion on the list, I've put my antispam plugin
  into git and split up the code into a frontend and possibly multiple
  backends. See http://git.sipsolutions.net/dovecot-antispam.git/ (URL
  functions as both gitweb and git URL)
  
 
 Hmm if I'm reading the code correctly one can define multiple spam folders?
 
 Would be nice to include a sample config i.e. all the variables that can be
 set
 and possible settings etc...

http://git.sipsolutions.net/?p=dovecot-antispam.git;a=commitdiff;h=658e7fe97b059ebf893fc3f2656ee6f569a7fb9f;hp=94e5e07c847768a15157c183aaa3bcb914e1afc2

johannes


signature.asc
Description: This is a digitally signed message part


Re: [Dovecot] new antispam plugin

2007-09-30 Thread Andraž 'ruskie' Levstik
On 18:33:33 2007-09-30 Johannes Berg [EMAIL PROTECTED] wrote:
 On Sun, 2007-09-30 at 18:12 +0200, Andraž 'ruskie' Levstik wrote:
  On 16:04:18 2007-09-30 Johannes Berg [EMAIL PROTECTED]
  wrote:
   Sparked from the discussion on the list, I've put my antispam plugin
   into git and split up the code into a frontend and possibly multiple
   backends. See http://git.sipsolutions.net/dovecot-antispam.git/ (URL
   functions as both gitweb and git URL)

   
  Hmm if I'm reading the code correctly one can define multiple spam
  folders?
   
  Would be nice to include a sample config i.e. all the variables that
  can be set
  and possible settings etc...
 
 http://git.sipsolutions.net/?p=dovecot-antispam.git;a=commitdiff;h=658e7fe97b059ebf893fc3f2656ee6f569a7fb9f;hp=94e5e07c847768a15157c183aaa3bcb914e1afc2

 

Many thanks...

btw I am wondering why exactly do you need the dovecot source and wouldn't
just the development headers be enough to build it?

There's quite a bit of things installed into:
/usr/include/dovecot

When one passes --enable-header-install to configure...


--
Andraž ruskie Levstik
Source Mage GNU/Linux Games grimoire guru
Geek/Hacker/Tinker

Be sure brain is in gear before engaging mouth.

Key id = F4C1F89C
Key fingerprint = 6FF2 8F20 4C9D DB36 B5B6  F134 884D 72CC F4C1 F89C



Re: [Dovecot] new antispam plugin

2007-09-30 Thread Johannes Berg
On Sun, 2007-09-30 at 18:43 +0200, Andraž 'ruskie' Levstik wrote:

 btw I am wondering why exactly do you need the dovecot source and wouldn't
 just the development headers be enough to build it?
 
 There's quite a bit of things installed into:
 /usr/include/dovecot
 
 When one passes --enable-header-install to configure...

Dunno. Debian doesn't ship a dev package so I haven't tried.

johannes


signature.asc
Description: This is a digitally signed message part