Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 533618 - net-mail/mailgraph - add systemd support
Summary: net-mail/mailgraph - add systemd support
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: No maintainer - Look at if you want to take care of it
Depends on:
Blocks: install-systemd-unit
  Show dependency tree
Reported: 2014-12-26 18:40 UTC by Stefan G. Weichinger
Modified: 2019-03-26 20:02 UTC (History)
3 users (show)

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

current draft (file_533618.txt,291 bytes, text/plain)
2015-10-04 09:37 UTC, Stefan G. Weichinger

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan G. Weichinger 2014-12-26 18:40:29 UTC
net-mail/mailgraph-1.14-r2 does not contain systemd-relevant files.

(a) suggested service-file:

Description=mailgraph mail log file analyzer

ExecStart=/usr/bin/mailgraph -d -l /var/log/messages \
  --daemon-rrd=/var/lib/mailgraph \
  --daemon-pid=/var/run/mailgraph/ \


(b) needed entry in tmpfiles.d

# mailgraph.conf 
D /run/mailgraph 0750 root root
Comment 1 Stefan G. Weichinger 2015-09-23 19:12:08 UTC

bug is old, pls do something ;-)
Comment 2 Pacho Ramos gentoo-dev 2015-09-24 18:50:12 UTC
Please take a look to guidelines about how to make better unit files :)

In summary:
1. Does this really need to run in daemon mode and then using Type=forking + needing to take care of the pid file? Would it cause problems to run it instead in foreground?

2. EnvironmentFile is usually discouraged... and also, in this case it looks to be even not needed, I would drop that line then.
Comment 3 Stefan G. Weichinger 2015-09-24 19:21:31 UTC
thanks for the pointer, I will try to rewrite my file and test that asap.

It works for me so far but I agree to get it right (the suggested service file is from late 2014 ...).
Comment 4 Stefan G. Weichinger 2015-09-24 20:18:15 UTC
improved and working service file:

# cat mailgraph.service

Description=mailgraph mail log file analyzer

# User=mgraph
ExecStart=/usr/bin/mailgraph -l /var/log/messages \
	  --daemon-rrd=/var/lib/mailgraph --daemon-pid=/var/run/mailgraph/ \


-> Type=simple, no "--daemon", no Environmentfile

What I dislike (and need advice/help for):

it runs as root right now to be able to read from /var/log/messages.
Which leads to the fact that mailgraph isn't yet able (AFAIK) to read directly from the systemd journal.

With "User=mgraph" it fails to read /var/log/messages with perms 600.
Comment 5 Pacho Ramos gentoo-dev 2015-09-25 16:19:11 UTC
In Fedora the logs for mailgraph are on a separate /var/log/maillog file... maybe it could help
Comment 6 Stefan G. Weichinger 2015-09-26 11:52:56 UTC
(In reply to Pacho Ramos from comment #5)
> In Fedora the logs for mailgraph are on a separate /var/log/maillog file...
> maybe it could help

To have a dedicated /var/log/maillog with systemd-journal one would need to pipe the journald-msgs to something like syslog-ng etc (just checked a fedora server, they run rsyslogd for that) ... not really to be solved inside this one ebuild, right?

I am unsure how to effectively solve that without much overhead.
Comment 7 Pacho Ramos gentoo-dev 2015-10-03 12:15:46 UTC
Maybe the ArchLinux approach could be used... I don't like it so much but it looks like the only alternative :/
Comment 8 Stefan G. Weichinger 2015-10-04 09:34:45 UTC
I try that right now ... it works as root but not as User=mgraph.
As that user it doesn't get in log lines either.

Oct 04 11:05:21 systemd[1]: Started mailgraph mail log file analyzer.
Oct 04 11:05:21 bash[2928]: No journal files were found.

as root:

Oct 04 11:22:07 systemd[1]: Started mailgraph mail log file analyzer.
Oct 04 11:22:07 bash[3502]: WARNING: line not in syslog format: -- Logs begin at Wed 2015-09-23 06:38:50 CEST. --

but then data gets displayed in the cgi.

But if I add that user to the systemd-journal group

# gpasswd -a  mgraph systemd-journal

the mailgraph.service is working as non-root-user mgraph as well.

Do you think that is a good-enough solution for now?
Comment 9 Stefan G. Weichinger 2015-10-04 09:37:54 UTC
Created attachment 413668 [details]
current draft
Comment 10 Pacho Ramos gentoo-dev 2015-10-04 09:48:19 UTC
Do we really need to run it as a separate user? It looks like Fedora and Arch are running it as root (and, then, not having this problem dealing with logs)
Comment 11 Stefan G. Weichinger 2015-10-04 11:55:10 UTC
I just wanted to try and follow the principle of least privileges.

Even as root we would need the more or less ugly construction for ExecStart= 
... I tend to prefer the solution with "gpasswd -a mgraph systemd-journal" then.

You decide.