Bug 39148 - Dovecot does not close its fds
Dovecot does not close its fds
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: Mail
UCS 4.0
Other Linux
: P5 normal (vote)
: UCS 4.0-3-errata
Assigned To: Daniel Tröder
Philipp Hahn
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-08-11 14:12 CEST by Stefan Gohmann
Modified: 2015-09-24 14:37 CEST (History)
3 users (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Gohmann univentionstaff 2015-08-11 14:12:05 CEST
Currently, I'm unable to install dovecot in the Univention Apps because the installation stalls.

Philipp found out that the file descriptors aren't closed. After stopping dovecot, the installation the installation completed:

root@unassigned-hostname:~# lsof | grep 44799
tee       15256               root    0r     FIFO                0,8      0t0      44799 pipe
dovecot   17607               root    2w     FIFO                0,8      0t0      44799 pipe
log       17614               root    2w     FIFO                0,8      0t0      44799 pipe
root@unassigned-hostname:~# ps -ef | grep univention-install
root     15181 12134  0 07:26 ?        00:00:00 /bin/sh /usr/lib/univention-install/99_setup_oxseforucs.inst
root     15226 15181  0 07:26 ?        00:00:00 /bin/bash /usr/sbin/univention-install -y --force-yes -o=APT::Get::AllowUnauthenticated=1; univention-ox-meta-singleserver univention-ox-text univention-ox-guard
root     24068  5951  0 08:07 pts/0    00:00:00 grep univention-install
root@unassigned-hostname:~# strace -p 15226
Process 15226 attached - interrupt to quit
wait4(-1, ^C <unfinished ...>
Process 15226 detached
root@unassigned-hostname:~# /etc/init.d/dovecot stop
[ ok ] Stopping IMAP/POP3 mail server: dovecot.
root@unassigned-hostname:~# strace -p 15226
attach: ptrace(PTRACE_ATTACH, ...): No such process
root@unassigned-hostname:~# ps -ef | grep univention-install
root     15181 12134  0 07:26 ?        00:00:00 /bin/sh /usr/lib/univention-install/99_setup_oxseforucs.inst
root     25413  5951  0 08:08 pts/0    00:00:00 grep univention-install
root@unassigned-hostname:~#
Comment 1 Stefan Gohmann univentionstaff 2015-08-12 06:37:38 CEST
Should this command also fail?

DEBIAN_FRONTEND=noninteractive apt-get install univention-mail-dovecot | tee -a logfile

The dovecot daemon is also restarted during the installation.
Comment 2 Stefan Gohmann univentionstaff 2015-08-12 08:45:06 CEST
(In reply to Stefan Gohmann from comment #1)
> Should this command also fail?
> 
> DEBIAN_FRONTEND=noninteractive apt-get install univention-mail-dovecot | tee
> -a logfile
> 
> The dovecot daemon is also restarted during the installation.

OK, it is stderr. To reproduce use:

root@master401:~# /etc/init.d/dovecot restart 2>&1 | tee -a logfile
Restarting IMAP/POP3 mail server: dovecot.

Redirect to a file works:
root@master401:~# /etc/init.d/dovecot restart 2>/tmp/a
root@master401:~#
Comment 3 Philipp Hahn univentionstaff 2015-08-12 10:28:44 CEST
r62950 | Bug #39148 test: 01/11 daemonize FDs
  tests/01_base/11restart_services

> * Testing /etc/init.d/dovecot restart ...
> COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF   NODE NAME
> dovecot 12747 root    2w   REG  253,0        0 391212 /tmp/tmp.GQjI7zdF8b/2
> log     12750 root    2w   REG  253,0        0 391212 /tmp/tmp.GQjI7zdF8b/2

Also does not close other inherited FDs;
see `grep -A10 ^close_fds /etc/init.d/apache2`
Comment 4 Stefan Gohmann univentionstaff 2015-08-13 09:02:33 CEST
(In reply to Philipp Hahn from comment #3)
> r62950 | Bug #39148 test: 01/11 daemonize FDs
>   tests/01_base/11restart_services
> 
> > * Testing /etc/init.d/dovecot restart ...
> > COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF   NODE NAME
> > dovecot 12747 root    2w   REG  253,0        0 391212 /tmp/tmp.GQjI7zdF8b/2
> > log     12750 root    2w   REG  253,0        0 391212 /tmp/tmp.GQjI7zdF8b/2
> 
> Also does not close other inherited FDs;
> see `grep -A10 ^close_fds /etc/init.d/apache2`

The test case failed, please check.

I'm not sure we should restart every service at the beginning of our Jenkins tests (01/11). Can you move it to the end of the tests?
Comment 5 Daniel Tröder univentionstaff 2015-09-02 18:29:05 CEST
There is a bug filed in upstream: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=734897

Dovecot 2.0 did receive an official patch to close stderr: http://hg.dovecot.org/dovecot-2.0/rev/08e4280e5bfd
But it seems in Dovecot 2.2 only stdin and stdout are closed: http://hg.dovecot.org/dovecot-2.2/file/7378ab8e3b4d/src/master/main.c#l845

The init script now simply redirects stderr to /dev/null. All error messages are sent to /var/log/dovecot.* anyway.

Commit: 63410
YAML (r63411): 2015-09-02-univention-mail-dovecot.yaml
Comment 6 Philipp Hahn univentionstaff 2015-09-09 14:21:28 CEST
OK: r63410
OK: r63411

OK: /etc/init.d/dovecot restart
OK: lsof `tty`
OK: DEBIAN_FRONTEND=noninteractive aptitude -y install '?source-package(^univention-mail-dovecot$)~i'
OK: lsof -a -p `pgrep dovecot` -d 1-3

FIXED: errata-announce -V 2015-09-02-univention-mail-dovecot.yaml
 r63547 | YAML Bug #39302
OK 2015-09-02-univention-mail-dovecot.yaml
Comment 7 Janek Walkenhorst univentionstaff 2015-09-24 14:37:39 CEST
<http://errata.software-univention.de/ucs/4.0/333.html>