
<?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>Matt Rude &#187; Dovecot</title>
	<atom:link href="http://mattrude.com/tag/dovecot/feed/" rel="self" type="application/rss+xml" />
	<link>http://mattrude.com</link>
	<description>Matt Rude’s Personal Website</description>
	<lastBuildDate>Thu, 15 Jul 2010 15:34:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1-alpha</generator>
		<item>
		<title>Installing Dovecot with SQLite Support</title>
		<link>http://mattrude.com/2009/12/installing-dovecot-using-sqlite/</link>
		<comments>http://mattrude.com/2009/12/installing-dovecot-using-sqlite/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 18:31:31 +0000</pubDate>
		<dc:creator>Matt Rude</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Dovecot]]></category>
		<category><![CDATA[Postfix]]></category>
		<category><![CDATA[SQLite]]></category>

		<guid isPermaLink="false">http://mattrude.com/?p=1648</guid>
		<description><![CDATA[Following in line with my previous post on Installing Postfix with SQL Support. This post will describe installing Dovecot from source with full SQLite support. Installing from Source First start out by downloading the lastest version from Dovecot&#8217;s website (the current version as of the writing of the how-to is 1.2.8). yum -y install sqlite sqlite-devel gcc make patch db4-devel cyrus-sasl-devel Next download and untar the source code. wget http://dovecot.org/releases/1.2/dovecot-1.2.8.tar.gz tar -xzf dovecot-1.2.8.tar.gz cd dovecot-1.2.8/ Next, you will need to...


<h3>Related Posts</h3>
<ol>
		<li><a href="http://mattrude.com/2009/09/installing-postfix-with-sqlite-support/" rel="bookmark">Installing Postfix with SQLite Support</a><!-- (45.3179)--></li>
		<li><a href="http://mattrude.com/2010/01/converting-a-mediawiki-database-from-mysql-to-sqlite/" rel="bookmark">Converting a MediaWiki database from MySQL to SQLite</a><!-- (15.6358)--></li>
		<li><a href="http://mattrude.com/2009/06/creating-self-signed-ssl-certificates-for-dovecot-postfix/" rel="bookmark">Creating Self-signed SSL Certificates for Dovecot &#038; Postfix</a><!-- (11.9806)--></li>
		<li><a href="http://mattrude.com/2009/09/postfix-remap-from-addresses-with-a-generic-map/" rel="bookmark">Postfix: remap from addresses with a generic map</a><!-- (9.5386)--></li>
		<li><a href="http://mattrude.com/2009/05/postfix-reject-an-address-before-queue/" rel="bookmark">Postfix: reject an address before queue</a><!-- (9.46202)--></li>
	</ol>
]]></description>
			<content:encoded><![CDATA[<p>Following in line with my previous post on <a href="http://mattrude.com/2009/09/installing-postfix-with-sqlite-support/" target="_blank">Installing Postfix with SQL Support</a>. This post will describe installing <a href="http://www.dovecot.org" target="_blank">Dovecot</a> from source with full <a href="http://www.sqlite.org" target="_blank">SQLite</a> support.</p>
<h3>Installing from Source</h3>
<p>First start out by downloading the lastest version from Dovecot&#8217;s website (the current version as of the writing of the how-to is 1.2.8).</p>
<pre>yum -y install sqlite sqlite-devel gcc make patch db4-devel cyrus-sasl-devel</pre>
<p>Next download and untar the source code.</p>
<pre>wget http://dovecot.org/releases/1.2/dovecot-1.2.8.tar.gz
tar -xzf dovecot-1.2.8.tar.gz
cd dovecot-1.2.8/</pre>
<p>Next, you will need to configure the code before compiling.</p>
<pre>./configure --with-sqlite
echo $?</pre>
<p>Assuming the configure command finishes with out error (the last line should be a &#8220;0&#8243;). Compile and install Dovecot.</p>
<pre>make &amp;&amp; make install</pre>
<h3>Configuring Dovecot for SQLite</h3>
<p>First we need to create or modify the dovecot config file for SQLite access.  If you are currenly using MySQL with Dovecot, switching to SQLite is pretty easy and strate forward.  Or you may just use the below dovecot config file.</p>
<pre>### Dovecot configuration file ###
### /etc/dovecot.conf ###
protocols = pop3 imap
login_user = postfix
auth_cache_size = 128
auth_cache_ttl = 600
mail_debug = yes

mail_location = maildir:%h/

protocol imap {
 listen = *:143
}

protocol lda {
  postmaster_address = postmaster@mattrude.com
  hostname = odin.mattrude.com
  mail_plugin_dir = /usr/local/lib/dovecot/lda
  auth_socket_path = /var/run/dovecot/auth-master
}

auth default {
  mechanisms = plain login
  userdb sql {
    args = /etc/dovecot-sqlite.conf
  }
  passdb sql {
    args = /etc/dovecot-sqlite.conf
  }
  socket listen {
    master {
      path = /var/run/dovecot/auth-master
      user = virtualmail
      group = virtualmail
    }
    client {
      path = /var/spool/postfix/private/auth
      mode = 0660
      user = postfix
      group = postfix
    }
  }
}</pre>
<p>After you have created the main Dovecot config file, you will need to add the SQLite config file (below).</p>
<pre>### /etc/dovecot-sqlite.conf ###
driver = sqlite
connect = /etc/postfix/postfix.sqlite
password_query = SELECT password, username AS user \
  FROM mailbox WHERE username = '%u' AND domain = '%d'
user_query = SELECT maildir, 1000 AS uid, 1000 AS gid FROM mailbox WHERE \
  username = '%u' AND domain = '%d' AND active = '1'</pre>
<p>After the config files have been created, we need to create the database file, here is where you will need SQLite installed on the system.</p>
<h3>Building the SQLite Database</h3>
<p>In order to use the SQLite function, you need a SQLite database.  First using SQLite3 run</p>
<pre>sqlite3 /etc/postfix/postfix.sqlite</pre>
<p>To create the database, then you can copy and past the following scheme into the new database.</p>
<pre>CREATE TABLE alias (
  address varchar(255) NOT NULL,
  goto text NOT NULL,
  domain varchar(255) NOT NULL,
  created datetime NOT NULL default '0000-00-00 00:00:00',
  modified datetime NOT NULL default '0000-00-00 00:00:00',
  active tinyint(1) NOT NULL default '1');

CREATE TABLE domain (
  domain varchar(255) NOT NULL,
  description varchar(255) NOT NULL,
  aliases int(10) NOT NULL default '0',
  mailboxes int(10) NOT NULL default '0',
  maxquota bigint(20) NOT NULL default '0',
  quota bigint(20) NOT NULL default '0',
  transport varchar(255) NOT NULL,
  backupmx tinyint(1) NOT NULL default '0',
  created datetime NOT NULL default '0000-00-00 00:00:00',
  modified datetime NOT NULL default '0000-00-00 00:00:00',
  active tinyint(1) NOT NULL default '1' );

CREATE TABLE mailbox (
  username varchar(255) NOT NULL,
  password varchar(255) NOT NULL,
  name varchar(255) NOT NULL,
  maildir varchar(255) NOT NULL,
  quota bigint(20) NOT NULL default '0',
  domain varchar(255) NOT NULL,
  created datetime NOT NULL default '0000-00-00 00:00:00',
  modified datetime NOT NULL default '0000-00-00 00:00:00',
  active tinyint(1) NOT NULL default '1',
  local_part varchar(255) NOT NULL );</pre>
<p>Then close the database</p>
<pre>.quit</pre>
<p>Or you may download mine from below and use the same scheme work.</p>
<ul>
<li> <a title="Postfix.sqlite" href="http://wiki.mattrude.com/images/1/15/Postfix.sqlite">postfix.sqlite</a></li>
</ul>
<pre>mkdir /var/run/dovecot</pre>
<h3>Dovecot INIT file</h3>
<pre>#!/bin/bash
#
#	/etc/rc.d/init.d/dovecot
#
# Starts the dovecot daemon
#
# chkconfig: - 65 35
# description: Dovecot Imap Server
# processname: dovecot
# Source function library.
. /etc/init.d/functions

test -x /usr/local/sbin/dovecot || exit 0

RETVAL=0
prog="Dovecot Imap"

start() {
       echo -n $"Starting $prog: "
	daemon /usr/local/sbin/dovecot
	RETVAL=$?
	[ $RETVAL -eq 0 ] &amp;&amp; touch /var/lock/subsys/dovecot
	echo
}

stop() {
	echo -n $"Stopping $prog: "
	killproc /usr/local/sbin/dovecot
	RETVAL=$?
	[ $RETVAL -eq 0 ] &amp;&amp; rm -f /var/lock/subsys/dovecot
	echo
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  reload|restart)
	stop
	start
	RETVAL=$?
	;;
  condrestart)
	if [ -f /var/lock/subsys/dovecot ]; then
	    stop
	    start
	fi
	;;
  status)
	status /usr/local/sbin/dovecot
	RETVAL=$?
	;;
  *)
	echo $"Usage: $0 {condrestart|start|stop|restart|reload|status}"
	exit 1
