[Dovecot] dspam plugin (and dovecot-dspam-plugin not launching
ryank at rkware.com
Wed Apr 12 20:47:00 EEST 2006
-----BEGIN PGP SIGNED MESSAGE-----
I tracked down the problem. Not really sure what's causing it or how to
fix it but I managed to work around the issue. Also ran into a couple
other problems that are similar to some other recent issues on this list.
Sorry for the longish email, but i'm hoping that this will help some other
people as well.
In trying to determine if the memory corruption was in creating the string
or in storing it into our linked arrary, i first stored the result from
p_strdup into a variable, inspected the results, and then had the normal
line of code that called p_strdup again.
For whatever reason, the second call to p_strdup succeeds and does The
Right Thing(tm). I'm not sure if there's an issue with allocating or
setting up the pool.
I'm fairly new to dovecot so I'm not sure of how it handles connections,
but I think i'm ok with allocating the extra string as i'm under the
impression that each imap session is a forked process so there shouldn't
be any long term leaks.
So, in my working plugin, i have changed:
list_append(listpool, &siglist)->sig = p_strdup(listpool, signature);
siglist->sig = p_strdup(listpool, signature);
as long as it works.. i'm not going to complain too much!
A couple other points:
valgrind has never raised any issues with anything in the plugin. I even
tried running it with trace-children enabled. I'm running gentoo and
valgrind is ~amd64 (not marked as stable) so perhaps it has some 64 bit
issues as well or wasn't able to detect anything.
Also, I was still getting errors once the plugin was getting far enough to
call dspam with a valid signature. It was complaining that it couldn't
determine the user. Learned a little bit more about the dspam design.
Apparently, for the plugin to work as is, the user that's calling dspam
needs to exist in the virtual_uids table.
dspam apparently always needs to know what user its working with. However,
the plugin doesn't have any fuctionality for determining this from the
email. Thankfully, the dspam signature can be written to the email in the
form of <uid>,<signature> if MySQLUIDInSignature is set to on in the
Even though dspam can determine the user from the signature, it still
needs to startup as a valid user. If the user is notspecified on the
command line with the --user parameter, dspam uses the user that invoked
dspam. A couple quick getuid and geteuid calls showed that my dovecot imap
session was running as 'nobody', and my dovecot process is running as
'dovecot'. Adding both those to the virutal_uid tables still yielded the
same error. So, i left 'dovecot' in my users table and added '--user
dovecot' to the execl call.
With all of that in place, I can now move mail into or out of my SPAM
folder and see dspam being called correctly and also seeing the database
being updated as well.
Hopefully this helps someone out who's looking at getting this running and
running into similar issues. Saw a similar thread from Stefan a few days
ago, and that's what gave me enough insight to get to the bottom of this.
On Wed, April 12, 2006 7:48 am, Johannes Berg said:
> On Tue, 2006-04-11 at 22:14 -0500, Ryan Kolak wrote:
>> found a small handful of leaks on startup, none of which look like
>> anything directly related.. There's one more leak when the first time i
>> load a page via squirrelmail (in the login process), but nothing after
>> that until i kill dovecot. the full output is at the bottom if its
>> at all.
> There's definitely a small one-time leak when the plugin is loaded which
> valgrind should've shown. Are you sure that you actually used the plugin
> by moving some mail between normal and spam?
PGP Fingerprint - E15C CC7D 5830 AB8A C2AE 5C5E 80D8 6B63 D40B 015C
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
-----END PGP SIGNATURE-----
More information about the dovecot