The following improvement was reported to the Debian BTS:

The error string presented when the uid and/or gid of a maildir is
incorrectly set includes the string for errno.  Because the check is
performed after stat'ing <maildir>/loginexec, it retains the errno value
from that check.  When printing the error message, the string from errno
is (incorrectly) appended:

/usr/bin/imapd .maildir 
* BYE [ALERT] Fatal error: Account's mailbox directory is not owned by
* the correct uid or gid: No such file or directory

strace output:
chdir("/home/<user>/.maildir")         = 0
stat64("loginexec", 0xbfd35804)         = -1 ENOENT (No such file or
directory)
stat64(".", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
geteuid32()                             = 1000
getegid32()                             = 1000
time(NULL)                              = 1197041165
write(1, "* BYE [ALERT] Fatal error: Accou"..., 122* BYE [ALERT] Fatal
error: Account's mailbox directory is not owned by the correct uid or
gid: No such file or directory
) = 122


The errno output originates in write_error_exit function in
imap/imapwrite.c.  In it, if errno is nonzero, errno is translated to a
string and appended (or, if no strerror is present on the system, just
the errno value).

Thefore, a simple one-line patch is sufficient to stop the incorrect
errno appending.  One need only set errno to 0 before calling
write_error_exit:

(see attachment)

Regards
        Racke

-- 
LinuXia Systems => http://www.linuxia.de/
Expert Interchange Consulting and System Administration
ICDEVGROUP => http://www.icdevgroup.org/
Interchange Development Team

diff -uNr original/courier-0.58.0/imap/imapd.c courier-0.58.0/imap/imapd.c
--- original/courier-0.58.0/imap/imapd.c        2007-11-10 14:46:53.000000000 
-0600
+++ courier-0.58.0/imap/imapd.c 2007-12-07 10:24:38.170826094 -0600
@@ -6392,7 +6392,10 @@
 
                if ( buf.st_uid != geteuid() ||
                     buf.st_gid != getegid())
+                    {
+                       errno=0;
                        write_error_exit("Account's mailbox directory is not 
owned by the correct uid or gid");
+                    }
 
                if ( (buf.st_mode & S_IRWXU) != (buf.st_mode & S_IRWXU))
                        write_error_exit("Invalid permissions on account's 
mailbox directory");
-------------------------------------------------------------------------
SF.Net email is sponsored by: 
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Courier-imap mailing list
[email protected]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-imap

Reply via email to