Next Previous Contents

4. Usage

Now that you have successfully compiled and installed authmkhome, you need to

There's one important thing you must be aware of before configuring authmkhome: courier uses a list of modules to authenticate the user. The first module that successfully authenticates the user, enters the home directory of the user. Once there, the authentication goes on and authmkhome is called. However, if the first module fails to change the directory, the authentication will immediately stop, without a chance for authmkhome to create the needed directories. There are two solutions to this problem:
  1. You set in your database a generic home directory (like /home) and you let your script change to the correct directory.
  2. You use authmkhome just to create the ``Maildir'' subdirectory under the home of the user.
The first method is not quite usable if you have shell users and you use the standard /etc/passwd file to retrieve authentication data for courier. However, it should be trivial to correctly set up authmkhome in any other case and the second method should be more than enough if you have shell users.

4.1 Talking to courier

So, let's start from the first step...

Before anything else, you should open courier-imap and courier-pop3 configuration files (on my system, /etc/courier/imapd and /etc/courier/pop3d).

Look for a line like

  AUTHMODULES="authdaemon"
    or
  AUTHMODULES="any_fancy_authentication_module"
and change it in
  AUTHMODULES="authdaemon authmkhome"
    or
  AUTHMODULES="any_fancy_authentication_module authmkhome"
Beware! authmkhome relies on other modules authenticating the users. Thus, it must be called as the last authentication module (unless you want to see funny things happening to your system).

Watch out that once courier is configured to use authmkhome, any authenticated user whose home directory does not exist won't be allowed in in case authmkhome can't find a valid maildir-creator script.

4.2 Talking to authmkhome

By default, authmkhome will look for a script in /usr/sbin/authmkhome-creator. It will call this script with the name of the user as the first argument and the directory to create as the second argument. Many other parameters may be available through the environment but you shouldn't rely on them too much since they may change from version to version of courier.

Anyway, you can specify a different homedir creator with the parameter ``MAILDIR_CREATOR''. You can put it in any of courier-imap or pop3 configuration files, as long as the script is executable. Actually, if you put this parameter in pop3d you should modify the init script in order to force the variable to be exported. In this case, you may want to modify your /etc/init.d/courier-pop3 to look like:

            /usr/bin/env - MAILDIR_CREATOR="$MAILDIR_CREATOR" PATH="...
        
while the original should be quite similar to:
           /usr/bin/env - PATH="$PATH" SHELL="$SHELL" POP3AUTH="$POP3AUTH" \
                $TCPD -pid=$PIDFILE -stderrlogger=${sbindir}/courierlogger \
                                 -maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP \
                                         $TCPDOPTS -address=$ADDRESS $PORT \
            ${prefix}/lib/courier/courier/courierpop3login $AUTHMODULELIST \
                          ${prefix}/lib/courier/courier/courierpop3d Maildir
        
If you want to, although useless in most cases, you can also specify two different creators, one for the pop3 daemon and one for the imap daemon. Just put a different ``MAILDIR_CREATOR'' in the correct configuration files. Make sure to read the following sections on how to write a creator since it can be quite tricky.

4.3 Writing the creator

Beware! The creator script is called with a simple exec. Thus, they cannot be ``inlined'' bash scripts. Example:

THIS IS BAD: MAILDIR_CREATOR="mkdir $(echo 'SELECT * FROM ...'|cut -f); chmod..."
There are few things to keep in mind when writing the mailcreator script:


Next Previous Contents