Bug 1253840

Summary: sendmail startup complains "sendmail.pid not readable (yet?) after start"
Product: Red Hat Enterprise Linux 7 Reporter: Joseph D. Wagner <joe>
Component: sendmailAssignee: Jaroslav Škarvada <jskarvad>
Status: CLOSED WONTFIX QA Contact: qe-baseos-daemons
Severity: low Docs Contact:
Priority: unspecified    
Version: 7.3CC: amahdal, extras-qa, joe, jskarvad, michal, sergio
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1057879 Environment:
Last Closed: 2017-01-05 14:28:20 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1298243    

Description Joseph D. Wagner 2015-08-14 21:02:48 UTC
+++ 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[1]: PID file /run/sendmail.pid not readable (yet?) after start.
Jan 25 09:55:35 yyyy sendmail[1060]: 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):
sendmail-8.14.7-5.fc21

How reproducible:
always

Steps to Reproduce:
1. run 'systemctl restart  sendmail.service' and read this "pid line" from 'systemctl -l status sendmail.service'

Additional info:
/run/sendmail.pid after a restart has a content like this:

1326
/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.

Comment 1 Joseph D. Wagner 2015-08-14 21:03:44 UTC
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.

Comment 3 Sergio Basto 2016-05-27 12:43:58 UTC
From 
[url]https://www.freedesktop.org/software/systemd/man/systemd.service.html[/url]

"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
[1], solves the problem, I don't known if it's worth report it, but
seems still works correctly and don't report any warning.   

[1]
#PIDFile=/run/sendmail.pid

Comment 4 Jaroslav Škarvada 2016-10-25 16:31:47 UTC
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.

Comment 5 Jaroslav Škarvada 2017-01-05 14:28:20 UTC
Closing per comment 4.