Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 590346 - mail-filter/spamassassin: systemd service file improvements
Summary: mail-filter/spamassassin: systemd service file improvements
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Michael Orlitzky
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-03 00:13 UTC by Michael Orlitzky
Modified: 2017-09-15 11:33 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Orlitzky gentoo-dev 2016-08-03 00:13:08 UTC
Just keeping track of a few things I wanted to change in the systemd service file for spamassassin. I would just go ahead and change them, but I have no way to test, so we're stuck waiting for a systemd user to help out.

files/spamassassin.service-r1:

  1. Change PIDFile=/run/spamd.pid to PIDFile=/run/spamd/spamd.pid. This is
     consistent with the OpenRC init script for v3.4.1.

  1a. Adjust the --pidfile parameter in ExecStart to reflect the same.

  2. Drop the -m 5 parameter from ExecStart. We'll add it to SPAMD_OPTS so
     that the user can change it easily.

  3. Remove the "Restart=always" like; this should only be added in unusual
     cases where you expect a daemon to crash.

files/spamassassin.service.conf:

  1. Set SPAMD_OPTS to the same value it has in files/3.4.1-spamd.conf,
     namely SPAMD_OPTS="--max-children=5 --create-prefs --helper-home-dir".
Comment 1 Stefan Briesenick (RETIRED) gentoo-dev 2016-11-06 01:12:16 UTC
@Michael:

you should NOT remove "Restart" for all long-running daemons, since it is a safety feature and doesn't hurt. But instead of "always", we could use "on-failure" or "on-abnormal".
Comment 2 Michael Orlitzky gentoo-dev 2016-11-06 02:09:09 UTC
(In reply to Stefan Briesenick from comment #1)
> @Michael:
> 
> you should NOT remove "Restart" for all long-running daemons, since it is a
> safety feature and doesn't hurt. But instead of "always", we could use
> "on-failure" or "on-abnormal".

On the contrary, I would say it's dangerous to restart a network daemon that isn't supposed to crash but that just crashed without understanding why. The SA daemon doesn't crash, and if it does, that's a serious problem that the admin needs to know about ASAP.

In the extraordinary event that somebody expects his SA daemon to crash and he has investigated and deemed it safe, the Restart parameter is there to play with. But normal users should see that SA crashed and file a bug, if it ever does.
Comment 3 Philippe Chaintreuil 2016-11-06 12:24:03 UTC
I would say that in general, people don't want to debug applications.  
People would rather that the spam filter keeps working all night instead of all their users finding a bunch of spam in the morning.

Notification of the failure is definitely a good thing, but daemon's continuing to do their job is the most important to the non-developer.
Comment 4 Michael Orlitzky gentoo-dev 2017-08-20 17:07:38 UTC
There's a masked -r14 in the tree with a new service file and configuration. If anyone is actually using systemd with spamd, I would appreciate a thumbs up/down to let me know if it works. It now runs in the foreground, as a restricted user, and the service file is greatly simplified.
Comment 5 Dan Goodliffe 2017-08-24 16:13:44 UTC
Not sure if this is related, but it feels it...

I've just upgraded to 3.4.1-r15 which includes a much changed service file... but the service fails to start with:

Aug 24 16:40:10 firebrand spamd[16880]: server socket setup failed, retry 9: spamd: could not create IO::Socket::IP socket on [0.0.0.0]:783: Permission denied
Aug 24 16:40:11 firebrand spamd[16880]: spamd: could not create IO::Socket::IP socket on [0.0.0.0]:783: Permission denied
Aug 24 16:40:11 firebrand systemd[1]: spamassassin.service: Main process exited, code=exited, status=13/n/a

I'm assuming this is because the service itself starts as a user that can't open port 783 as opposed to previously starting as root and dropping to user spamd.
Is this a bug or is there some config change I should make?

Rolled back -r13 and that works fine again.

Thanks.
Comment 6 Michael Orlitzky gentoo-dev 2017-08-24 17:58:30 UTC
(In reply to Dan Goodliffe from comment #5)
> 
> I'm assuming this is because the service itself starts as a user that can't
> open port 783 as opposed to previously starting as root and dropping to user
> spamd.
> Is this a bug or is there some config change I should make?
> 
> Rolled back -r13 and that works fine again.
>

Yeah, it's because I screwed up. I didn't notice the low-numbered port. That's why I left -r13 in the tree though. Let me figure out what to do...
Comment 7 Michael Orlitzky gentoo-dev 2017-08-24 18:11:45 UTC
Dan, does the service file work if you remove the lines,

  User=spamd
  Group=spamd

and if you change,

  ExecStart=/usr/sbin/spamd $SPAMD_OPTS

to

  ExecStart=/usr/sbin/spamd $SPAMD_OPTS --username=spamd --groupname=spamd

?

(And does the resulting process actually run as the spamd user/group?)
Comment 8 Dan Goodliffe 2017-08-24 18:17:47 UTC
Hi Michael, Thanks for looking into this.

Made the suggested changes. Process starts up fine, ps as follows:

UID        PID  PPID  C STIME TTY      STAT   TIME CMD
root     29423     1  2 19:14 ?        Ss     0:00 /usr/bin/perl -T -w /usr/sbin/spamd -c -H -i 0.0.0.0 -A 10.10. --username=spamd --groupname=spamd
spamd    29430 29423  0 19:14 ?        S      0:00 spamd child
spamd    29431 29423  0 19:14 ?        S      0:00 spamd child

Previously those options were in the config file (or in my config file at least, no sure about the supplied one)
Comment 9 Dan Goodliffe 2017-08-24 18:18:56 UTC
To clarify that a bit... this config file:

/etc/systemd/system/spamassassin.service.d/00gentoo.conf

[Service]
Environment="SPAMD_OPTS= -c -H -i 0.0.0.0 -A 10.10. -u spamd -g spamd"
Comment 10 Michael Orlitzky gentoo-dev 2017-08-24 18:32:53 UTC
(In reply to Dan Goodliffe from comment #9)
> To clarify that a bit... this config file:
> 
> /etc/systemd/system/spamassassin.service.d/00gentoo.conf
> 
> [Service]
> Environment="SPAMD_OPTS= -c -H -i 0.0.0.0 -A 10.10. -u spamd -g spamd"

That was my mistake... those two options don't belong in the conf file because you shouldn't change them. I moved them into the service file to avoid tempting people, but I moved them into systemd directives (which take effect as the process starts) and not flags to spamd (which take effect after spamd binds to port 783).

I'm pushing out an -r16 in a second to fix this, thanks for your help.
Comment 11 Michael Orlitzky gentoo-dev 2017-08-24 18:47:46 UTC
-r16 is in the tree and should hit the mirrors within the hour. Please don't hesitate to complain if it doesn't work =)
Comment 12 Dan Goodliffe 2017-08-24 19:09:42 UTC
Got it. Gone with default options across the board with the exception of listening IP address... and all looks good to me. Thanks.