esac

exit $RETVAL</pre>


<br />
<h3>Related Posts</h3>
<ol>
		<li><a href="http://mattrude.com/2009/09/installing-postfix-with-sqlite-support/" rel="bookmark">Installing Postfix with SQLite Support</a><!-- (45.3179)--></li>
		<li><a href="http://mattrude.com/2010/01/converting-a-mediawiki-database-from-mysql-to-sqlite/" rel="bookmark">Converting a MediaWiki database from MySQL to SQLite</a><!-- (15.6358)--></li>
		<li><a href="http://mattrude.com/2009/06/creating-self-signed-ssl-certificates-for-dovecot-postfix/" rel="bookmark">Creating Self-signed SSL Certificates for Dovecot &#038; Postfix</a><!-- (11.9806)--></li>
		<li><a href="http://mattrude.com/2009/09/postfix-remap-from-addresses-with-a-generic-map/" rel="bookmark">Postfix: remap from addresses with a generic map</a><!-- (9.5386)--></li>
		<li><a href="http://mattrude.com/2009/05/postfix-reject-an-address-before-queue/" rel="bookmark">Postfix: reject an address before queue</a><!-- (9.46202)--></li>
	</ol>
]]></content:encoded>
			<wfw:commentRss>http://mattrude.com/2009/12/installing-dovecot-using-sqlite/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Creating Self-signed SSL Certificates for Dovecot &amp; Postfix</title>
		<link>http://mattrude.com/2009/06/creating-self-signed-ssl-certificates-for-dovecot-postfix/</link>
		<comments>http://mattrude.com/2009/06/creating-self-signed-ssl-certificates-for-dovecot-postfix/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 14:42:39 +0000</pubDate>
		<dc:creator>Matt Rude</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Dovecot]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Postfix]]></category>

		<guid isPermaLink="false">http://www.mattrude.com/?p=262</guid>
		<description><![CDATA[Self-signed SSL certificates are the easiest way to get your SSL server working. However unless you take some action to prevent it, this is at the cost of security: The first time the client connects to the server, it sees the certificate and asks the user whether to trust it. The user of course doesn&#8217;t really bother verifying the certificate&#8217;s fingerprint, so a man-in-the-middle attack can easily bypass all the SSL security, steal the user&#8217;s password and so on. If...


<h3>Related Posts</h3>
<ol>
		<li><a href="http://mattrude.com/2009/12/installing-dovecot-using-sqlite/" rel="bookmark">Installing Dovecot with SQLite Support</a><!-- (11.0738)--></li>
		<li><a href="http://mattrude.com/2009/09/installing-postfix-with-sqlite-support/" rel="bookmark">Installing Postfix with SQLite Support</a><!-- (10.1052)--></li>
		<li><a href="http://mattrude.com/2009/07/creating-a-secure-git-repository-server/" rel="bookmark">Creating a secure Git repository server</a><!-- (9.09548)--></li>
		<li><a href="http://mattrude.com/2009/09/postfix-remap-from-addresses-with-a-generic-map/" rel="bookmark">Postfix: remap from addresses with a generic map</a><!-- (7.15023)--></li>
		<li><a href="http://mattrude.com/2010/03/installing-the-git-daemon-for-read-only-access-to-repoistory/" rel="bookmark">Installing the GIT Daemon for Read Only Access to Repoistory</a><!-- (6.56282)--></li>
	</ol>
]]></description>
			<content:encoded><![CDATA[<p>Self-signed <a title="Openssl" href="http://wiki.mattrude.com/index.php/Openssl">SSL</a> certificates are the easiest way to get your SSL server working. However unless you take some action to prevent it, this is at the cost of security:</p>
<ul>
<li> The first time the client connects to the server, it sees the certificate and asks the user whether to trust it. The user of course doesn&#8217;t really bother verifying the certificate&#8217;s fingerprint, so a man-in-the-middle attack can easily bypass all the SSL security, steal the user&#8217;s password and so on.</li>
<li> If the client was lucky enough not to get attacked the first time it connected, the following connections will be secure as long as the client had permanently saved the certificate. Some clients do this, while others have to be manually configured to accept the certificate.</li>
</ul>
<p>The only way to be fully secure is to import the SSL certificate to client&#8217;s (or operating system&#8217;s) list of trusted CA certificates prior to first connection. See <a title="http://wiki.dovecot.org/SSL/CertificateClientImporting" rel="nofollow" href="http://wiki.dovecot.org/SSL/CertificateClientImporting">SSL/CertificateClientImporting</a> how to do it for different clients.</p>
<h4>Building Dovcot&#8217;s Self-Signed Certificates</h4>
<p>Dovecot includes a script to build self-signed SSL certificates using OpenSSL. First you need to find the <strong>dovecot-openssl.cnf</strong> file.</p>
<ul>
<li><strong>Configuring the Certificate Config File</strong></li>
</ul>
<p>The best way on <a title="Fedora" href="http://wiki.mattrude.com/index.php/Fedora">Fedora</a> to do this is via the <strong>locate</strong> command.</p>
<pre>locate dovecot-openssl.cnf</pre>
<p>Mine was located at <strong>/etc/pki/dovecot/dovecot-openssl.cnf</strong>. Now that you have found the file you need to add your server information to it, like this:</p>
<pre>[ req ]
default_bits = 1024
encrypt_key = yes
distinguished_name = req_dn
x509_extensions = cert_type
prompt = no

[ req_dn ]
# country (2 letter code)
C=US

# State or Province Name (full name)
ST=MN

# Locality Name (eg. city)
L=SaintPaul

# Organization (eg. company)
O=example.com

# Organizational Unit Name (eg. section)
OU=IMAP server

# Common Name (*.example.com is also possible)
CN=*.example.com

# E-mail contact
emailAddress=postmaster@example.com

[ cert_type ]
nsCertType = server</pre>
<ul>
<li><strong>Build the Certificates</strong></li>
</ul>
<pre>/usr/libexec/dovecot/mkcert.sh</pre>
<ul>
<li><strong>Modifying Dovecot</strong></li>
</ul>
<p>You will need to add the following to your <strong>/etc/dovecot.conf</strong> file:</p>
<pre>ssl_listen = 993
ssl_disable = no
ssl_cert_file = /etc/postfix/smtpd.pem
ssl_key_file = /etc/postfix/smtpd.pem
auth_cache_size = 128</pre>
<p>Then restart Dovecot</p>
<pre>/sbin/service dovecot restart</pre>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 1014px; width: 1px; height: 1px;">
<pre>gutter='0'</pre>
</div>


<br />
<h3>Related Posts</h3>
<ol>
		<li><a href="http://mattrude.com/2009/12/installing-dovecot-using-sqlite/" rel="bookmark">Installing Dovecot with SQLite Support</a><!-- (11.0738)--></li>
		<li><a href="http://mattrude.com/2009/09/installing-postfix-with-sqlite-support/" rel="bookmark">Installing Postfix with SQLite Support</a><!-- (10.1052)--></li>
		<li><a href="http://mattrude.com/2009/07/creating-a-secure-git-repository-server/" rel="bookmark">Creating a secure Git repository server</a><!-- (9.09548)--></li>
		<li><a href="http://mattrude.com/2009/09/postfix-remap-from-addresses-with-a-generic-map/" rel="bookmark">Postfix: remap from addresses with a generic map</a><!-- (7.15023)--></li>
		<li><a href="http://mattrude.com/2010/03/installing-the-git-daemon-for-read-only-access-to-repoistory/" rel="bookmark">Installing the GIT Daemon for Read Only Access to Repoistory</a><!-- (6.56282)--></li>
	</ol>
]]></content:encoded>
			<wfw:commentRss>http://mattrude.com/2009/06/creating-self-signed-ssl-certificates-for-dovecot-postfix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
