Package: courier-imap Version: 4.3.0-1. Severity: minor Tags: patch 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: -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable') Architecture: i386 (i686) Kernel: Linux 2.6.23.8 Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) Shell: /bin/sh linked to /bin/bash Versions of packages courier-imap depends on: ii courier-authlib 0.60.1-1 Courier authentication library ii courier-base 0.58.0-1 Courier mail server - base system ii exim4-daemon-heavy [mail-tran 4.68-2 Exim MTA (v4) daemon with extended ii libc6 2.7-3 GNU C Library: Shared libraries ii libfam0 2.7.0-13 Client library to control the FAM ii libgdbm3 1.8.3-3 GNU dbm database routines (runtime courier-imap recommends no packages. -- debconf information: courier-imap/moveconfig: true
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");