[Dovecot] environment variables required for startup
Using dovecot-1.0-rc19 (quotas are working good, btw) on Gentoo, I have a strange problem. On boot, dovecot doesn't start, the init script just times out. From the command line, it starts instantly without problem. Also, using a program called 'monit' to make sure processes stay running and restart them if they stop, if I manually stop dovecot, it is then unable to start it (calling the init script). Nothing gets logged. In all cases, it's "/etc/init.d/dovecot start".
The only thing I can think of is that there's some environment variable required which isn't being set. monit specifically says it unsets everything except for a basic path before running the start program. Do any environment variables need to be set in order for dovecot to start successfully?
-- Marshal Newrock Ideal Solution, LLC - http://www.idealso.com
On Friday 26 January 2007 3:07 pm, Marshal Newrock wrote:
The only thing I can think of is that there's some environment variable required which isn't being set. monit specifically says it unsets everything except for a basic path before running the start program. Do any environment variables need to be set in order for dovecot to start successfully?
Something similar happened to me once on a Fedora Core 3 system with SELinux enabled, where a startup script using 'su -c' (not dovecot's) stopped to ask me if I wanted the SELinux context changed. Try running it like this
/etc/init.d/dovecot < /dev/null
to see if this makes any difference.
Thank you for your consideration, Davide Bolcioni
Paranoia is an afterthought.
Using dovecot-1.0-rc19 (quotas are working good, btw) on Gentoo, I have a strange problem. On boot, dovecot doesn't start, the init script just times out. From the command line, it starts instantly without problem. Also, using a program called 'monit' to make sure processes stay running and restart them if they stop, if I manually stop dovecot, it is then unable to start it (calling the init script). Nothing gets logged. In all cases, it's "/etc/init.d/dovecot start".
The only thing I can think of is that there's some environment variable required which isn't being set. monit specifically says it unsets everything except for a basic path before running the start program. Do any environment variables need to be set in order for dovecot to start successfully? Actually this would have more to do with Gentoo than with Dovecot. Check out the init script you are using. Are you getting any errors on the console where you run the init script?
the init script we are using: #!/sbin/runscript # Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License, v2 or later # $Header: /var/cvsroot/gentoo-x86/net-mail/dovecot/files/dovecot.init,v 1.3 2005/12/14 23:32:08 uberlord Exp $
depend() { need net after saslauthd ldap slapd postgresql mysql use logger }
start() {
ebegin "Starting dovecot"
start-stop-daemon --start --exec /usr/sbin/dovecot
--pidfile /var/run/dovecot/master.pid
eend $?
}
stop() {
ebegin "Stopping dovecot"
start-stop-daemon --stop --exec /usr/sbin/dovecot
--pidfile /var/run/dovecot/master.pid
eend $?
}
HTH
Kenny Dail kend@amigo.net
On Fri, 26 Jan 2007 11:20:02 -0700 Kenny Dail kend@amigo.net wrote:
Using dovecot-1.0-rc19 (quotas are working good, btw) on Gentoo, I have a strange problem. On boot, dovecot doesn't start, the init script just times out. From the command line, it starts instantly without problem. Also, using a program called 'monit' to make sure processes stay running and restart them if they stop, if I manually stop dovecot, it is then unable to start it (calling the init script). Nothing gets logged. In all cases, it's "/etc/init.d/dovecot start".
The only thing I can think of is that there's some environment variable required which isn't being set. monit specifically says it unsets everything except for a basic path before running the start program. Do any environment variables need to be set in order for dovecot to start successfully? Actually this would have more to do with Gentoo than with Dovecot. Check out the init script you are using. Are you getting any errors on the console where you run the init script?
I have the stock init script. No errors at all when run from the command line, just on boot and when run by monit. monit doesn't report any errors, just that execution failed. On boot, I get:
/lib/rcscripts/sh/rc-daemon.sh: line 229: 5211 Alarm clock /sbin/start-stop-daemon '--start' '--exec' '/usr/sbin/dovecot' '--pidfile' '/var/run/dovecot/master.pid'.
Line 229 is just: eval /sbin/start-stop-daemon "${args}"
I just did some more looking into this. I have another server configuration which works without a problem. The other is the proxy, this is the actual mailbox. After a lot of commenting and uncommenting, I found that monit is unable to start dovecot when mail_plugins is set in the "protocol imap" section. I had quota, imap_quota, and trash, and tried each of these by themselves, and in all cases, monit failed to start dovecot, with nothing being logged. With mail_plugins commented out, monit starts dovecot. In "protocol lda", "mail_plugins = quota" with no problems.
-- Marshal Newrock, Ideal Solution LLC http://www.idealso.com
On 27.1.2007, at 0.13, Marshal Newrock wrote:
I had quota, imap_quota, and trash, and tried each of these by themselves, and in all cases, monit failed to start dovecot, with nothing being logged. With mail_plugins commented out, monit starts dovecot. In "protocol lda", "mail_plugins = quota" with no problems.
I think "nothing being logged" is highly unlikely. See http:// wiki.dovecot.org/Logging
Hmm. I think I'll have to add some --log-error command line option to
actually log an error message so it can be easily found..
On Sat, 27 Jan 2007 03:24:16 +0200 Timo Sirainen tss@iki.fi wrote:
I had quota, imap_quota, and trash, and tried each of these by themselves, and in all cases, monit failed to start dovecot, with nothing being logged. With mail_plugins commented out, monit starts dovecot. In "protocol lda", "mail_plugins = quota" with no problems.
I think "nothing being logged" is highly unlikely. See http:// wiki.dovecot.org/Logging
Hmm. I think I'll have to add some --log-error command line option to actually log an error message so it can be easily found..
It really does log nothing. Normal startups, or even startups with errors in the config file (such as having the path to an sql config file commented out) get logged. However, I do have an strace of dovecot being called directly (no init script, no start-stop-daemon). The imap mail_executable was a wrapper script, but for this, I set it back to the default /usr/libexec/dovecot/imap. The end of the strace is:
18945 fstat64(3, {st_mode=S_IFREG|0755, st_size=1204080, ...}) = 0 18945 mmap2(NULL, 1172860, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7e95000 18945 mmap2(0xb7fad000, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x117) = 0xb7fad000 18945 mmap2(0xb7fb1000, 9596, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7fb1000 18945 close(3) = 0 18945 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7e94000 18945 set_thread_area({entry_number:-1 -> 6, base_addr:0xb7e946b0, limit:1048575 , seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0 , useable:1}) = 0 18945 mprotect(0xb7fad000, 8192, PROT_READ) = 0 18945 mprotect(0xb7fdb000, 4096, PROT_READ) = 0 18945 munmap(0xb7fb8000, 26772) = 0 18945 time(NULL) = 1169873237 18945 brk(0) = 0x80d4000 18945 brk(0x80fd000) = 0x80fd000 18945 uname({sys="Linux", node="stasis", ...}) = 0 18945 getpid() = 18945 18945 open("/dev/urandom", O_RDONLY|O_LARGEFILE) = 3 18945 read(3, "k\273\36\347", 4) = 4 18945 fcntl64(3, F_GETFD) = 0 18945 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 18945 getgid32() = 0 18945 setgid32(65534) = 0 18945 setgroups32(1, [65534]) = 0 18945 setuid32(65534) = 0 18945 setuid32(0) = -1 EPERM (Operation not permitted) 18945 getgid32() = 65534 18945 getegid32() = 65534 18945 setgid32(0) = -1 EPERM (Operation not permitted) 18945 gettimeofday({1169873237, 140240}, {300, 0}) = 0 18945 epoll_create(128) = 4 18945 fcntl64(4, F_GETFD) = 0 18945 fcntl64(4, F_SETFD, FD_CLOEXEC) = 0 18945 SYS_291(0x80dd300, 0x18, 0x80dd300, 0x80d2e64, 0xbf95a3ec) = 5 18945 fcntl64(5, F_GETFD) = 0 18945 fcntl64(5, F_SETFD, FD_CLOEXEC) = 0 18945 rt_sigaction(SIGINT, {0x80ba3c0, [], 0}, NULL, 8) = 0 18945 pipe([6, 7]) = 0 18945 fcntl64(6, F_GETFD) = 0 18945 fcntl64(6, F_SETFD, FD_CLOEXEC) = 0 18945 fcntl64(7, F_GETFD) = 0 18945 fcntl64(7, F_SETFD, FD_CLOEXEC) = 0 18945 epoll_ctl(4, EPOLL_CTL_ADD, 6, {EPOLLIN|EPOLLPRI|EPOLLERR|EPOLLHUP, {u32=135127920, u64=135127920}}) = 0 18945 rt_sigaction(SIGTERM, {0x80ba3c0, [], 0}, NULL, 8) = 0 18945 rt_sigaction(SIGPIPE, {SIG_IGN}, NULL, 8) = 0 18945 rt_sigaction(SIGALRM, {0x80b9ec0, [], 0}, NULL, 8) = 0 18945 epoll_ctl(4, EPOLL_CTL_ADD, 2, {EPOLLERR|EPOLLHUP, {u32=135128016, u64=135128016}}) = -1 EPERM (Operation not permitted) 18945 write(2, "\1Fio_loop_handle_add: epoll_ctl(1, 2): Operation not permitted\ n", 63) = 63 18945 exit_group(89) = ? 18944 <... wait4 resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 89}], 0, NULL) = 1 8945 18944 --- SIGCHLD (Child exited) @ 0 (0) --- 18944 alarm(0) = 5 18944 close(3) = 0 18944 write(2, "Error: ", 7) = 7 18944 write(2, "imap dump-capability process returned 89", 40) = 40 18944 write(2, "\n", 1) = 1 18944 exit_group(89) = ?
full strace available on request. The size is 23KB (235 lines).
dovecot -n: # /etc/dovecot/dovecot.conf protocols: pop3 imap ssl_disable: yes disable_plaintext_auth: no login_dir: /var/run/dovecot/login login_executable(default): /usr/libexec/dovecot/imap-login login_executable(imap): /usr/libexec/dovecot/imap-login login_executable(pop3): /usr/libexec/dovecot/pop3-login first_valid_uid: 225 last_valid_uid: 225 first_valid_gid: 225 last_valid_gid: 225 mmap_disable: yes maildir_copy_with_hardlinks: yes maildir_copy_preserve_filename: yes mail_executable(default): /usr/libexec/dovecot/imap mail_executable(imap): /usr/libexec/dovecot/imap mail_executable(pop3): /usr/local/sbin/dovecot_pop3_wrapper mail_plugins(default): quota imap_quota trash mail_plugins(imap): quota imap_quota trash mail_plugins(pop3): quota mail_plugin_dir(default): /usr/lib/dovecot/imap mail_plugin_dir(imap): /usr/lib/dovecot/imap mail_plugin_dir(pop3): /usr/lib/dovecot/pop3 pop3_uidl_format(default): pop3_uidl_format(imap): pop3_uidl_format(pop3): %v-%u pop3_client_workarounds(default): pop3_client_workarounds(imap): pop3_client_workarounds(pop3): outlook-no-nuls oe-ns-eoh auth default: mechanisms: plain login verbose: yes passdb: driver: sql args: /etc/dovecot/dovecot-sql.conf userdb: driver: sql args: /etc/dovecot/dovecot-sql.conf socket: type: listen client: path: /var/run/dovecot/auth-client mode: 432 user: vmail group: vmail master: path: /var/run/dovecot/auth-master mode: 384 user: vmail group: vmail
-- Marshal Newrock Ideal Solution, LLC - http://www.idealso.com
On Sat, 2007-01-27 at 00:02 -0500, Marshal Newrock wrote:
{EPOLLIN|EPOLLPRI|EPOLLERR|EPOLLHUP, {u32=135127920, u64=135127920}}) = 0 18945 rt_sigaction(SIGTERM, {0x80ba3c0, [], 0}, NULL, 8) = 0 18945 rt_sigaction(SIGPIPE, {SIG_IGN}, NULL, 8) = 0 18945 rt_sigaction(SIGALRM, {0x80b9ec0, [], 0}, NULL, 8) = 0 18945 epoll_ctl(4, EPOLL_CTL_ADD, 2, {EPOLLERR|EPOLLHUP, {u32=135128016, u64=135128016}}) = -1 EPERM (Operation not permitted)
epoll() not permitted? I guess SELinux rules are disallowing them. Fix them or disable SELinux.
18945 write(2, "\1Fio_loop_handle_add: epoll_ctl(1, 2): Operation not permitted\ n", 63) = 63 .. 18944 write(2, "Error: ", 7) = 7 18944 write(2, "imap dump-capability process returned 89", 40) = 40 18944 write(2, "\n", 1) = 1
So it didn't log the errors, but it did write them to stderr. Didn't it print them to screen? If not, I think Gentoo's init script should be fixed.
On Sat, 27 Jan 2007 14:31:49 +0200 Timo Sirainen tss@iki.fi wrote:
On Sat, 2007-01-27 at 00:02 -0500, Marshal Newrock wrote:
{EPOLLIN|EPOLLPRI|EPOLLERR|EPOLLHUP, {u32=135127920, u64=135127920}}) = 0 18945 rt_sigaction(SIGTERM, {0x80ba3c0, [], 0}, NULL, 8) = 0 18945 rt_sigaction(SIGPIPE, {SIG_IGN}, NULL, 8) = 0 18945 rt_sigaction(SIGALRM, {0x80b9ec0, [], 0}, NULL, 8) = 0 18945 epoll_ctl(4, EPOLL_CTL_ADD, 2, {EPOLLERR|EPOLLHUP, {u32=135128016, u64=135128016}}) = -1 EPERM (Operation not permitted)
epoll() not permitted? I guess SELinux rules are disallowing them. Fix them or disable SELinux.
SELinux is not enabled at all on this machine.
18945 write(2, "\1Fio_loop_handle_add: epoll_ctl(1, 2): Operation not permitted\ n", 63) = 63 .. 18944 write(2, "Error: ", 7) = 7 18944 write(2, "imap dump-capability process returned 89", 40) = 40 18944 write(2, "\n", 1) = 1
So it didn't log the errors, but it did write them to stderr. Didn't it print them to screen? If not, I think Gentoo's init script should be fixed.
This isn't with the init script. Currently, I'm just using monit to force dovecot restarts, as that's much easier to do remotely - I'd have to be at the console to see if it outputs anything additional when it boots. I started monit with its verbose flag to see if it logs anything additional, but it doesn't. I also tried running it as a foreground process, but then the problem doesn't occur.
-- Marshal Newrock Ideal Solution, LLC - http://www.idealso.com
On Sat, 2007-01-27 at 11:19 -0500, Marshal Newrock wrote:
On Sat, 27 Jan 2007 14:31:49 +0200 Timo Sirainen tss@iki.fi wrote:
On Sat, 2007-01-27 at 00:02 -0500, Marshal Newrock wrote:
{EPOLLIN|EPOLLPRI|EPOLLERR|EPOLLHUP, {u32=135127920, u64=135127920}}) = 0 18945 rt_sigaction(SIGTERM, {0x80ba3c0, [], 0}, NULL, 8) = 0 18945 rt_sigaction(SIGPIPE, {SIG_IGN}, NULL, 8) = 0 18945 rt_sigaction(SIGALRM, {0x80b9ec0, [], 0}, NULL, 8) = 0 18945 epoll_ctl(4, EPOLL_CTL_ADD, 2, {EPOLLERR|EPOLLHUP, {u32=135128016, u64=135128016}}) = -1 EPERM (Operation not permitted)
epoll() not permitted? I guess SELinux rules are disallowing them. Fix them or disable SELinux.
SELinux is not enabled at all on this machine.
BTW this is fixed now in CVS.
participants (4)
-
Kenny Dail
-
Marshal Newrock
-
Schwanritter
-
Timo Sirainen