Bug 714430 - Provide native systemd unit file for postgrey
Provide native systemd unit file for postgrey
Product: Fedora
Classification: Fedora
Component: postgrey (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Matthias Saou
Fedora Extras Quality Assurance
Depends On:
Blocks: SysVtoSystemd
  Show dependency treegraph
Reported: 2011-06-19 05:25 EDT by Harald Reindl
Modified: 2012-04-11 22:02 EDT (History)
4 users (show)

See Also:
Fixed In Version: postgrey-1.34-3.fc17
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-04-11 22:02:39 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Harald Reindl 2011-06-19 05:25:39 EDT
please include a systemd-service file for Fedora >= 15

it is a bad behavior that F15 replacing upstart with systemd and most 
services are running in SysV compatibilty mode
Comment 1 Jon Ciesla 2012-02-13 14:47:25 EST
Mattias, any objection to my making this change?
Comment 2 Jon Ciesla 2012-03-14 12:24:15 EDT
Comment 3 Harald Reindl 2012-03-14 12:29:10 EDT
here the unit-file written the same day as my bugreport and in production since many months - laughable how many package maintainers are acting with systemd-transition

[root@mail:~]$ cat /lib/systemd/system/postgrey.service 
Description=Postfix Greylisting Service

ExecStart=/usr/sbin/postgrey --unix=/var/spool/postfix/postgrey/socket

Comment 4 Jon Ciesla 2012-03-14 12:36:35 EDT
Thanks, Harald, I'll use that if Mattias OKs it.
Comment 5 Michael J. Chudobiak 2012-03-15 16:27:54 EDT
Does it matter that the "-d" flag is not in the ExecStart line? The old init script had it.

I couldn't make this service file work on F16. Postfix couldn't find postgrey without the -d flag, but systemd didn't report a successful start with the -d flag in. Not sure what it all means. I'm back to the init file method.

Personally, I'd also add "--delay=60". The default 5 minute delay (300 sec) is a bit excessive.
Comment 6 Harald Reindl 2012-03-15 16:42:29 EDT
no idea what you are speaking about
see log at the bottom

[root@testserver:~]$ rpm -q postgrey

[root@testserver:~]$ uname -r

[root@testserver:~]$ systemctl status postgrey.service
postgrey.service - Postfix Greylisting Service
          Loaded: loaded (/lib/systemd/system/postgrey.service; enabled)
          Active: active (running) since Thu, 15 Mar 2012 21:39:31 +0100; 1min 40s ago
        Main PID: 15350 (/usr/sbin/postg)
          CGroup: name=systemd:/system/postgrey.service
                  └ 15350 /usr/sbin/postgrey --unix=/var/spool/postfix/postgrey/socket

[root@testserver:~]$ cat /lib/systemd/system/postgrey.service
Description=Postfix Greylisting Service
ExecStart=/usr/sbin/postgrey --unix=/var/spool/postfix/postgrey/socket

[root@testserver:~]$ cat maillog 
Mar 15 21:40:27 testserver postfix/smtpd[15374]: connect from local.rhsoft.net[]
Mar 15 21:40:27 testserver postfix/smtpd[15374]: Anonymous TLS connection established from local.rhsoft.net[]: TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)
Mar 15 21:40:27 testserver postfix/smtpd[15374]: NOQUEUE: reject: RCPT from local.rhsoft.net[]: 450 4.2.0 <test@testserver.rhsoft.net>: Recipient address rejected: Greylisted, see http://postgrey.schweikert.ch/help/testserver.rhsoft.net.html; from=<harry@srv-rhsoft.rhsoft.net> to=<test@testserver.rhsoft.net> proto=ESMTP helo=<srv-rhsoft.rhsoft.net>
Mar 15 21:40:28 testserver postfix/smtpd[15374]: disconnect from local.rhsoft.net[]
Comment 7 Michael J. Chudobiak 2012-03-15 17:37:39 EDT
Your maillog is only showing entries from "postfix/smtpd". My system shows "postfix/smtpd" entries AND "postgrey" entries, like this:

