Courier Cygwin

From miki
Revision as of 10:05, 7 November 2008 by Mip (talk | contribs) (→‎Testing)
Jump to navigation Jump to search

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

Prerequisites

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

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 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

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 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

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-authdaemon
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-authdaemon 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/authdaemonrc to enable full debug message:

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

and restart courier-authlib to enable debug logging:

/etc/rc.d/init.d/courier-authdaemon stop
/etc/rc.d/init.d/courier-authdaemon 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

$ cat /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