IMAP: Difference between revisions

From miki
Jump to navigation Jump to search
No edit summary
Line 56: Line 56:
* <tt>inetutils</tt>
* <tt>inetutils</tt>
* <tt>cygrunsrv</tt>
* <tt>cygrunsrv</tt>
* <tt>psmisc</tt>


==== Install courier-authlib ====
==== Install courier-authlib ====
Line 127: Line 128:
# The number of daemon processes that are started.
# The number of daemon processes that are started.
daemons=3
daemons=3
# DEBUG_LOGIN=2 - turn on debugging + log passwords too
DEBUG_LOGIN=2
</pre>
</pre>


Line 159: Line 157:
IMAP_ULIMITD=2097152 #Set same value as returned by 'ulimit -v' or imapd.rc will complain
IMAP_ULIMITD=2097152 #Set same value as returned by 'ulimit -v' or imapd.rc will complain
</pre>
</pre>

Create link to authlib and imap daemon in <tt>/etc/rc.d/init.d</tt>
<source lang="bash">
ln -s /usr/local/sbin/authdaemond /etc/rc.d/init.d/courier-authlib
ln -s /usr/lib/courier-imap/libexec/imapd.rc /etc/rc.d/init.d/courier-imap
</source>


==== Running ====
==== Running ====


Start authlib and imap daemon:
Configure '''syslogd''' for capturing system message from '''courier-authlib'''

<source lang="bash">
/etc/rc.d/init.d/courier-authlib start
/etc/rc.d/init.d/courier-imap start
</source>

==== Testing ====

If not done yet, configure '''syslogd''' for capturing system message from '''courier-authlib'''


<source lang="bash">
<source lang="bash">
Line 169: Line 182:
</source>
</source>


Edit courier-authlib configuration file <tt>/usr/local/etc/authlib/authdaemonrc</tt>to enable full debug message:
Start authlib and imap daemon:

<pre>
# DEBUG_LOGIN=2 - turn on debugging + log passwords too
DEBUG_LOGIN=2
</pre>

and restart ''authdaemond'' to enable debug logging:


<source lang="bash">
<source lang="bash">
/etc/rc.d/init.d/courier-authlib stop
authdaemond start
/usr/lib/courier-imap/libexec/imapd.rc start
/etc/rc.d/init.d/courier-authlib start
</source>
</source>


