Bug 843116 - dovecot starts too early
Summary: dovecot starts too early
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: dovecot
Version: 17
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Michal Hlavinka
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 851131
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-07-25 16:02 UTC by Ralf Corsepius
Modified: 2012-11-15 02:38 UTC (History)
2 users (show)

Fixed In Version: dovecot-2.1.10-2.fc17
Clone Of:
Environment:
Last Closed: 2012-11-15 02:38:50 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Ralf Corsepius 2012-07-25 16:02:59 UTC
Description of problem:

I am using nfs-autofs-automounted homes.

When booting up, dovecot fails start up properly, AFAIU, because these users' homes are not yet available:


[root@beck ~]# systemctl status dovecot.service
dovecot.service - Dovecot IMAP/POP3 email server
	  Loaded: loaded (/usr/lib/systemd/system/dovecot.service; enabled)
	  Active: active (running) since Wed, 25 Jul 2012 17:51:35 +0200; 3min 40s ago
	Main PID: 655 (dovecot)
	  CGroup: name=systemd:/system/dovecot.service
		  ├ 655 /usr/sbin/dovecot -F
		  ├ 685 dovecot/anvil
		  ├ 686 dovecot/log
		  └ 691 dovecot/config

Jul 25 17:51:35 beck dovecot[655]: master: Dovecot v2.1.8 starting up (cor...d)
Jul 25 17:51:35 beck dovecot[655]: master: Warning: /var/ftp/pub is no lon...nt
Jul 25 17:51:35 beck dovecot[655]: master: Warning: /misc is no longer mou...nt
Jul 25 17:51:35 beck dovecot[655]: master: Warning: /net is no longer moun...nt
Jul 25 17:51:35 beck dovecot[655]: master: Warning: /users is no longer mo...nt
Jul 25 17:51:35 beck dovecot[655]: master: Warning: /run/user/corsepiu/gvf...nt
[root@beck ~]# systemctl restart dovecot.service
[root@beck ~]# systemctl status dovecot.service
dovecot.service - Dovecot IMAP/POP3 email server
	  Loaded: loaded (/usr/lib/systemd/system/dovecot.service; enabled)
	  Active: active (running) since Wed, 25 Jul 2012 17:55:42 +0200; 3s ago
	Main PID: 1723 (dovecot)
	  CGroup: name=systemd:/system/dovecot.service
		  ├ 1723 /usr/sbin/dovecot -F
		  ├ 1727 dovecot/anvil
		  ├ 1728 dovecot/log
		  └ 1730 dovecot/config

Jul 25 17:55:42 beck dovecot[1723]: master: Dovecot v2.1.8 starting up (core dumps disabled)


Version-Release number of selected component (if applicable):
dovecot-2.1.8-1.fc17.x86_64

How reproducible:
Always.

Manually restarting dovecot resolves this issue.


Actual results:
After bootup, such users can't access mail.
After manually restarting dovecot (cf. above), mail access works again.

Expected results:
Function. FC16 did not exhibit this behavior.

Comment 1 Michal Hlavinka 2012-07-27 10:30:24 UTC
please try if following helps:
create /etc/systemd/system/dovecot.service with content:
.include /usr/lib/systemd/system/dovecot.service
[Unit]
After=autofs.service

and reboot. Does it help?

Comment 2 Ralf Corsepius 2012-07-27 14:44:05 UTC
(In reply to comment #1)
> Does it help?
No, it doesn't.

# cat /etc/systemd/system/dovecot.service
.include /usr/lib/systemd/system/dovecot.service
[Unit]
After=autofs.service

After rebooting, user "corsepiu" logging-in into xfce via gdm and launching thunderbird:

# systemctl status dovecot.service
dovecot.service - Dovecot IMAP/POP3 email server
	  Loaded: loaded (/etc/systemd/system/dovecot.service; enabled)
	  Active: active (running) since Fri, 27 Jul 2012 16:32:19 +0200; 5min ago
	Main PID: 834 (dovecot)
	  CGroup: name=systemd:/system/dovecot.service
		  ├ 834 /usr/sbin/dovecot -F
		  ├ 868 dovecot/anvil
		  └ 869 dovecot/log

Jul 27 16:32:19 beck dovecot[834]: master: Dovecot v2.1.8 starting up (core...d)
Jul 27 16:32:19 beck dovecot[834]: master: Warning: /run/user/corsepiu/gvfs...nt
Jul 27 16:32:45 beck dovecot[869]: imap-login: Login: user=<corsepiu>, meth...o>
Jul 27 16:32:45 beck dovecot[869]: imap(corsepiu): Error: chdir(/users/cors...ks
Jul 27 16:32:45 beck dovecot[869]: imap(corsepiu): Error: user corsepiu: In...iu
Jul 27 16:32:45 beck dovecot[869]: imap(corsepiu): Error: Invalid user sett...n.

Comment 3 Michal Hlavinka 2012-08-23 09:20:55 UTC
OK, I tried to reproduce this. 

Environment:
mkdir /home/auto
adduser -d /home/auto/afsuser afsuser
passwd afsuser
new /etc/auto.home with following line:
afsuser -fstype=ext3,loop,rw :/home/disk.img
added "/home/auto /etc/auto.home" to /etc/auto.master
chkconfig dovecot on
chkconfig autofs on
dd if=/dev/zero of=/home/disk.img bs=1M count=100
mkfs.ext3 -F /home/disk.img
mount /home/disk.img /mnt -oloop
mv /home/auto/afsuser /mnt
umount /mnt

default dovecot configuration, set mail_location=maildir:~/Maildir

configure thunderbird to use afsuser@localhost:143

1) Reproduce - force autofs started *after* (note "Before=") dovecot:
# cat /etc/systemd/system/dovecot.service 
.include /usr/lib/systemd/system/dovecot.service
[Unit]
Before=autofs.service

reboot, add enforcing=0 to kernel cmd line

start thunderbird -> "Login to server localhost failed."
service dovecot status:
master: Dovecot v2.1.9 starting up (core dumps disabled)
master: Warning: /misc is no longer mounted. See http://wiki2.dovecot.org/Mountpoints
master: Warning: /net is no longer mounted. See http://wiki2.dovecot.org/Mountpoints
master: Warning: /home/auto is no longer mounted. See http://wiki2.dovecot.org/Mountpoints
imap-login: Login: user=<afsuser>, method=PLAIN, rip=::1, lip=::1, mpid=884, secured, session=<u5QeJdzHfAAAAAAAAAAAAAAAAAAAAAAB>
imap(afsuser): Error: user afsuser: Initialization failed: Namespace '': Can't create mailbox root dir /home/auto/afsuser/...ount remove
imap(afsuser): Error: Invalid user settings. Refer to server log for more information.

-> reproducible

2) Try the fix - start dovecot after autofs:
# cat /etc/systemd/system/dovecot.service 
.include /usr/lib/systemd/system/dovecot.service
[Unit]
After=autofs.service

