Re: [exim] exim4 only queues mails sent by systemd service

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Kamil Jońca
Dátum:  
Címzett: exim-users
Tárgy: Re: [exim] exim4 only queues mails sent by systemd service
Jeremy Harris via Exim-users <exim-users@???> writes:

> On 24/09/2018 14:25, Kamil Jońca via Exim-users wrote:
>> assume we have service file /etc/systemd/system/mailtest.service:
>>
>> --8<---------------cut here---------------start------------->8---
>> [Unit]
>> Description="Test maili"
>> [Service]
>> #User=kjonca
>> NoNewPrivileges=false
>> Type=oneshot
>> ExecStart=-zsh -c 'echo xxx|mail news'
>> ExecStart=-zsh -c 'echo xxx|mutt -F /dev/null -s subject -e \'set copy=no\' kjonca'
>> --8<---------------cut here---------------end--------------->8---
>>
>> When I call
>> sudo systemctl start mailtest.service
>> Two messages are put in exim queue, but not deliveried immediately.
>> Why? What am I missing?
>> Morevoer this service run as "--user" service works as expected - mails
>> are delivered at once.
>> Does systemd interfere with processes (suid/sgid? file access limitations?)

[...my mail...]
>
> Possible, but rather difficult for us to guess.
> If you could call exim directly, rather than via mutt, you could
> add debug flags to the commandline. Then assuming that systemd
> collects stderr, we might be able to trace what happens.


After discussion on systemd list we have conclusions:
(https://lists.debian.org/debian-user/2018/10/msg00054.html
and thread
https://lists.freedesktop.org/archives/systemd-devel/2018-September/041395.html
)

1. exim forks and creates background process to deliver mail
2. systemd, after main process exits, kill all remaining proceses, so
...
3. background exim process are killed during delivery, and message remains in
queue.

I think this is important for services sending mails (for example
logrotate with mail option)

There are solutions/workarounds:
1. migrate to postfix :)
2. set KillMode=none in service file.
3. use other init (not systemd)

KJ

-- 
http://wolnelektury.pl/wesprzyj/teraz/
Sendmail may be safely run set-user-id to root.
        -- Eric Allman, "Sendmail Installation Guide"