+++ This bug was initially created as a clone of Bug #1057879 +++
+++ This bug impacts Red Hat Enterprise Linux 7. +++
Description of problem:
sendmail does start automatically but leaves in logs these:
-- Subject: Unit sendmail.service has begun with start-up
-- Unit sendmail.service has begun starting up.
Jan 25 09:55:36 yyyy systemd: PID file /run/sendmail.pid not readable (yet?) after start.
Jan 25 09:55:35 yyyy sendmail: starting daemon (8.14.7): SMTP+queueing@01:00:00
(Yes, reversed timestamps are straigth from journalctl output.)
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. run 'systemctl restart sendmail.service' and read this "pid line" from 'systemctl -l status sendmail.service'
/run/sendmail.pid after a restart has a content like this:
/usr/sbin/sendmail -bd -q1h
Is it possible that whatever tries to read sendmail.pid runs an 'smmsp' user while /run/sendmail.pid has "-rw------- 1 root smmsp" access permits?
On this test installation selinux is turned off so, at least at this stage, it is not involved in blocking that read.
Permissions on /run/sendmail.pid are not set correctly. At a minimum, group (smmsp) should be able to read. Not sure if group needs write.
"Please set PIDFile= accordingly. Note that the daemon should write
that file before finishing with its initialization. Otherwise, systemd
might try to read the file before it exists."
So it looks like sendmail creates pid file before exit ... (makes sense
since sendmail have 2 processes) , editing
/usr/lib/systemd/system/sendmail.service and comment out PIDFile entry
, solves the problem, I don't known if it's worth report it, but
seems still works correctly and don't report any warning.
The core of this problem is that sendmail main process fork the child (the server) and the main process then immediately exits without writing the PID. The PID file is written later at some non-deterministic moment. This is flow of the design. The cleanly written daemon should write the PID in the main process before it exits. Unfortunately this is not easy to fix in sendmail. We tried in the past, but we was not successful to get the fix upstream - the change in behaviour could also break others. Fortunately systemd can cope with this problem and the only drawback is the harmless warning in the journal stating that the PID file wasn't there in time it should be.
Closing per comment 4.