Difference between revisions of "Courier-Cygwin"
Line 273: | Line 273: | ||
+ | <source lang=bash> |
||
⚫ | |||
+ | #! /bin/sh |
||
− | # This will open a dialog box to complain about DLL. |
||
+ | # |
||
− | $ export PATH=$PATH:/usr/local/lib/bin |
||
+ | # Courier imap daemon startup script. |
||
− | $ /usr/local/sbin/authtest ausername |
||
+ | |||
⚫ | |||
+ | imapd=/usr/lib/courier-imap/libexec/imapd.rc |
||
+ | |||
+ | test ! -f $authlib && echo "File not found: $authlib" && exit 1; |
||
+ | test ! -f $imapd && echo "File not found: $imapd" && exit 1; |
||
+ | |||
+ | case $1 in |
||
+ | start) |
||
+ | $authlib start |
||
+ | $imapd start |
||
+ | ;; |
||
+ | stop) |
||
+ | $imapd stop |
||
+ | $authlib stop |
||
+ | ;; |
||
+ | *) |
||
+ | echo "Usage: $0 <start|stop>" |
||
+ | ;; |
||
+ | esac |
||
+ | </source> |
||
==Testing authlib== |
==Testing authlib== |
Revision as of 10:31, 26 October 2008
Courier-IMAP
Courier-IMAP requires the installation of the Courier Authentication Library and the following cygwin tools and packages
- patch, tar, make, gcc
- crypt
- libgdbm-devel
- libtool (version 1.5.27a-1)
- inetutils
- cygrunsrv
Run the Cygwin setup program. Locate, select and install the required packages.
Courier Authentication Library
Download and untar courier-authlib in your favorite sandbox. Version used: 0.61.0
Apply the [{{#file:courrier-authlib-0.61.0-cygwin.patch}} patch] before configuration to correct following issues:
- incorrect usage of EXEEXT in makedat/Makefile
- add libtool flag (-no-undefined) required for DLL creation
- add missing dependencies
- add PATH in start script to access new DLL (installed in a different directory)
Solution source: http://lists.cairographics.org/archives/cairo/2004-April/001125.html
--- courier-authlib-0.61.0/makedat/Makefile.in 2008-05-24 16:21:09.000000000 +0200
+++ courier-authlib-0.61.0-cygwin/makedat/Makefile.in 2008-10-21 16:02:38.709166700 +0200
@@ -182,7 +182,7 @@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
-makedatprog_target = @makedatprog_target@
+makedatprog_target = @makedatprog_target@$(EXEEXT)
makedatprogpath = @makedatprogpath@
mandir = @mandir@
mkdir_p = @mkdir_p@
@@ -198,7 +198,7 @@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-noinst_PROGRAMS = @makedatprog_target@
+noinst_PROGRAMS = @makedatprog_target@$(EXEEXT)
makedatprog_SOURCES = makedatprog.c
makedatprog_DEPENDENCIES = @dblibrary@
makedatprog_LDADD = @dblibrary@
--- courier-authlib-0.61.0/Makefile.in 2008-07-12 21:41:08.000000000 +0200
+++ courier-authlib-0.61.0-cygwin/Makefile.in 2008-10-23 22:59:03.843750000 +0200
@@ -213,9 +213,10 @@
LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-CCLD = $(CC)
+CCLD = $(CC) -no-undefined
+CCLDEXE = $(CC)
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
- --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ --mode=link $(CCLDEXE) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(libauthcustom_la_SOURCES) $(libauthldap_la_SOURCES) \
$(libauthmysql_la_SOURCES) $(libauthpam_la_SOURCES) \
@@ -452,9 +453,9 @@
README.authdebug.html
DISTCLEANFILES = dbobj.config README_authlib.html
-commonlibdep = libcourierauthcommon.la
+commonlibdep = libcourierauthcommon.la libcourierauth.la
commonldflags = -module -rpath $(pkglibdir) -export-symbols-regex 'courier_auth.*_init' -avoid-version
-commonlibadd = libcourierauthcommon.la
+commonlibadd = libcourierauthcommon.la libcourierauth.la
libcourierauthcommon_t = @CRYPTLIBS@
libcourierauthcommon_la_SOURCES = \
auth.h courierauth.h \
--- courier-authlib-0.61.0/authdaemond.in 2005-07-05 14:25:08.000000000 +0200
+++ courier-authlib-0.61.0-cygwin/authdaemond.in 2008-10-25 12:03:32.140625000 +0200
@@ -15,4 +15,10 @@
set -a
. @authdaemonrc@
+# Some shared libraries (DLL) are installed in @libdir@/bin
+# instead of @libdir@/@PACKAGE@
+# Setting LD_LIBRARY_PATH at runtime or LR_RUN_PATH at linktime doesn't
+# work in cygwin, only setting PATH works.
+export PATH=$PATH:@libdir@/bin
+
exec ${sbindir}/courierlogger -pid=@authdaemonvar@/pid $LOGGEROPTS -$1 @libexecdir@/courier-authlib/authdaemond
Install the patch
$ patch -Np1 < courrier-authlib-0.61.0-cygwin.patch
Configure the package without most authentication modules, keeping only userdb.
Note: replace mailuser by an existing user name (in your /etc/passwd file). I used my own username.
$ ./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
Take a long pause... and when ready execute the following command.
$ make
Take again a long pause... then check the result and install the libraries
$ make check $ make install
Compilation and installation
Download and untar package courier-imap in your favorite sandbox. Version used: 4.4.1.20080920
Apply the [{{#file:courrier-imap-4.4.1-cygwin.patch}} patch] before configuration to correct following issues:
- incorrect usage of EXEEXT in makedat/Makefile
- incorrect usage of EXTEXT in main Makefile
- remove usage of /usr/lib/env in start/stop script (/usr/lib/env does not seem to work under Cygwin)
--- courier-imap-4.4.1.20080920/makedat/Makefile.in 2008-08-24 19:52:51.000000000 +0200
+++ courier-imap-4.4.1.20080920-cygwin/makedat/Makefile.in 2008-10-21 20:43:27.500000000 +0200
@@ -182,7 +182,7 @@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
-makedatprog_target = @makedatprog_target@
+makedatprog_target = @makedatprog_target@$(EXEEXT)
makedatprogpath = @makedatprogpath@
mandir = @mandir@
mkdir_p = @mkdir_p@
@@ -198,7 +198,7 @@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-noinst_PROGRAMS = @makedatprog_target@
+noinst_PROGRAMS = @makedatprog_target@$(EXEEXT)
makedatprog_SOURCES = makedatprog.c
makedatprog_DEPENDENCIES = @dblibrary@
makedatprog_LDADD = @dblibrary@
--- courier-imap-4.4.1.20080920/Makefile.in 2008-09-20 14:48:46.000000000 +0200
+++ courier-imap-4.4.1.20080920-cygwin/Makefile.in 2008-10-21 20:59:45.156250000 +0200
@@ -247,9 +247,9 @@
CLEANFILES = $(databin_SCRIPTS) $(man_MANS) $(sysconf_DATA) $(sbin_SCRIPTS)
databindir = $(datadir)
databin_SCRIPTS = mkimapdcert mkpop3dcert
-binPROGRAMS = imapd pop3d maildirmake maildiracl deliverquota maildirkw
-sbinPROGRAMS = imaplogin pop3login
-libexecPROGRAMS = makedatprog couriertcpd
+binPROGRAMS = imapd$(EXEEXT) pop3d$(EXEEXT) maildirmake$(EXEEXT) maildiracl$(EXEEXT) deliverquota$(EXEEXT) maildirkw$(EXEEXT)
+sbinPROGRAMS = imaplogin$(EXEEXT) pop3login$(EXEEXT)
+libexecPROGRAMS = makedatprog$(EXEEXT) couriertcpd$(EXEEXT)
bin_PROGRAMS = @binPROGRAMS_exec@
sbin_PROGRAMS = @sbinPROGRAMS_exec@
libexec_PROGRAMS = @libexecPROGRAMS_exec@
--- courier-imap-4.4.1.20080920/imapd.rc.in 2008-05-04 15:12:47.000000000 +0200
+++ courier-imap-4.4.1.20080920-cygwin/imapd.rc.in 2008-10-21 23:00:30.781250000 +0200
@@ -35,7 +35,7 @@
umask $IMAP_UMASK
@ULIMIT@ $IMAP_ULIMITD
- @SETENV@ -i @SHELL@ -c " set -a ;
+ @SHELL@ -c " set -a ;
prefix=@prefix@ ;
exec_prefix=@exec_prefix@ ;
bindir=@bindir@ ;
--- courier-imap-4.4.1.20080920/pop3d.rc.in 2008-05-04 15:12:47.000000000 +0200
+++ courier-imap-4.4.1.20080920-cygwin/pop3d.rc.in 2008-10-21 23:00:49.875000000 +0200
@@ -27,7 +27,7 @@
case $1 in
start)
- @SETENV@ -i @SHELL@ -c " set -a ;
+ @SHELL@ -c " set -a ;
prefix=@prefix@ ;
exec_prefix=@exec_prefix@ ;
bindir=@bindir@ ;
Install the patch
$ patch -Np1 < courrier-imap-4.4.1-cygwin.patch
Configure the package
$ ./configure --disable-root-check --with-waitfunc=wait
Take a walk... and when ready execute the following command to build the package.
$ make
Time to go for some coffee... and then install the package with the usual
$ make install $ make install-configure
Configuration
Setup courier-imap: $prefix/etc/imapd (where $prefix=/usr/lib/courier-imap)
Set ADDRESS to a valid value (0 or 127.0.0.1) and change IMAP_ULIMITD to a value accepted by the command ulimit. I simply used the existing value returned by
$ ulimit -v
Setup authdaemon: /usr/local/etc/authlib/authdaemonrc. Create authdaemonrc file
$ cp /usr/local/etc/authlib/authdaemonrc.dist /usr/local/etc/authlib/authdaemonrc
Change number of daemons (I use only one) and enable DEBUG_LOGIN
# The number of daemon processes that are started.
daemons=1
# DEBUG_LOGIN=2 - turn on debugging + log passwords too
DEBUG_LOGIN=2
IMAP accounts
User accounts and settings are managed by userdb. See makeuserdb man page for details, or used the freshly new install man page - man makeuserdb
Assuming username is your username, 1001 and 10545 are respectively the UID and GID of an existing user (part of your /etc/passwd and /etc/group). I use my own UID and GID. Create the mailuser home directory, if required. Create Maildir folder.
$ mkdir -p /home/username $ cd /home/username $ /usr/lib/courier-imap/bin/maildirmake Maildir
Create the userdb text file /usr/local/etc/authlib/userdb
$ touch /usr/local/etc/authlib/userdb $ chmod 700 /usr/local/etc/authlib/userdb
Edit /usr/local/etc/authlib/userdb, one line per account
username[TAB]uid=1001|gid=10111|home=/home/username|mail=/home/username/Maildir|systempw=XXXXXX
where XXXXXX is the encrypted password created with
$ /usr/local/sbin/userdbpw.exe
Create the (binary) userdb
$ /usr/local/sbin/makeuserdb
You should now have the following files created:
- /usr/local/etc/authlib/userdb.dat
- /usr/local/etc/authlib/userdbshadow.dat
Running
Install and configure syslogd. Run the Cygwin setup program. Locate, select and install inetutils (contains syslogd). Configure syslogd with the following command. It will create the /etc/syslogd.conf file and install a windows service using cygrunsrv
$ syslogd-config
Start the authlib and imap daemons with the following command:
$ /usr/local/sbin/authdaemon start $ /usr/lib/courier-imap/libexec/imapd.rc start
Stop the daemons with the following command:
$ /usr/lib/courier-imap/libexec/imapd.rc stop $ /usr/local/sbin/authdaemon stop
You'll find log messages in /var/log/messages (default target file as specified in /etc/syslogd.conf)
#! /bin/sh
#
# Courier imap daemon startup script.
authlib=/usr/local/sbin/authdaemond
imapd=/usr/lib/courier-imap/libexec/imapd.rc
test ! -f $authlib && echo "File not found: $authlib" && exit 1;
test ! -f $imapd && echo "File not found: $imapd" && exit 1;
case $1 in
start)
$authlib start
$imapd start
;;
stop)
$imapd stop
$authlib stop
;;
*)
echo "Usage: $0 <start|stop>"
;;
esac
Testing authlib
$ /usr/local/sbin/authtest username CCCCCC Authentication succeeded. Authenticated: username (uid 1001, gid 10111) Home Directory: /home/username Maildir: /home/username/Maildir Quota: (none) Encrypted Password: XXXXXX Cleartext Password: CCCCCC Options: (none)
where username is you user name and XXXXXX is you encrypted password as provided in userbd text file. CCCCCC is your password in clear.
Troubleshooting
Should you have a doubt on the execution of a command (ie: no output) you can check if the application is able to load required DLL. This error is not reported. Using strace, windows will complain about DLL not found, if any. To solve this problem you may need to add some path in your PATH. For example, in order to test authlib with authtest:
$ strace /usr/local/sbin/authtest # This will open a dialog box to complain about DLL. $ export PATH=$PATH:/usr/local/lib/bin $ /usr/local/sbin/authtest ausername
Maildir
maildirmake is part of the courier-imap package
$ /usr/lib/courier-imap/bin/maildirmake