FS#31409 - [sshguard] new systemd service silently stops working when no syslog daemon is running

Attached to Project: Community Packages
Opened by Abdó Roig-Maranges (abdo) - Tuesday, 04 September 2012, 14:56 GMT
Last edited by Massimiliano Torromeo (mtorromeo) - Thursday, 15 November 2012, 08:54 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Sergej Pupykin (sergej)
Massimiliano Torromeo (mtorromeo)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:
sshguard systemd service file watches /var/log/auth.log. However systemd replaces syslog with the journal. Although both can run together, systemd is perfectly happy without syslog. This means no auth.log.

As it is now, sshguard.service neither depends on syslog nor uses the journal, so on systems without syslog, sshguard stands there silently doing nothing. sshguard should use the journal, which is part of systemd and is always there.

When I installed systemd, I hacked together a service file that watches the journal for sshd messages and feeds them to sshguard. See the attachment. I'm not sure if it is the best way to do it though... maybe some systemd expert can help?


Additional info:
* package version(s) 1.5-4

Steps to reproduce:
Run sshguard service an a systemd installation without syslog daemon running, and observe it doing nothing.
This task depends upon

Closed by  Massimiliano Torromeo (mtorromeo)
Thursday, 15 November 2012, 08:54 GMT
Reason for closing:  Duplicate
Additional comments about closing:   FS#31733 
Comment by Massimiliano Torromeo (mtorromeo) - Tuesday, 04 September 2012, 19:27 GMT
You know that sshguard does not watch only for sshd logs, right? http://www.sshguard.net/docs/reference/service-codes/

If I have to choose, I would rather make it depend on syslog if there is no cleaner solution.
You can always use your service file and ignore the one dispatched with the sshguard package if you prefer but if we put syslog as a dependency you cannot choose not to install it.
Comment by Abdó Roig-Maranges (abdo) - Tuesday, 04 September 2012, 20:43 GMT
I know sshguard watches for other things. I just attached my files, maybe I should have been more careful. You can use more general filters, like this

journalctl -f SYSLOG_IDENTIFIER=sshd SYSLOG_IDENTIFIER=imapd | /usr/sbin/sshguard -l - -b /var/db/sshguard/blacklist.db $@

or, maybe easier, just forget about filtering and feed everything to sshguard

journalctl -f | /usr/sbin/sshguard -l - -b /var/db/sshguard/blacklist.db $@

I do strongly believe the sshguard service should use the journal by default. It seems more right to me, once you commit to the systemd way, as then syslog becomes an extra optional layer over the journal. Also running without syslog doesn't sound that rare, one may want to keep the journal on ram and get rid of syslog writes on disk, for example. In the future it may even be the default. Using sshguard with the journal, enables both sysloggers and non-sysloggers to use the same service file. Oherwise, non-sysloggers must write their own, as I did. What I suggested seems rather clean to me. It is a shell one-liner after all. I don't quite like having to use an external shell script, but having to run syslog and keeping duplicate logs (journal + syslog) just for sshguard seems much worse.

Anyway, personal preferences aside, the problem with the current state of things is that someone who gets rid of syslog and blindly trusts the service file will end up with a non-functional sshguard without warning.

Oh, and just to clarify, I didn't meant a package dependency on syslog, I meant a systemd dependency on a syslog daemon. This way syslog would not be installed by force, but sshguard should refuse to start if no syslog daemon is running.
Comment by Massimiliano Torromeo (mtorromeo) - Friday, 07 September 2012, 08:16 GMT
Ok, I've done some testing and I'm going with this: journalctl -flbp info -n0 SYSLOG_FACILITY=10
Comment by Johan R (cleanrock) - Wednesday, 14 November 2012, 23:55 GMT
  • Field changed: Percent Complete (100% → 0%)
I updated my server to systemd a few days ago and it very much look like you 1.5-7 is broken, sshguard dont catch anything. I have syslog-ng enabled but i doubt that it has any effect.
I think its worth to test/check sshguard-journalctl is its really working as it should.

Loading...