<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BenV&#039;s notes &#187; qmail</title>
	<atom:link href="http://notes.benv.junerules.com/tag/qmail/feed/" rel="self" type="application/rss+xml" />
	<link>http://notes.benv.junerules.com</link>
	<description>Rants and notes</description>
	<lastBuildDate>Wed, 28 Jul 2010 13:36:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Qmail + vpopmail + Dovecot and Sieve</title>
		<link>http://notes.benv.junerules.com/all/software/qmail-vpopmail-dovecot-and-sieve/</link>
		<comments>http://notes.benv.junerules.com/all/software/qmail-vpopmail-dovecot-and-sieve/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 22:11:47 +0000</pubDate>
		<dc:creator>BenV</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[qmail]]></category>
		<category><![CDATA[sieve]]></category>

		<guid isPermaLink="false">http://notes.benv.junerules.com/?p=621</guid>
		<description><![CDATA[Let&#8217;s start with a problem description. We start out with a -working- mailer: A pretty simple qmail/vpopmail installation with Courier IMAP and the pop3d that comes with qmail. This is administered by users with the qmailadmin frontend and allows for creation of mailboxes and forwards by postmasters. Together with spamdyke and spamassassin it works pretty [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s start with a problem description. We start out with a -working- mailer:<br />
A pretty simple qmail/vpopmail installation with Courier IMAP and the pop3d that comes with qmail. This is administered by users with the qmailadmin frontend and allows for creation of mailboxes and forwards by postmasters. Together with spamdyke and spamassassin it works pretty well. So why change it?</p>
<p>The problem: First of all, Courier is a piece of shit. The various parts of it have broken in various ways over the years (authd hanging for no apparent reason or suddenly eating a ton of memory, stuff like that). Not only that, but they decided that vpopmail wasn&#8217;t worth supporting anymore, so their latest release of courier-authlib simply doesn&#8217;t handle vpopmail anymore. (don&#8217;t ask me why, can&#8217;t find any details on it).<br />
Second of all, it would be cool to give our users the ability to create their own custom mail filters on our server. Stuff that you can do in thunderbird or through webmail, so they can setup their mailbox filters and vacation messages and whatever without me having to help them. (well&#8230;. we&#8217;ll see about that). Needless to say we could do that by giving them access to the .qmail files, but those are way out of their league. Not only that, it would be a security nightmare. So to solve that, we&#8217;re trying the <a href="http://en.wikipedia.org/wiki/Sieve_(mail_filtering_language)">Sieve</a> disaster. I mean language&#8230; or something.<span id="more-621"></span></p>
<p>Getting rid of Courier is really simple. Simply pull the harddisk out of your server and shake it a few times, then step on it and throw it out of the window (while still standing on top of it of course). If you did it properly you should now be wondering why the hell you follow instructions without thinking. However, if you do have a brain, you might want to shutdown the courier-imap* and pop* services and remove them from your disk. Tada.<br />
Personally I replaced the pop, imap and auth services with <a href="http://www.dovecot.org/">Dovecot</a>. If you&#8217;re running qmail like you&#8217;re supposed to this is pretty easy. Check out <a href="http://qmail.jms1.net/dovecot.shtml">this page by John Simpson</a> for details on that. Instructions for vpopmail included. (thanks again John!)</p>
<p>Now for the interesting part. Getting Sieve to work. I decided to get the latest shiny version from their hg repository, but feel free to take the latest stable version instead.</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root<span style="color: #000000; font-weight: bold;">@</span>black:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>dovecot-sieve$ hg clone http:<span style="color: #000000; font-weight: bold;">//</span>hg.rename-it.nl<span style="color: #000000; font-weight: bold;">/</span>dovecot-<span style="color: #000000;">1.2</span>-sieve dovecot-<span style="color: #000000;">1.2</span>-sieve-hg<br />
&nbsp;<span style="color: #000000; font-weight: bold;">*</span>clone meets clone<span style="color: #000000; font-weight: bold;">*</span><br />
root<span style="color: #000000; font-weight: bold;">@</span>black:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>dovecot-sieve$ <span style="color: #7a0874; font-weight: bold;">cd</span> dovecot-<span style="color: #000000;">1.2</span>-sieve-hg<br />
root<span style="color: #000000; font-weight: bold;">@</span>black:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>dovecot-sieve<span style="color: #000000; font-weight: bold;">/</span>dovecot-<span style="color: #000000;">1.2</span>-sieve-hg$ .<span style="color: #000000; font-weight: bold;">/</span>autogen.sh<br />
&nbsp;<span style="color: #000000; font-weight: bold;">*</span>skip that <span style="color: #000000; font-weight: bold;">if</span> you are using the stable version<span style="color: #000000; font-weight: bold;">*</span><br />
root<span style="color: #000000; font-weight: bold;">@</span>black:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>dovecot-sieve<span style="color: #000000; font-weight: bold;">/</span>dovecot-<span style="color: #000000;">1.2</span>-sieve-hg$ .<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>usr <span style="color: #660033;">--with-dovecot</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>dovecot-1.2.8<br />
root<span style="color: #000000; font-weight: bold;">@</span>black:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>dovecot-sieve<span style="color: #000000; font-weight: bold;">/</span>dovecot-<span style="color: #000000;">1.2</span>-sieve-hg$ <span style="color: #c20cb9; font-weight: bold;">make</span> ; <span style="color: #c20cb9; font-weight: bold;">mkdir</span> pkg ; <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #007800;">DESTDIR</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">pwd</span><span style="color: #000000; font-weight: bold;">`/</span>pkg <span style="color: #c20cb9; font-weight: bold;">install</span> ; <span style="color: #7a0874; font-weight: bold;">cd</span> pkg ; makepkg <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span>dovecot-sieve-i386-<span style="color: #000000;">1</span>.tgz</div></div>
<p>Now we still need to enable it. Make sure your <span style="color:#FF00FF">/etc/dovecot.conf</span> has a section like this:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">##</span><br />
<span style="color: #666666; font-style: italic;">## Local Delivery Agent stuff</span><br />
<span style="color: #666666; font-style: italic;">##</span><br />
protocol lda <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; postmaster_address = postmaster<span style="color: #000000; font-weight: bold;">@</span>your.mother.isawhore.nl<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">hostname</span> = mail.server.gov<br />
&nbsp; &nbsp; &nbsp; &nbsp; sendmail_path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>qmail<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sendmail</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; mail_plugins = sieve<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; log_path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>dovecot-deliver-errors.log<br />
&nbsp; &nbsp; &nbsp; &nbsp; info_log_path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>dovecot-deliver.log<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #007800;">debug</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
auth default <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># Your other garbage options here .... </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; socket listen <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; master <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>auth-master<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mode = 0660<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; user = vpopmail<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; group = vchkpw<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
plugin <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; sieve = ~<span style="color: #000000; font-weight: bold;">/</span>.sieve<span style="color: #000000; font-weight: bold;">/</span>dovecot.sieve<br />
&nbsp; &nbsp; &nbsp; &nbsp; sieve_dir = ~<span style="color: #000000; font-weight: bold;">/</span>.sieve<br />
&nbsp; &nbsp; &nbsp; &nbsp; sieve_global_dir = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>sieve<span style="color: #000000; font-weight: bold;">/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; sieve_subaddress_sep = -+<br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span></div></div>
<p>Easy. This should make the <span style="color:#00FFAA">/usr/libexec/dovecot/deliver</span> program able to verify the account information of a requested user against the vpopmail database and it instructs the local delivery part to use the sieve plugin. (which I&#8217;ve configured some paths for).<br />
However, next part literally took me hours to figure out. I wanted to use the Dovecot LDA only for my test email account. So I created a .qmail file for my user &#8211; <a href="http://wiki.dovecot.org/LDA/Qmail">according to their wiki </a>:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root<span style="color: #000000; font-weight: bold;">@</span>black$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'|/var/qmail/bin/preline -f /usr/local/libexec/dovecot/deliver -d $EXT@$USER'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> ~vpopmail<span style="color: #000000; font-weight: bold;">/</span>domains<span style="color: #000000; font-weight: bold;">/</span>benv.junerules.com<span style="color: #000000; font-weight: bold;">/</span>.qmail-benv-test<br />
root<span style="color: #000000; font-weight: bold;">@</span>black$ <span style="color: #c20cb9; font-weight: bold;">chown</span> vpopmail:vchkpw ~vpopmail<span style="color: #000000; font-weight: bold;">/</span>domains<span style="color: #000000; font-weight: bold;">/</span>benv.junerules.com<span style="color: #000000; font-weight: bold;">/</span>.qmail-benv-test</div></div>
<p>According to their wiki, this should be the correct way to invoke the deliver program. So I send a test mail to benv-test@benv.junerules.com &#8230;. nothing happens. Nothing in logs, nothing.<br />
Oh that&#8217;s a lie, the error log says:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">deliver<span style="color: #7a0874; font-weight: bold;">&#40;</span>benv-test<span style="color: #000000; font-weight: bold;">@</span>benv.junerules.com<span style="color: #7a0874; font-weight: bold;">&#41;</span>: Info: Loading modules from directory: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>lda<br />
deliver<span style="color: #7a0874; font-weight: bold;">&#40;</span>benv-test<span style="color: #000000; font-weight: bold;">@</span>benv.junerules.com<span style="color: #7a0874; font-weight: bold;">&#41;</span>: Info: Module loaded: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>lda<span style="color: #000000; font-weight: bold;">/</span>lib90_sieve_plugin.so</div></div>
<p>Of course it doesn&#8217;t work yet, I haven&#8217;t put a sieve filter in place yet. So I put a simple reject filter there so I know it works when it does <img src='http://notes.benv.junerules.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
This is the contents of a file <span style="color:#AAFF00">~vpopmail/domains/benv.junerules.com/benv/.sieve/dovecot.sieve</span>. <b>Corresponding with the dovecot.conf plugin settings</b>.</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">require <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;reject&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;<br />
<br />
reject <span style="color: #ff0000;">&quot;If you're getting this reject... it works. Also, your mom wears combat boots!&quot;</span>;</div></div>
<p>I send another mail. Same stuff in the logs. Mhm&#8230; more debugging would be great guys. I have no idea if it loads a sieve filter, from what directory or if it does anything at all! GRRRr.<br />
After a lot of cursing and throwing with plants and cats and hammers, I went through the mailing archives from the John&#8217;s qmail-patch list and found a snippet from someone else that set up something similar. Apparently the way to invoke the deliver program is different. Because I use the qmail extension addresses, benv-test@benv.junerules.com was given as user. However, vpopmail only knows about benv@benv.junerules.com, so it failed. Blegh.<br />
So for now I decided to use the solution offered by the mailinglist:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #007800;">DTLINE</span>=<span style="color: #800000;">${DTLINE/$USER-}</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>qmail<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>preline <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>deliver <span style="color: #660033;">-d</span> <span style="color: #800000;">${EXT/-*}</span><span style="color: #000000; font-weight: bold;">@</span><span style="color: #007800;">$USER</span> <span style="color: #660033;">-a</span> <span style="color: #007800;">$EXT</span><span style="color: #000000; font-weight: bold;">@</span><span style="color: #007800;">$USER</span></div></div>
<p>A little explanation on the environment variables. Normally when I send a message to benv-test@benv.junerules.com they look like this:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #007800;">HOST2</span>=benv.junerules<br />
<span style="color: #007800;">HOST3</span>=benv<br />
<span style="color: #007800;">RECIPIENT</span>=benv.junerules.com-benv-test<span style="color: #000000; font-weight: bold;">@</span>benv.junerules.com<br />
<span style="color: #007800;">HOST</span>=benv.junerules.com<br />
<span style="color: #007800;">DTLINE</span>=Delivered-To: benv.junerules.com-benv-test<span style="color: #000000; font-weight: bold;">@</span>benv.junerules.com<br />
<span style="color: #007800;">HOST4</span>=benv<br />
<span style="color: #007800;">USER</span>=benv.junerules.com<br />
<span style="color: #007800;">EXT</span>=benv-test<br />
<span style="color: #007800;">LOCAL</span>=benv.junerules.com-benv-test<br />
<span style="color: #007800;">SHLVL</span>=<span style="color: #000000;">2</span><br />
<span style="color: #007800;">EXT3</span>=<br />
<span style="color: #007800;">EXT2</span>=<span style="color: #7a0874; font-weight: bold;">test</span><br />
<span style="color: #007800;">EXT4</span>=</div></div>
<p>The DTLINE rewrite isn&#8217;t strictly necessary but looks a bit nicer in the logs. However, the EXT@USER part should not contain all the extensions since they won&#8217;t resolve to a vpopmail user.<br />
With the rewritten .qmail file I send another test email. Here&#8217;s the log:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">deliver<span style="color: #7a0874; font-weight: bold;">&#40;</span>benv<span style="color: #000000; font-weight: bold;">@</span>benv.junerules.com<span style="color: #7a0874; font-weight: bold;">&#41;</span>: Info: Loading modules from directory: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>lda<br />
deliver<span style="color: #7a0874; font-weight: bold;">&#40;</span>benv<span style="color: #000000; font-weight: bold;">@</span>benv.junerules.com<span style="color: #7a0874; font-weight: bold;">&#41;</span>: Info: Module loaded: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>lda<span style="color: #000000; font-weight: bold;">/</span>lib90_sieve_plugin.so<br />
deliver<span style="color: #7a0874; font-weight: bold;">&#40;</span>benv<span style="color: #000000; font-weight: bold;">@</span>benv.junerules.com<span style="color: #7a0874; font-weight: bold;">&#41;</span>: Info: auth input: <span style="color: #007800;">uid</span>=<span style="color: #000000;">89</span><br />
deliver<span style="color: #7a0874; font-weight: bold;">&#40;</span>benv<span style="color: #000000; font-weight: bold;">@</span>benv.junerules.com<span style="color: #7a0874; font-weight: bold;">&#41;</span>: Info: auth input: <span style="color: #007800;">gid</span>=<span style="color: #000000;">89</span><br />
deliver<span style="color: #7a0874; font-weight: bold;">&#40;</span>benv<span style="color: #000000; font-weight: bold;">@</span>benv.junerules.com<span style="color: #7a0874; font-weight: bold;">&#41;</span>: Info: auth input: <span style="color: #007800;">home</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>vpopmail<span style="color: #000000; font-weight: bold;">/</span>domains<span style="color: #000000; font-weight: bold;">/</span>benv.junerules.com<span style="color: #000000; font-weight: bold;">/</span>benv<br />
deliver<span style="color: #7a0874; font-weight: bold;">&#40;</span>benv<span style="color: #000000; font-weight: bold;">@</span>benv.junerules.com<span style="color: #7a0874; font-weight: bold;">&#41;</span>: Info: Namespace: <span style="color: #007800;">type</span>=private, <span style="color: #007800;">prefix</span>=INBOX., <span style="color: #007800;">sep</span>=., <span style="color: #007800;">inbox</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span>, <span style="color: #007800;">hidden</span>=no, <span style="color: #007800;">list</span>=<span style="color: #000000;">1</span>, <span style="color: #007800;">subscriptions</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span><br />
deliver<span style="color: #7a0874; font-weight: bold;">&#40;</span>benv<span style="color: #000000; font-weight: bold;">@</span>benv.junerules.com<span style="color: #7a0874; font-weight: bold;">&#41;</span>: Info: maildir: <span style="color: #007800;">data</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>vpopmail<span style="color: #000000; font-weight: bold;">/</span>domains<span style="color: #000000; font-weight: bold;">/</span>benv.junerules.com<span style="color: #000000; font-weight: bold;">/</span>benv<span style="color: #000000; font-weight: bold;">/</span>Maildir<br />
deliver<span style="color: #7a0874; font-weight: bold;">&#40;</span>benv<span style="color: #000000; font-weight: bold;">@</span>benv.junerules.com<span style="color: #7a0874; font-weight: bold;">&#41;</span>: Info: maildir++: <span style="color: #007800;">root</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>vpopmail<span style="color: #000000; font-weight: bold;">/</span>domains<span style="color: #000000; font-weight: bold;">/</span>benv.junerules.com<span style="color: #000000; font-weight: bold;">/</span>benv<span style="color: #000000; font-weight: bold;">/</span>Maildir, <span style="color: #007800;">index</span>=, <span style="color: #007800;">control</span>=, <span style="color: #007800;">inbox</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>vpopmail<span style="color: #000000; font-weight: bold;">/</span>domains<span style="color: #000000; font-weight: bold;">/</span>benv.junerules.com<span style="color: #000000; font-weight: bold;">/</span>benv<span style="color: #000000; font-weight: bold;">/</span>Mai<br />
ldir<br />
deliver<span style="color: #7a0874; font-weight: bold;">&#40;</span>benv<span style="color: #000000; font-weight: bold;">@</span>benv.junerules.com<span style="color: #7a0874; font-weight: bold;">&#41;</span>: Info: sieve: using sieve path <span style="color: #000000; font-weight: bold;">for</span> user<span style="color: #ff0000;">'s script: /home/vpopmail/domains/benv.junerules.com/benv/.sieve/dovecot.sieve<br />
deliver(benv@benv.junerules.com): Info: sieve: opening script /home/vpopmail/domains/benv.junerules.com/benv/.sieve/dovecot.sieve<br />
deliver(benv@benv.junerules.com): Info: sieve: executing compiled script /home/vpopmail/domains/benv.junerules.com/benv/.sieve/dovecot.sieve<br />
deliver(benv@benv.junerules.com): Info: sieve: msgid=&lt;20091207214454.GJ9038@uil.winnipeg.nl&gt;: rejected message from &lt;benv-rotnaarjegraf@junerules.com&gt; (reject)</span></div></div>
<p>Woohoo, it rejected! <img src='http://notes.benv.junerules.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
So Sieve works. Next thing to do is to get ManageSieve up and running and test it with thunderbird and <a href="https://addons.mozilla.org/en-US/thunderbird/addon/2548">some sieve addons</a><br />
But that&#8217;s a rant for later, my eyes are collapsing.</p>
]]></content:encoded>
			<wfw:commentRss>http://notes.benv.junerules.com/all/software/qmail-vpopmail-dovecot-and-sieve/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Qmail + Spamdyke and fail2ban</title>
		<link>http://notes.benv.junerules.com/all/software/qmail-spamdyke-and-fail2ban/</link>
		<comments>http://notes.benv.junerules.com/all/software/qmail-spamdyke-and-fail2ban/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 09:52:09 +0000</pubDate>
		<dc:creator>BenV</dc:creator>
				<category><![CDATA[Morons]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[fail2ban]]></category>
		<category><![CDATA[qmail]]></category>
		<category><![CDATA[spamdyke]]></category>

		<guid isPermaLink="false">http://notes.benv.junerules.com/?p=539</guid>
		<description><![CDATA[Yesterday evening I was curiously looking at some tcpdump traffic that went through our dom0 of Xenbro. There seemed to be a ton of weird DNS requests. And with weird I mean spamlike domains, like familiesfirstmedical.com. After wondering for a bit I realized they were coming from our service domU that runs mail for the [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday evening I was curiously looking at some tcpdump traffic that went through our dom0 of Xenbro. There seemed to be a ton of weird DNS requests. And with weird I mean spamlike domains, like familiesfirstmedical.com. After wondering for a bit I realized they were coming from our service domU that runs mail for the junerules.com domain.<span id="more-539"></span><br />
I logged in and was surprised to see more than 50 active connections busy trying to deliver mostly spam to us. Fortunately I have some anti spam things enabled like <a href="http://spamassassin.apache.org/">spamassassin</a> and reverse DNS checking (which is where the DNS requests came from) and some more things using <a href="http://www.spamdyke.org/">Spamdyke</a>. However, checking the maillog I noticed that there were over 300000 denied connections from a day earlier! Time to become a bit more agressive in getting rid of zombie machines trying to spam us.</p>
<p>As a side story, since we moved our junerules.com domain from our very kind previous host to our own Xenbro machine, the amount of spam we receive plummeted. Apparently not because they stopped spamming on the domain though. I&#8217;m sure our previous host is glad he doesn&#8217;t have to deal with all the attention and traffic anymore <img src='http://notes.benv.junerules.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .<br />
The main reason for this spam drop seems to be spamdyke. I&#8217;m sure you have your own opinion about how nice or acceptable it is to run graylisting and reverse DNS checking and all that, but my opinion is that if you have a badly configured mailserver (read: windows zombie machine) you can die in a fire for all I care. Fix your mailserver and then I&#8217;ll accept your mail.<br />
Too bad for the few properly configured mailservers out there that now have to try twice to get through the graylisting&#8230;. then again, it&#8217;s a small price to pay.</p>
<p>Anyway, to get rid of assholes trying to bruteforce their way into my ssh daemon I run <a href="http://www.fail2ban.org/">fail2ban</a>, which lets you try to get in a few times and then blocks your IP for a week. That&#8217;s how much I like them. So I decided to add a new filter to fail2ban, which gets rid of asshole mailservers that will fail their next attempts anyway. Those are the mailservers that spamdyke denies with the following errors:</p>
<ul>
<li><span style="color:#FF00FF">DENIED_RDNS_MISSING</span> &#8211; in other words, the mailserver doesn&#8217;t have a reverse DNS entry. You can&#8217;t be serious, that has to be a zombie.</li>
<li><span style="color:#FF00FF">DENIED_IP_IN_CC_RDNS</span> &#8211; means the mailserver probably has a dynamic IP address from their local ISP. Mostly zombies. Sorry for the 2 mailservers our there that are legitimate that mail like this. I&#8217;ll whitelist you whenever I see complaints.</li>
<li><span style="color:#FF00FF">DENIED_RDNS_RESOLVE</span> &#8211; means the reverse DNS does not resolve to the IP address it connected from. Get lost. However, this one should be used with care, because if the DNS resolver fails for whatever reason spamdyke will also issue this. So make a real good consideration if you want to use this in the fail2ban filter.</li>
</ul>
<p>Since above failures will keep coming back if they retry, I block these asshole servers for a week.<br />
Here&#8217;s my <span style="color:#FFFF00">/etc/fail2ban/filter.d/spamdyke.conf</span>:<br />
<a href="http://notes.benv.junerules.com/wp-content/plugins/download-monitor/download.php?id=spamdyke.conf" title="Downloaded 119 times">Fail2ban spamdyke filter</a> - Version 0.1 - SHA: 1ee23545d87998d0314d2683eb8f2a099cf9fca9</p>
<p>Simply put it in /etc/fail2ban/filter.d and edit <span style="color:#00FFFF">/etc/fail2ban/jail.local</span> and add something like this:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">&#91;</span>spamdyke-rdns<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
enabled &nbsp;= <span style="color: #c20cb9; font-weight: bold;">true</span><br />
filter &nbsp; = spamdyke<br />
action &nbsp; = iptables-allports<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">name</span>=SPAM, <span style="color: #007800;">protocol</span>=all<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
logpath &nbsp;= <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>maillog<br />
maxretry = <span style="color: #000000;">2</span><br />
bantime &nbsp;= <span style="color: #000000;">604800</span></div></div>
<p>Then reload fail2ban:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># fail2ban-client reload</span></div></div>
<p>After enabling it about 12 hours ago, this is the result:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root<span style="color: #000000; font-weight: bold;">@</span>service<span style="color: #666666; font-style: italic;"># fail2ban-client status spamdyke-rdns</span><br />
Status <span style="color: #000000; font-weight: bold;">for</span> the jail: spamdyke-rdns<br />
<span style="color: #000000; font-weight: bold;">|</span>- filter<br />
<span style="color: #000000; font-weight: bold;">|</span> &nbsp;<span style="color: #000000; font-weight: bold;">|</span>- File list: &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>maillog<br />
<span style="color: #000000; font-weight: bold;">|</span> &nbsp;<span style="color: #000000; font-weight: bold;">|</span>- Currently failed: <span style="color: #000000;">72</span><br />
<span style="color: #000000; font-weight: bold;">|</span> &nbsp;<span style="color: #000000; font-weight: bold;">`</span>- Total failed: &nbsp; &nbsp; <span style="color: #000000;">10065</span><br />
<span style="color: #000000; font-weight: bold;">`</span>- action<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span>- Currently banned: <span style="color: #000000;">1987</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span>- <span style="color: #000000; font-weight: bold;">&lt;</span>BenV<span style="color: #000000; font-weight: bold;">&gt;</span> too many to list<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">`</span>- Total banned: &nbsp; &nbsp; <span style="color: #000000;">1987</span></div></div>
<p>Simply amazing. We&#8217;ll end up blocking half the internet. Oh well, it&#8217;s only the bad part of internet anyway.</p>
]]></content:encoded>
			<wfw:commentRss>http://notes.benv.junerules.com/all/software/qmail-spamdyke-and-fail2ban/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Slackware(64), Qmail and IPv6</title>
		<link>http://notes.benv.junerules.com/all/software/slackware64-qmail-and-ipv6/</link>
		<comments>http://notes.benv.junerules.com/all/software/slackware64-qmail-and-ipv6/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 13:34:46 +0000</pubDate>
		<dc:creator>BenV</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[djbdns]]></category>
		<category><![CDATA[ipv6]]></category>
		<category><![CDATA[qmail]]></category>
		<category><![CDATA[slackware]]></category>

		<guid isPermaLink="false">http://notes.benv.junerules.com/?p=485</guid>
		<description><![CDATA[Now that we have Xenbro up and running with a domain attached to it and a bunch of toy domU&#8217;s running, we soon ran into the need for a dns server and mailer. Needless to say I don&#8217;t like the default Sendmail and Bind junk very much (wonder why Slackware still ships it&#8230;), and my [...]]]></description>
			<content:encoded><![CDATA[<p>Now that we have Xenbro up and running with a domain attached to it and a bunch of toy domU&#8217;s running, we soon ran into the need for a dns server and mailer.<br />
Needless to say I don&#8217;t like the default Sendmail and Bind junk very much (wonder why Slackware still ships it&#8230;), and my experiences with Exim and Postfix aren&#8217;t all too great either.<br />
Sure, they work, but they&#8217;re too complex for my liking. I like to know what&#8217;s going on, so I still use my trusty old <a href="http://cr.yp.to/qmail.html">Qmail</a> and <a href="http://cr.yp.to/djbdns.html">Djbdns</a> for mail and dns.<br />
However, since those packages haven&#8217;t been updated in years, some newer features are missing. So I patch them 4 times over and stab them a bit so they work the way I like <img src='http://notes.benv.junerules.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> <span id="more-485"></span></p>
<p>So what things are missing in the vanilla Qmail 1.03 package?</p>
<ul>
<li>IPv6 support</li>
<li>A ton of antispam features like SPF, DomainKeys, MFCHECK, etc</li>
<li>Authentication support</li>
<li>Filter support for stuff like Spamassassin, ClamAV, /dev/null</li>
<li>Virtual domains</li>
</ul>
<p>Probably more, but these are things I care about. Some of these points are not entirely true, for instance you could add filter support by mangling the <span style="color:#FF00FF">.qmail</span> files for all users, but these are things you want centralized so all things have to pass the filter, not for only a few accounts.<br />
In order to fix the missing features I use a few things.<br />
First of all: <a href="http://qmail.jms1.net/patches/combined-details.shtml">John M. Simpson&#8217;s combined patch</a>. This patch fixes more than half of the list. It&#8217;s a collection of smaller patches all rolled together in a nice patch that cleanly applies to qmail 1.0.3 as supplied by D.J. Bernstein. Thanks a lot to Mr Simpson! His pages also have a lot of notes and scripts on how to get qmail up and running, and how to run the services from daemontools. You might want to <a href="http://qmail.jms1.net/scripts/">check them out</a>.<br />
Next, I use <a href="http://www.inter7.com/index.php?page=vpopmail">vpopmail</a> to handle the virtual domains problem. Together with <a href="http://www.inter7.com/index.php?page=qmailadmin">qmailadmin</a> they make the virtual domains thing very easy.</p>
<p>Anyway, that is all old stuff. New stuff is having Qmail working correctly using <span style="color:#FFFF00">IPv6</span>.<br />
It&#8217;s easy to get it up and running, basically just compile qmail as usual and patch <a href="http://cr.yp.to/ucspi-tcp.html">ucspi-tcp</a> using <a href="http://www.fefe.de/ucspi/">Fefe&#8217;s IPv6 patch</a>. Make a few new qmail-smtp services for the IPv6 enabled addressses and go!<br />
While this does work for receiving mail, it fails for a few things in the combined patch &#8211; like SPF checking.<br />
You will run into stuff like:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">@</span>400000004acb39440ca58a8c qmail-smtpd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">28952</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: Received-SPF: unknown <span style="color: #7a0874; font-weight: bold;">&#40;</span>service.xenbro.nl: No IP address <span style="color: #000000; font-weight: bold;">in</span> conversation<span style="color: #7a0874; font-weight: bold;">&#41;</span></div></div>
<p>Obviously this is a lie, but at least it&#8217;s dealt with gracefully. However, you want SPF checking for the IPv6 address!<br />
Fortunately, <a href="http://www.brandonturner.net/blog/2009/08/qmail-ipv6-jms1/">Brandon Turner</a> has patched this with a patch that applies to Qmail 1.0.3 when already patched with John&#8217;s patch. Enough patches for you? <img src='http://notes.benv.junerules.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
After recompiling and restarting your services you will see that it works now. Thanks Brandon! <img src='http://notes.benv.junerules.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">@</span>400000004acb4025340a0b5c qmail-smtpd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">31526</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: Received-SPF: none <span style="color: #7a0874; font-weight: bold;">&#40;</span>service.xenbro.nl: domain at je.moeder.com does not designate permitted sender hosts<span style="color: #7a0874; font-weight: bold;">&#41;</span></div></div>
<p>What does Slackware have to do with this?<br />
Nothing, I just like the way it runs the qmail services :-p</p>
]]></content:encoded>
			<wfw:commentRss>http://notes.benv.junerules.com/all/software/slackware64-qmail-and-ipv6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
