Bug 258072 - sysutils/munin-master: install does not respect root directory for /var/cron/tabs/munin
Summary: sysutils/munin-master: install does not respect root directory for /var/cron/...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Florian Smeets
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-27 00:15 UTC by Tassilo Philipp
Modified: 2023-05-23 18:02 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback?


Attachments
munin.cron (9.39 KB, patch)
2023-01-29 22:37 UTC, Florian Smeets
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tassilo Philipp 2021-08-27 00:15:51 UTC
Since sysutils/munin-master/pkg-install uses crontab(1), the munin crontab file will always be installed at /var/cron/tabs/munin. This is an issue when installing munin-master by specifying a different root directory (e.g. for a jail via "pkg -r <jailroot> install munin-master"). The cron(8) process reading /var/cron/tabs/munin will try to execute /usr/local/bin/munin-cron, which doesn't exist, and under the different root hierarchy there won't be any crontab file at all.

I'm not really sure how to best fix this, as crontab(1) has no notion of specifying a different root (and copying the tab file around after crontab(1) created it is messy... I guess nothing should be installed outside of the root anyways, not even temporarily?)
Comment 1 Florian Smeets freebsd_committer freebsd_triage 2023-01-27 20:51:09 UTC
Wouldn't it make more sense to use pkg -j, in that case the crontab command would run inside the jail and that should work, no?
Comment 2 Tassilo Philipp 2023-01-28 14:03:44 UTC
I think this is open for debate, but in my opinion, no, b/c:

- using -j won't work for microjails where there is no complete system

- pkg(1)'s -r can be used for anything and is not jail related, the jail part in my description was only an example; I don't think it's intended things should be installed anywhere outside the hierarchy pointed to by -r

I reopened this, as I don't think -j is the solution here (also "FIXED" is the wrong resolution, nothing was changed, there are other types that would be more suitable).
Comment 3 Tassilo Philipp 2023-01-28 14:18:37 UTC
Just for completeness: when pkg-install is executed, PKG_ROOTDIR is set, so the script has that information and should use it. The only issue is that crontab(1) cannot be used as it has no equivalent of -r, and given crontab(1)'s man page says that the crontab files "are not intended to be edited directly". As mentioned in the original description, I'm not sure how to best fix this.
Comment 4 Tassilo Philipp 2023-01-28 14:41:34 UTC
Suggestion: the script could maybe just check if a different root dir is used, and if so, skip the crontab(1) logic and inform the user that he has to do that step himself. That isn't ideal, but still better than installing things where it isn't supposed to write to at all.
Comment 5 Florian Smeets freebsd_committer freebsd_triage 2023-01-28 15:36:04 UTC
(In reply to Tassilo Philipp from comment #2)
Yeah, I forgot to change the Resolution to something else than FIXED.

It would probably be best to provide a munin.conf and place it in /usr/local/etc/cron.d instead of calling crontab.

I'll look at implementing that.
Comment 6 Tassilo Philipp 2023-01-28 15:56:35 UTC
Ah, very good idea, didn't think of that. Thanks!
Comment 7 Florian Smeets freebsd_committer freebsd_triage 2023-01-29 22:37:41 UTC
Created attachment 239794 [details]
munin.cron
Comment 8 Florian Smeets freebsd_committer freebsd_triage 2023-01-29 22:38:31 UTC
(In reply to Tassilo Philipp from comment #6)
Hey, would you test the attached patch? Thanks.
Comment 9 Tassilo Philipp 2023-01-30 09:33:12 UTC
(In reply to Florian Smeets from comment #8)
Tested it, updated a munin node, made sure only the cron.d file is active, and it's looking good. Thanks for your work, that's a much cleaner style indeed!
Comment 10 commit-hook freebsd_committer freebsd_triage 2023-01-30 18:52:45 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=02388ae491f5d00fb4dfe7e1945b8644c3c1aae7

commit 02388ae491f5d00fb4dfe7e1945b8644c3c1aae7
Author:     Florian Smeets <flo@FreeBSD.org>
AuthorDate: 2023-01-29 22:17:24 +0000
Commit:     Florian Smeets <flo@FreeBSD.org>
CommitDate: 2023-01-30 18:46:33 +0000

    sysutils/munin-{master,node}: change cron job install

    Don't rely on directly calling crontab(1) to install the cron job, use
    the etc/cron.d directory for which we've had support for a while. This
    fixes installing munin-master using pkg -r as crontab(1) installed the
    cron job on the host system not in the specified alternative root
    otherwise.

    Completely remove pkg-install, that also removes the automatic migration
    for newsyslog files after src revision r340318 it's been 4 years and a
    bit.

    Leave the pkg-deinstall script for a while to make sure that the
    automatically installed cron jobs via crontab(1) are removed.

    PR:             258072
    Reported by:    Tassilo Philipp <tphilipp@potion-studios.com>
    Tested by:      Tassilo Philipp <tphilipp@potion-studios.com>

 sysutils/munin-master/Makefile             |   3 +
 sysutils/munin-master/files/cron (new)     |   1 +
 sysutils/munin-master/files/pkg-message.in |  22 -------
 sysutils/munin-master/pkg-install (gone)   | 100 -----------------------------
 sysutils/munin-master/pkg-plist            |   2 +
 sysutils/munin-node/files/pkg-message.in   |  19 ------
 sysutils/munin-node/pkg-install (gone)     |  42 ------------
 7 files changed, 6 insertions(+), 183 deletions(-)
Comment 11 abhay.rathod 2023-05-23 18:02:27 UTC
I'm seeing an issue with munin-master.conf located at /usr/local/etc/cron.d/ in FreeBSD 13.2.

After the munin packages are installed, the cron is not picking up the munin-cron schedule from munin-master.conf located at /usr/local/etc/cron.d/ until I touch the file to change the modification time. This is weird because if I create another file in same folder, the cron picks it up but still not the munin-master.conf until its touched.

Any ideas?