Hello.
I've tried to implement dovecot's deliver LDA to my home mailserver.
I've run into troubles :)
dovecot-deliver.conf:
-- snip --
mail = maildir:%h/Maildir:INBOX=maildir:%h/Maildir
mbox_read_locks = flock
mbox_write_locks = flock
-- snip --
when i run:
deliver -d bfg < email.txt dovecot delivers message to ~/Maildir/maildir/new
It acctually creates "maildir" folder inside real maildir folder.
If i try to list messages via Outlook express mail client, OE reports
entire folder list, but also lists one message "which no longer exists
on server".
If i remove ~/Maildir/maildir folder this message dissaperas from OE
imap folder listing.
Test scenario:
1. start dovecot
2. try to deliver message using "deliver" program (succeedes)
3. try to open INBOX via imap:
Outlook Express:
- reports INBOX message listing with one message, which "doesn't exist
on server anymore"
- the next delivery test with "deliver" LDA fails (lots of nanosleep()
calls)
Thunderbird:
- reports that there are NO messages in INBOX
- still can delivery messages with "deliver" LDA
deliver strace output (search for EVIL CODE string):
--- snip ---
execve("/opt/dovecot/libexec/dovecot/deliver",
["/opt/dovecot/libexec/dovecot/deliver", "-d", "bfg"], [/* 42 vars */]) = 0
uname({sys="Linux", node="frost", ...}) = 0
brk(0) = 0x80af7cc
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb28ee000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or
directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=29220, ...}) = 0
mmap2(NULL, 29220, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb28e6000
close(3) = 0
open("/lib/libdl.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0 \r\0\000"...,
512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=9604, ...}) = 0
mmap2(NULL, 11364, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)
= 0x5837000
mmap2(0x5839000, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1) = 0x5839000
close(3) = 0
open("/lib/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\220T\1"...,
512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1207404, ...}) = 0
mmap2(NULL, 1132300, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3,
0) = 0x583a000
mmap2(0x5949000, 12288, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x10f) = 0x5949000
mmap2(0x594c000, 9996, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x594c000
close(3) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb28e5000
set_thread_area({entry_number:-1 -> 6, base_addr:0xb28e56b0,
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0,
limit_in_pages:1, seg_not_present:0, useable:1}) = 0
munmap(0xb28e6000, 29220) = 0
open("/dev/urandom", O_RDONLY) = 3
read(3, "\362yOO", 4) = 4
close(3) = 0
time(NULL) = 1111840485
brk(0) = 0x80af7cc
brk(0x80d87cc) = 0x80d87cc
brk(0x80d9000) = 0x80d9000
uname({sys="Linux", node="frost", ...}) = 0
cat: 1111836380.P11693Q0M524017.frost:2,S: No such file or directory
getpid() = 23206
rt_sigaction(SIGHUP, {0x8093a90, [], SA_RESTORER, 0x58625b8}, NULL, 8) = 0
rt_sigaction(SIGUSR1, {0x8093a90, [], SA_RESTORER, 0x58625b8}, NULL, 8) = 0
rt_sigaction(SIGUSR2, {0x8093a90, [], SA_RESTORER, 0x58625b8}, NULL, 8) = 0
rt_sigaction(SIGINT, {0x8093ad0, [INT], SA_RESTORER|SA_RESTART,
0x58625b8}, {SIG_DFL}, 8) = 0
rt_sigaction(SIGTERM, {0x8093ad0, [TERM], SA_RESTORER|SA_RESTART,
0x58625b8}, {SIG_DFL}, 8) = 0
rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) = 0
rt_sigaction(SIGALRM, {SIG_IGN}, {SIG_DFL}, 8) = 0
gettimeofday({1111840485, 349252}, {4294967236, 0}) = 0
open("/opt/dovecot/etc/dovecot-deliver.conf", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=111, ...}) = 0
pread(3, "#\n#\n# \n\nmail = maildir:%h/Maildi"..., 1024, 0) = 111
pread(3, "", 913, 111) = 0
close(3) = 0
socket(PF_UNIX, SOCK_STREAM, 0) = 3
fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
connect(3, {sa_family=AF_UNIX, path="/var/run/dovecot/auth-master"},
110) = 0
fstat64(3, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
_llseek(3, 0, 0xb71716b0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
getsockname(3, {sa_family=AF_UNIX, path=L
'"}, [2]) = 0
write(3, "VERSION\t1\t0\nUSER\t1\tbfg\n", 23) = 23
poll([{fd=3, events=POLLIN|POLLPRI|POLLERR|POLLHUP|POLLNVAL,
revents=POLLIN}], 1, 2147483647) = 1
gettimeofday({1111840485, 361824}, {4294967236, 0}) = 0
read(3, "VERSION\t1\t0\nSPID\t29143\n", 4096) = 23
poll([{fd=3, events=POLLIN|POLLPRI|POLLERR|POLLHUP|POLLNVAL,
revents=POLLIN}], 1, 2147483647) = 1
gettimeofday({1111840485, 364325}, {4294967236, 0}) = 0
read(3, "USER\t1\tbfg\tsystem_user=bfg\tuid=1"..., 4073) = 66
getgid32() = 0
setgid32(100) = 0
setgroups32(1, [100]) = 0
setuid32(1000) = 0
setuid32(0) = -1 EPERM (Operation not permitted)
getgid32() = 100
getegid32() = 100
setgid32(0) = -1 EPERM (Operation not permitted)
lstat64("maildir/cur", 0xb7171640) = -1 ENOENT (No such file or
directory)
mkdir("maildir/cur", 0770) = -1 ENOENT (No such file or
directory)
********* EVIL CODE *********
mkdir("maildir", 0770) = 0
mkdir("maildir/cur", 0770) = 0
lstat64("maildir/new", 0xb7171640) = -1 ENOENT (No such file or
directory)
mkdir("maildir/new", 0770) = 0
lstat64("maildir/tmp", 0xb7171640) = -1 ENOENT (No such file or
directory)
mkdir("maildir/tmp", 0770) = 0
********* EVIL CODE *********
fcntl64(0, F_GETFL) = 0 (flags O_RDONLY)
fcntl64(0, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
fstat64(0, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
lstat64("maildir/cur", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
lstat64("maildir/new", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
lstat64("maildir/tmp", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
stat64("/export/home/bfg/Maildir", {st_mode=S_IFDIR|0700, st_size=4096,
...}) = 0
stat64("maildir/dovecot-shared", 0xb7171620) = -1 ENOENT (No such file
or directory)
time(NULL) = 1111840485
open("/export/home/bfg/Maildir/dovecot.index", O_RDWR|O_LARGEFILE) = 4
alarm(120) = 0
fcntl64(4, F_SETLKW64, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0},
0xb7171410) = 0
alarm(0) = 120
fstat64(4, {st_mode=S_IFREG|0600, st_size=144, ...}) = 0
mmap2(NULL, 144, PROT_READ|PROT_WRITE, MAP_SHARED, 4, 0) = 0xb28ed000
open("/export/home/bfg/Maildir/dovecot.index.log", O_RDWR|O_LARGEFILE) = 5
fstat64(5, {st_mode=S_IFREG|0600, st_size=16504, ...}) = 0
pread(5, "\1\0\30\0\223LEB\1\0\0\0\0\0\0\0\0\0\0\0\223LEB", 24, 0) = 24
open("/export/home/bfg/Maildir/dovecot.index.cache", O_RDWR|O_LARGEFILE) = 6
fstat64(6, {st_mode=S_IFREG|0600, st_size=1202176, ...}) = 0
mmap2(NULL, 1202176, PROT_READ, MAP_SHARED, 6, 0) = 0xb27bf000
fcntl64(4, F_SETLK64, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0},
0xb7171470) = 0
alarm(120) = 0
fcntl64(5, F_SETLKW64, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0},
0xb71714b0) = 0
alarm(0) = 120
stat64("/export/home/bfg/Maildir/dovecot.index.log",
{st_mode=S_IFREG|0600, st_size=16504, ...}) = 0
fstat64(5, {st_mode=S_IFREG|0600, st_size=16504, ...}) = 0
mmap2(NULL, 16504, PROT_READ, MAP_SHARED, 5, 0) = 0xb27ba000
madvise(0xb27ba000, 16504, MADV_SEQUENTIAL) = 0
fstat64(4, {st_mode=S_IFREG|0600, st_size=144, ...}) = 0
stat64("/export/home/bfg/Maildir/dovecot.index", {st_mode=S_IFREG|0600,
st_size=144, ...}) = 0
fcntl64(4, F_SETLK64, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0},
0xb71714b0) = 0
write(2, "Error: ", 7Error: ) = 7
write(2, "Fixed index file /export/home/bf"..., 89Fixed index file
/export/home/bfg/Maildir/dovecot.index: first_recent_uid_lowwater 3 ->
1) = 89
write(2, "\n", 1
) = 1
msync(0xb28ed000, 120, MS_SYNC) = 0
fcntl64(4, F_SETLK64, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0},
0xb71714f0) = 0
fcntl64(5, F_SETLK64, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0},
0xb71714f0) = 0
stat64("maildir/new", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
stat64("maildir/cur", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
fstat64(4, {st_mode=S_IFREG|0600, st_size=144, ...}) = 0
stat64("/export/home/bfg/Maildir/dovecot.index", {st_mode=S_IFREG|0600,
st_size=144, ...}) = 0
alarm(120) = 0
fcntl64(5, F_SETLKW64, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0},
0xb7171560) = 0
alarm(0) = 120
stat64("/export/home/bfg/Maildir/dovecot.index.log",
{st_mode=S_IFREG|0600, st_size=16504, ...}) = 0
fstat64(5, {st_mode=S_IFREG|0600, st_size=16504, ...}) = 0
fstat64(4, {st_mode=S_IFREG|0600, st_size=144, ...}) = 0
stat64("/export/home/bfg/Maildir/dovecot.index", {st_mode=S_IFREG|0600,
st_size=144, ...}) = 0
alarm(120) = 0
fcntl64(4, F_SETLKW64, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0},
0xb7171570) = 0
alarm(0) = 120
fstat64(4, {st_mode=S_IFREG|0600, st_size=144, ...}) = 0
stat64("/export/home/bfg/Maildir/dovecot.index", {st_mode=S_IFREG|0600,
st_size=144, ...}) = 0
fcntl64(4, F_SETLK64, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0},
0xb7171470) = 0
_llseek(4, 0, [144], SEEK_END) = 0
write(4, "\0\0\0\0\0\0\0\0\0\0\0\0", 12) = 12
fstat64(4, {st_mode=S_IFREG|0600, st_size=156, ...}) = 0
mmap2(NULL, 156, PROT_READ|PROT_WRITE, MAP_SHARED, 4, 0) = 0xb27b9000
open("/etc/localtime", O_RDONLY) = 7
fstat64(7, {st_mode=S_IFREG|0644, st_size=696, ...}) = 0
fstat64(7, {st_mode=S_IFREG|0644, st_size=696, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb27b8000
read(7, "TZif\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\6\0\0\0\6\0"...,
4096) = 696
close(7) = 0
munmap(0xb27b8000, 4096) = 0
open("/etc/localtime", O_RDONLY) = 7
fstat64(7, {st_mode=S_IFREG|0644, st_size=696, ...}) = 0
close(7) = 0
msync(0xb27b9000, 156, MS_SYNC) = 0
fcntl64(4, F_SETLK64, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0},
0xb7171470) = 0
umask(0177) = 022
time(NULL) = 1111840485
lstat64("maildir/dovecot-uidlist.lock", 0xb71714c0) = -1 ENOENT (No such
file or directory)
stat64("maildir/temp.frost.23206.19bb83d2a70b22b7", 0xb7171490) = -1
ENOENT (No such file or directory)
open("maildir/temp.frost.23206.19bb83d2a70b22b7",
O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0666) = 7
link("maildir/temp.frost.23206.19bb83d2a70b22b7",
"maildir/dovecot-uidlist.lock") = 0
unlink("maildir/temp.frost.23206.19bb83d2a70b22b7") = 0
fstat64(7, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
umask(022) = 0177
open("maildir/dovecot-uidlist", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No
such file or directory)
open("maildir/new", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 8
fstat64(8, {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
fcntl64(8, F_SETFD, FD_CLOEXEC) = 0
getdents64(8, /* 2 entries */, 4096) = 48
getdents64(8, /* 0 entries */, 4096) = 0
close(8) = 0
open("maildir/cur", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 8
fstat64(8, {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
fcntl64(8, F_SETFD, FD_CLOEXEC) = 0
getdents64(8, /* 2 entries */, 4096) = 48
getdents64(8, /* 0 entries */, 4096) = 0
close(8) = 0
fstat64(4, {st_mode=S_IFREG|0600, st_size=156, ...}) = 0
mmap2(NULL, 156, PROT_READ|PROT_WRITE, MAP_SHARED, 4, 0) = 0xb27b8000
pwrite(5, "\0\0\0\0\221\315\0\20", 8, 16504) = 8
pwrite(5, "\1\0\0\0\1\0\0\0", 8, 16512) = 8
pwrite(5, "\200\200\200\204 \0\0\20", 8, 16520) = 8
pwrite(5, "\34\0\4\0\1\0\0\0", 8, 16528) = 8
fsync(5) = 0
pwrite(5, "\200\200\200\204", 4, 16504) = 4
fstat64(5, {st_mode=S_IFREG|0600, st_size=16536, ...}) = 0
munmap(0xb27ba000, 16504) = 0
mmap2(NULL, 16536, PROT_READ, MAP_SHARED, 5, 0) = 0xb27ba000
madvise(0xb27ba000, 16536, MADV_SEQUENTIAL) = 0
fstat64(4, {st_mode=S_IFREG|0600, st_size=156, ...}) = 0
stat64("/export/home/bfg/Maildir/dovecot.index", {st_mode=S_IFREG|0600,
st_size=156, ...}) = 0
fcntl64(4, F_SETLK64, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0},
0xb7171460) = 0
munmap(0xb27b9000, 156) = 0
munmap(0xb27b8000, 156) = 0
umask(0) = 022
open("/export/home/bfg/Maildir/dovecot.index.tmp",
O_RDWR|O_CREAT|O_TRUNC|O_LARGEFILE, 0600) = 8
umask(022) = 0
write(8, "\7\0x\0\220\0\0\0\f\0\0\0\1\10\4\0\223LEB\0\0\0\0\223L"...,
120) = 120
write(8, "\0\0\0\0\224LEB\10\0\4\0\4\0\5\0cache\0\0\0", 24) = 24
close(8) = 0
fcntl64(4, F_SETLK64, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0},
0xb7171460) = 0
fsync(4) = 0
rename("/export/home/bfg/Maildir/dovecot.index.tmp",
"/export/home/bfg/Maildir/dovecot.index") = 0
fcntl64(4, F_SETLK64, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0},
0xb7171530) = 0
fcntl64(5, F_SETLK64, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0},
0xb7171530) = 0
lstat64("maildir/dovecot-uidlist.lock", {st_mode=S_IFREG|0600,
st_size=0, ...}) = 0
unlink("maildir/dovecot-uidlist.lock") = 0
close(7) = 0
munmap(0xb28ed000, 144) = 0
stat64("maildir/tmp/1111840485.P23206Q0M364325.frost", 0xb7171660) = -1
ENOENT (No such file or directory)
umask(0) = 022
open("maildir/tmp/1111840485.P23206Q0M364325.frost",
O_WRONLY|O_CREAT|O_EXCL|O_LARGEFILE, 0600) = 7
umask(022) = 0
_llseek(7, 0, [0], SEEK_CUR) = 0
fstat64(7, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
poll([{fd=0, events=POLLIN|POLLPRI|POLLERR|POLLHUP|POLLNVAL,
revents=POLLHUP}], 1, 2147483647) = 1
gettimeofday({1111840485, 393090}, {4294967236, 0}) = 0
read(0, "", 4096) = 0
fsync(7) = 0
close(7) = 0
alarm(120) = 0
fcntl64(5, F_SETLKW64, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0},
0xb7171590) = 0
alarm(0) = 120
stat64("/export/home/bfg/Maildir/dovecot.index.log",
{st_mode=S_IFREG|0600, st_size=16536, ...}) = 0
fstat64(5, {st_mode=S_IFREG|0600, st_size=16536, ...}) = 0
fstat64(4, {st_mode=S_IFREG|0600, st_size=156, ...}) = 0
stat64("/export/home/bfg/Maildir/dovecot.index", {st_mode=S_IFREG|0600,
st_size=144, ...}) = 0
open("/export/home/bfg/Maildir/dovecot.index", O_RDWR|O_LARGEFILE) = 7
alarm(120) = 0
fcntl64(7, F_SETLKW64, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0},
0xb7171410) = 0
alarm(0) = 120
fstat64(7, {st_mode=S_IFREG|0600, st_size=144, ...}) = 0
mmap2(NULL, 144, PROT_READ|PROT_WRITE, MAP_SHARED, 7, 0) = 0xb28ed000
fcntl64(7, F_SETLK64, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0},
0xb7171440) = 0
close(4) = 0
alarm(120) = 0
fcntl64(7, F_SETLKW64, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0},
0xb71715a0) = 0
alarm(0) = 120
umask(0177) = 022
time(NULL) = 1111840485
lstat64("maildir/dovecot-uidlist.lock", 0xb71714f0) = -1 ENOENT (No such
file or directory)
stat64("maildir/temp.frost.23206.187e2a44c13cb5c3", 0xb71714c0) = -1
ENOENT (No such file or directory)
open("maildir/temp.frost.23206.187e2a44c13cb5c3",
O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0666) = 4
link("maildir/temp.frost.23206.187e2a44c13cb5c3",
"maildir/dovecot-uidlist.lock") = 0
unlink("maildir/temp.frost.23206.187e2a44c13cb5c3") = 0
fstat64(4, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
umask(022) = 0177
open("maildir/dovecot-uidlist", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No
such file or directory)
fcntl64(5, F_SETLK64, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0},
0xb7171560) = 0
fcntl64(7, F_SETLK64, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0},
0xb7171510) = 0
link("maildir/tmp/1111840485.P23206Q0M364325.frost",
"maildir/new/1111840485.P23206Q0M364325.frost") = 0
unlink("maildir/tmp/1111840485.P23206Q0M364325.frost") = 0
alarm(120) = 0
fcntl64(7, F_SETLKW64, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0},
0xb71715b0) = 0
alarm(0) = 120
alarm(120) = 0
fcntl64(5, F_SETLKW64, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0},
0xb7171530) = 0
alarm(0) = 120
stat64("/export/home/bfg/Maildir/dovecot.index.log",
{st_mode=S_IFREG|0600, st_size=16536, ...}) = 0
fstat64(5, {st_mode=S_IFREG|0600, st_size=16536, ...}) = 0
pwrite(5, "\0\0\0\0\2\0\0\20", 8, 16536) = 8
pwrite(5, "\1\0\0\0 \0\0\0", 8, 16544) = 8
fsync(5) = 0
pwrite(5, "\200\200\200\204", 4, 16536) = 4
fcntl64(5, F_SETLK64, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0},
0xb7171550) = 0
fcntl64(7, F_SETLK64, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0},
0xb7171650) = 0
write(4, "1 1111837843 2\n1 1111840485.P232"..., 50) = 50
utime("maildir/dovecot-uidlist.lock", [2005/03/26-13:34:45,
2005/03/26-13:34:45]) = 0
fsync(4) = 0
rename("maildir/dovecot-uidlist.lock", "maildir/dovecot-uidlist") = 0
close(4) = 0
exit_group(75)
SHELL EXIT CODE: 0
--- snip ---
Best regards, Brane