reboot

cat /var/log/boot.log:
         Starting Automounts filesystems on demand...
.........
[  OK  ] Started Automounts filesystems on demand.
         Starting Dovecot IMAP/POP3 email server...
[  OK  ] Started Dovecot IMAP/POP3 email server.

so dovecot really is started after autofs

thunderbird -> Login failed again

service dovecot status:
dovecot: master: Dovecot v2.1.9 starting up (core dumps disabled)
dovecot: imap-login: Login: user=<afsuser>, method=PLAIN, ...
dovecot: imap(afsuser): Error: chdir(/home/auto/afsuser) failed: Too many levels of symbolic links

WTF?

# cat chdircheck.c 
#include <unistd.h>
#include <stdio.h>
#include <errno.h>

int main(int argc, char **argv)
{
  int r=chdir("/home/auto/afsuser");
  fprintf(stderr,"Return code is: %d, errno=%d : %m\n",r,errno);
  return r;
}

gcc chdircheck.c -o /home/chdircheck
to /etc/.../dovecot.service added:
[Service]
ExecStartPre=/home/chdircheck

reboot
service dovecot status: failed
/var/log/messages: 
chdircheck[608]: Return code is: -1, errno=40 : Too many levels of symbolic links

seems there is some problem with autofs. I'll investigate and file a new bug.

Comment 4 Michal Hlavinka 2012-08-23 10:25:39 UTC
> seems there is some problem with autofs. I'll investigate and file a new bug.

the bug seems to be in systemd or kernel : bug #851131

Comment 5 Michal Hlavinka 2012-10-18 15:50:19 UTC
That systemd bug won't be fixed in Fedora 17 nor 16, but there should be workaround for that bug.

please try if following helps:
create /etc/systemd/system/dovecot.service with content:



.include /usr/lib/systemd/system/dovecot.service
[Unit]
After=autofs.service

[Service]
PrivateTmp=false




and reboot. Does it help?

Comment 6 Ralf Corsepius 2012-10-19 05:41:17 UTC
(In reply to comment #5)
> That systemd bug won't be fixed in Fedora 17 nor 16,
Is anybody surprized, why Fedora is loosing users? I regret, but such kind of regressions, definitely contribute their share to the "great Fedora experience".

> but there should be
> workaround for that bug.
... 
> please try if following helps:
> create /etc/systemd/system/dovecot.service with content:
...
> and reboot. Does it help?

Seems so. At least, dovecot appeared working properly after 2 reboots for me.

Thanks for you efforts.

Comment 7 Michal Hlavinka 2012-11-02 11:41:06 UTC
Should be fixed in dovecot-2.1.10-2.fc17 I did not use 'After=autofs.service', because for my testing it was not necessary. Only the systemd workaround was required.

Comment 8 Fedora Update System 2012-11-02 12:26:59 UTC
dovecot-2.1.10-2.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/dovecot-2.1.10-2.fc17

Comment 9 Fedora Update System 2012-11-04 01:57:14 UTC
Package dovecot-2.1.10-2.fc17:
* should fix your issue,
* was pushed to the Fedora 17 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing dovecot-2.1.10-2.fc17'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-17584/dovecot-2.1.10-2.fc17
then log in and leave karma (feedback).

Comment 10 Fedora Update System 2012-11-15 02:38:52 UTC
dovecot-2.1.10-2.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.