[Dovecot] How to stop mail_executable from cwd to ~home

Joseph Tam jtam.home at gmail.com
Sat May 21 10:51:34 EEST 2011


On Thu, 19 May 2011, I wrote:

> Gary Duncan <gduncan at engr.UVic.CA> writes:
>
>> Works well except that dovecot still wants to cd to the real home
>> triggering a useless and potentially hindering automount when it
>> invokes the imap or pop3 process specified by mail_executable, ie an
>> lsof of the process shows cwd of /home/<user> and the automounted
>> home.
> 
> I see the same behaviour in 2.0.13, which process tracing of imap
> shows more clearly (/nfs/user is per user mount, /nfs/home/user
> is user home bundle)

This appears to be done (v2.0.13) in mail-storage-service.c in an attempt to
make sure core files are dumped into a user's home directory

         if ((user->flags & MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP) != 0 &&
             (user->flags & MAIL_STORAGE_SERVICE_FLAG_ENABLE_CORE_DUMPS) == 0) {
                 /* we don't want to write core files to any users' home
                    directories since they could contain information about other
                    users' mails as well. so do no chdiring to home. */
         } else if (*home != '\0' &&
                    (user->flags & MAIL_STORAGE_SERVICE_FLAG_NO_CHDIR) == 0) {
                 /* If possible chdir to home directory, so that core file
                    could be written in case we crash. */
                 if (chdir(home) < 0) {
 			... debug diagnostics ...
                 }
         }

As to how to stop the mail process from chdir'ing to a home directory
rather than putting core files somewhere else, I don't know how to do it
without altering the source code or wrapping these processes in something
that alters the HOME environment variable.

I also can't find how user->flags sets MAIL_STORAGE_SERVICE_FLAG_NO_CHDIR or
MAIL_STORAGE_SERVICE_FLAG_ENABLE_CORE_DUMPS that could influence this
behaviour.

Joseph Tam <jtam.home at gmail.com>


More information about the dovecot mailing list