Mar 15 17:31:54 server2 postgrey[846]: action=greylist, reason=new, client_name=unknown, client_address=, sender=importunityseu636@wwsdonline.com, recipient=info@avtechpulse.com
Mar 15 17:31:54 server2 postfix/smtpd[5640]: NOQUEUE: reject: RCPT from unknown[]: 450 4.2.0 <info@avtechpulse.com>: Recipient address rejected: Greylisted, see http://postgrey.schweikert.ch/help/avtechpulse.com.html; from=<importunityseu636@wwsdonline.com> to=<info@avtechpulse.com> proto=ESMTP helo=<dsldevice.lan>

Your service file does not launch postgrey with the -d (or --daemonize) flag, so logging is disabled. From /usr/sbin/postgrey:

log_file => $opt{daemonize} ? 'Sys::Syslog' : undef

The init script uses:

start() {
    [ -x $exec ] || exit 5
    echo -n $"Starting $prog: "
    daemon $exec -d $options
    [ $retval -eq 0 ] && touch $lockfile
    return $retval

Note the "-d".
Comment 8 Harald Reindl 2012-03-15 17:55:55 EDT
Maybe, but it is working and all relevant things are in maillog, teh rest in /var/log/messages -> However it would be the job of the package-maintainer since a year to patch whatever si needed and provide native systemd-units, not mine

Mar 15 21:38:56 testserver postgrey[15317]: 2012/03/15-21:38:56 postgrey (type Net::Server::Multiplex) starting! pid(15317)
Mar 15 21:38:56 testserver postgrey[15317]: Binding to UNIX socket file /var/spool/postfix/postgrey/socket using SOCK_STREAM
Mar 15 21:38:56 testserver postgrey[15317]: Setting gid to "482 482"
Mar 15 21:38:56 testserver postgrey[15317]: Setting uid to "488"
Mar 15 21:39:18 testserver postgrey[15317]: 2012/03/15-21:39:18 Server closing!
Mar 15 21:39:31 testserver postgrey[15350]: 2012/03/15-21:39:31 postgrey (type Net::Server::Multiplex) starting! pid(15350)
Mar 15 21:39:31 testserver postgrey[15350]: Binding to UNIX socket file /var/spool/postfix/postgrey/socket using SOCK_STREAM
Mar 15 21:39:31 testserver postgrey[15350]: Setting gid to "482 482"
Mar 15 21:39:31 testserver postgrey[15350]: Setting uid to "488"
Mar 15 21:40:27 testserver postgrey[15350]: action=greylist, reason=new, client_name=local.rhsoft.net, client_address=, sender=harry@srv-rhsoft.rhsoft.net, recipient=test@testserver.rhsoft.net
Mar 15 21:55:33 testserver postgrey[15350]: action=pass, reason=triplet found, delay=906, client_name=local.rhsoft.net, client_address=, sender=harry@srv-rhsoft.rhsoft.net, recipient=test@testserver.rhsoft.net
Comment 9 Jon Ciesla 2012-03-16 08:03:21 EDT
Also, we can add delay config in a /etc/sysconfig/postgrey file, which the unit file can source.

-d Shouldn't be necessary, as systemd should handle daemonization.  Maybe Type should be Forking rather than Simple?
Comment 10 Michael J. Chudobiak 2012-03-16 08:20:35 EDT
Here's a more robust postgrey.service file, I think. Can you test it, Harald?

Description=Postfix Greylisting Service


ExecStartPre=-/bin/rm -f /var/run/postgrey.pid


ExecStart=/usr/sbin/postgrey \
 --unix=/var/spool/postfix/postgrey/socket \
 --pidfile=/var/run/postgrey.pid \
 --daemonize \



My /etc/sysconfig/postgrey contains one line:

Comment 11 Michael J. Chudobiak 2012-03-20 08:56:56 EDT
Anyway... the service file in comment 10 seems to work well. In fact, it works better than the current init script, which does not cleanly kill postgrey for some reason on my system.

Can someone push this into a testing release? It would be nice to have a service file for F17.

- Mike
Comment 12 Jon Ciesla 2012-03-20 09:05:04 EDT
I'll do this today.
Comment 13 Jon Ciesla 2012-03-20 09:36:44 EDT
Committed.  Will build once rawhide builds recover from the deltarpm/rpm issue.
Comment 14 Jon Ciesla 2012-03-20 10:35:27 EDT
Done, thanks all.  I'll send an update for f17.
Comment 15 Fedora Update System 2012-03-20 10:46:14 EDT
postgrey-1.34-3.fc17 has been submitted as an update for Fedora 17.
Comment 16 Fedora Update System 2012-03-21 14:19:23 EDT
Package postgrey-1.34-3.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 postgrey-1.34-3.fc17'
as soon as you are able to.
Please go to the following url:
then log in and leave karma (feedback).
Comment 17 Harald Reindl 2012-03-23 04:58:29 EDT
remove this whole PID-crap

systemd doe snot need it, postgrey does not need it
if you are not froce to create it you have no troubles after
a crash because it was not deleted

with "--daemonize" and "forking" it logs in /var/log/maillog and that was it

Description=Postfix Greylisting Service

ExecStart=/usr/sbin/postgrey --unix=/var/spool/postfix/postgrey/socket --daemonize

Comment 18 Michael J. Chudobiak 2012-03-23 08:02:41 EDT
The service file in comment 17 is too minimal. It has no support for EnvironmentFile, which is not good.

Also, "man systemd.service" says: "If set to forking ...<snip>... If this setting is used, it is recommended to also use the PIDFile= option, so that systemd can identify the main process of the daemon."

The ExecStartPre line removes leftover pid files before launch, in the event of a crash.

I believe the existing service file is more correct.
Comment 19 Harald Reindl 2012-03-23 09:21:33 EDT
The env-file si your, i haveno need for it

with the pid-file you are TOTALLY wrong
look gagain at my systemd-unit

postgrey itself is started without pid-file, there is no one and so there is nothing to remove and nothing block the next start, that it is a ppor bug in postgrey refuse starting because a orphaned pid-file exists is another story and the root-cause of the whole problem

your reference to systemd manual is nice but completly wrong interpretaed for a service wiht only a single process

and why it is really wrong is:
i saw manually created htttp-services for special instances of apache which did not start as all as long PIDFile was set, removing the line and all was fine

systemd does NOT need this line, make a request on the system-devel list
i am tired after many months with a lot of REALLY forking services aithout PID lines in production to get educated here - where were you when i had to upgrade to F15 and there was no postgrey.service?
Comment 20 Jon Ciesla 2012-03-23 09:42:11 EDT
Harald, the env file provides a mechanism for providing a reasonable default, editable by the admin.  You don't have to use it.

postgrey is not httpd, simply because something works for one does not mean it's needed or appropriate for the other.  postgrey's behaviour may be buggy, but this unit file works for it as it is.  If the maintainer wishes to patch the buggy behaviour and submit it upstream, that's fine.  If you wish to do so and submit a patch for him or someone else to apply and send upstream, that's also fine.
Comment 21 Harald Reindl 2012-03-23 09:52:47 EDT
again: postgey works completly without an PID-file
please try it out, so the bug remove orphaned on start is not a topic

the pid-file was more needed for sysv-scripts
it is obsolete
Comment 22 Harald Reindl 2012-03-25 14:44:09 EDT
this appears in /var/log/messages for nearly ALL services with the 
"PIDFile" line, after remove it from the unit-file all works fine

believe it or not

systemd[1]: PID file /var/run/pure-ftpd.pid not readable (yet?) after start.
Comment 23 Fedora Update System 2012-04-11 22:02:39 EDT
postgrey-1.34-3.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.