Testing authlib (replace <tt>CCCCCC</tt> with your password:
==== Testing ====

Testing authlib:
<pre>
<pre>
$ export PATH=$PATH:/usr/local/lib/bin #because authtest needs a library there (strace authtest
$ export PATH=$PATH:/usr/local/lib/bin #because authtest needs a library there (strace authtest
$ authtest username CCCCCC
$ authtest username CCCCCC
</pre>

Output must be similar to
Output must be similar to
<pre>
<pre>
Line 207: Line 227:
003 LOGOUT
003 LOGOUT
</pre>
</pre>
Server must reply with OK messages (and additionally more information)


When testing is done, don't forget to reset debugging in <tt>/usr/local/etc/authlib/authdaemonrc</tt>:
'''TO DO:'''
<pre>
# Use SYSTEM instead of my user account for configure authlib
# DEBUG_LOGIN=2 - turn on debugging + log passwords too
DEBUG_LOGIN=0
</pre>


====Install as a service====
'''File location''':
TBC
/usr/local/bin
/usr/local/sbin
/usr/lib/courier-imap
/usr/local/etc/authlib


=== Configuration ===
====File location====
* /usr/local/bin
* Configuration file:
* /usr/local/sbin
** <tt>/etc/courier/</tt>
* /usr/lib/courier-imap
* /usr/local/etc/authlib

Revision as of 23:17, 6 November 2008

IMAP servers

There are basically three main IMAP server solutions:

UW IMAP
IMAP server developped by the University of Washington. Uses a proprietory mailbox format mbx, which is more or less a binary version of the usual mailbox format. A binary package exists on cygwin, but it regularly suffers from locking problems. A patch exists to use maildir format though, but patch seems outdated.
Courier IMAP
Courier-IMAP is a fast, scalable, enterprise IMAP server that uses Maildirs.
Cyrus IMAP
Developped by Carnegie Mellon. Also uses a private mailbox format.

Courier IMAP

References

Courier IMAP on openSUSE

Binary package for Courier IMAP is available on openSUSE (package courier-authlib and courier-imap). However it conflicts with the default IMAP server, (UW IMAP), which must first be uninstalled.

Courier IMAP on Cygwin

There is no binary package for Cygwin. And building Courier IMAP on that platform is a true pain in the neck, if not something else. 2 packages must be built: courier-authlib and courier-imap. Some links I found on Internet:

In summary, this is the furthest I went:

# First, installed these packages in Cygwin: gdbm, libgdbm-devel, minires-devel, libgdbm, libgdbm3, libtool
tar -xvjf courier-authlib-0.61.0.tar.bz2
cd courier-authlib-0.61.0
# Fix Makefile that builds makedatprog
sed -i 's/noinst_PROGRAMS = @makedatprog_target@/noinst_PROGRAMS = @makedatprog_target@$(EXEEXT)/' makedat/Makefile.in
./configure --with-mailuser=SYSTEM --with-mailgroup=SYSTEM --with-db=gdbm
make
# ... ERRORS!

But... Thierry succeeded in compiling and installing Courier-IMAP and Courier-authlib on Cywing. He has detailed the complete procedure on [Yobi Wiki]. Here the exact steps I applied myself

Cygwin Packages

Install required Cygwin packages (run Cygwin's setup.exe):

  • patch, tar, make, gcc
  • crypt
  • libgdbm-devel
  • libtool
  • inetutils
  • cygrunsrv
  • psmisc

Install courier-authlib

untar courier-authlib

tar -xvjf courier-authlib-0.61.0.tar.bz2
cd courier-authlib-0.61.0

Apply this patch:

patch -Np1 <../courier-authlib-0.61.0-cygwin.patch

Configure (replace mailuser with an user name from /etc/passwd - I used my own username as suggested), build, check and install.

./configure --disable-root-check --with-waitfunc=wait --without-authpam --without-authldap --without-authpwd \
--without-authshadow --without-authcustom --without-authpipe --without-authmysql --without-authpgsql --with-mailuser=mailuser \
--with-mailgroup=mkgroup-l-d
make
make check
make install

Install courier-imap

Building and installing courier-imap

untar courier-imap

tar -xvjf courier-imap-4.4.1.tar.bz2
cd courier-imap-4.4.1

Apply this patch:

patch -Np1 <../courier-imap-4.4.1-cygwin.patch

Configure, build, check and install.

./configure --disable-root-check --with-waitfunc=wait
make
make install
make install-configure

Configuration

If not present yet, add /usr/local/bin and /usr/local/sbin to your path (ideally in /etc/bash.bashrc):

PATH=/usr/local/bin:/usr/local/sbin:$PATH

Create courier-authlib configuration file,

cp /usr/local/etc/authlib/authdaemonrc.dist /usr/local/etc/authlib/authdaemonrc

and edit its content as follows:

# The number of daemon processes that are started.
daemons=3

Create user mailbox (replace username with user account name). Repeat for all users:

mkdir -p /home/username                          #if don't exist yet...
cd /home/username
for i in "" .Drafts .Sent .Trash .Templates; do /usr/lib/courier-imap/bin/maildirmake ~username/MailDir/$i; done
# Create also default Maildir for new users
for i in "" .Drafts .Sent .Trash .Templates; do /usr/lib/courier-imap/bin/maildirmake /etc/skel/MailDir/$i; done

Create user authentication database:

touch /usr/local/etc/authlib/userdb
chmod 700 /usr/local/etc/authlib/userdb
#Repeat for each username:
pw2userdb | grep "^username">>/usr/local/etc/authlib/userdb   # Fill userdb from /etc/passwd user entry
userdb username set mail=~username/MailDir                    # Specify user MailDir location
userdbpw | userdb username set systempw                       # Set user account password
...
makeuserdb                                                    # Create binary database

Edit the file /usr/lib/courier-imap/etc/imapd:

ADDRESS=127.0.0.1                    #Typ. use 0 or 127.0.0.1
...
IMAP_ULIMITD=2097152                 #Set same value as returned by 'ulimit -v' or imapd.rc will complain

Create link to authlib and imap daemon in /etc/rc.d/init.d

ln -s /usr/local/sbin/authdaemond /etc/rc.d/init.d/courier-authlib
ln -s /usr/lib/courier-imap/libexec/imapd.rc /etc/rc.d/init.d/courier-imap

Running

Start authlib and imap daemon:

/etc/rc.d/init.d/courier-authlib start
/etc/rc.d/init.d/courier-imap start

Testing

If not done yet, configure syslogd for capturing system message from courier-authlib

syslogd-config                   #if not configured yet
net start syslogd                #if not started yet

Edit courier-authlib configuration file /usr/local/etc/authlib/authdaemonrcto enable full debug message:

# DEBUG_LOGIN=2   - turn on debugging + log passwords too
DEBUG_LOGIN=2

and restart authdaemond to enable debug logging:

/etc/rc.d/init.d/courier-authlib stop
/etc/rc.d/init.d/courier-authlib start

Testing authlib (replace CCCCCC with your password:

$ export PATH=$PATH:/usr/local/lib/bin               #because authtest needs a library there (strace authtest
$ authtest username CCCCCC

Output must be similar to

Authentication succeeded.

     Authenticated: username  (uid 1001, gid 10545)
    Home Directory: /home/username
           Maildir: /home/username/Maildir
             Quota: (none)
Encrypted Password: XXXXXX
Cleartext Password: CCCCCC
           Options: (none)

Check everything is fine in /var/log/messages

Testing courier-imap:

$ telnet localhost 143

Type the following commands

001 LOGIN username password
002 EXAMINE INBOX
003 LOGOUT

Server must reply with OK messages (and additionally more information)

When testing is done, don't forget to reset debugging in /usr/local/etc/authlib/authdaemonrc:

# DEBUG_LOGIN=2   - turn on debugging + log passwords too
DEBUG_LOGIN=0

Install as a service

TBC

File location

  • /usr/local/bin
  • /usr/local/sbin
  • /usr/lib/courier-imap
  • /usr/local/etc/authlib