Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 525418 - app-admin/logrotate should install a systemd timer
Summary: app-admin/logrotate should install a systemd timer
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Chema Alonso Josa (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-14 15:16 UTC by Alex Brandt (RETIRED)
Modified: 2017-07-02 14:12 UTC (History)
5 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 Alex Brandt (RETIRED) gentoo-dev 2014-10-14 15:16:59 UTC
Running logrotate under cron in a systemd system results in spurious permission errors.  It appears that arch at least has timer files for logrotate.  I have not checked to see if they're in the source and we just haven't updated to include them.  It'd be nice if these timers were installed and running when logrotate was installed.

Reproducible: Always

Steps to Reproduce:
1. Use systemd
2. Install logrotate
3. Watch logrotate fail under cron
Actual Results:  
Permission errors from logrotate running under cron on systemd system.

Expected Results:  
Successfully running logrotate process using systemd timers.
Comment 1 Chema Alonso Josa (RETIRED) gentoo-dev 2014-10-16 11:08:43 UTC
Don't have a systemd installation ATM

@systemd team: Could you please take a look?. Thanks.
Comment 2 Alex Brandt (RETIRED) gentoo-dev 2014-11-29 00:05:48 UTC
Looks like arch has the necessary systemd unit and timer file at this URL:

https://projects.archlinux.org/svntogit/packages.git/tree/trunk?h=packages/logrotate

I'll see about adding this in my overlay so I can supply an updated ebuild as well.
Comment 3 Mike Gilbert gentoo-dev 2014-11-29 04:35:30 UTC
(In reply to Alex Brandt from comment #0)
> Running logrotate under cron in a systemd system results in spurious
> permission errors.

That doesn't make any sense. Please elaborate.

The problem I see with installing timer units is we would also need to disable the cron files to avoid running logrotate under both systemd and cron.
Comment 4 Alex Brandt (RETIRED) gentoo-dev 2014-11-29 06:35:12 UTC
@floppym,

When running logrotate via cron.daily under fcron in a systemd environment I receive this output rather than a successful run of logrotate:

error: error setting owner of /var/log/portage/elog/summary.log-20140817.gz to uid 1000 and gid 250: Operation not permitted
fopen: Permission denied

This is probably due to fcron but it works under openrc without any modifications (after emerge that is).  I'm also not sure if the fopen error is related but can't think of anything else that might be running that would report that error.

Any guidance would be appreciated.
Comment 5 Mike Gilbert gentoo-dev 2014-11-29 23:08:29 UTC
(In reply to Alex Brandt from comment #4)
> @floppym,
> 
> When running logrotate via cron.daily under fcron in a systemd environment I
> receive this output rather than a successful run of logrotate:
> 
> error: error setting owner of /var/log/portage/elog/summary.log-20140817.gz
> to uid 1000 and gid 250: Operation not permitted

Have you modified /etc/logrotate.d/elog-save-summary? That uid should be 250 (portage) by default.

I suspect there is something wrong with your logrotate config, or something inconsistent about the permissions on your log files or /var/log/portage/elog.

I can't explain why it would work under openrc. I don't see anything suspicious with the fcron.service file (like CapabilityBoundingSet, etc).
Comment 6 Alex Brandt (RETIRED) gentoo-dev 2014-12-06 03:07:49 UTC
I'm not sure what the problem might be either but it seems like that component is a support issue.  Thanks for the pointers and all the permissions look fine.

If we don't want to add timers to things like logrotate we should probably mark this bug as invalid.

I'll take the issues I'm having with logrotate and fcron under systemd to a proper support forum.
Comment 7 Mike Gilbert gentoo-dev 2014-12-06 03:28:05 UTC
(In reply to Alex Brandt from comment #6)

I think timers make sense, but we still need to figure out how to implement them without having them duplicated if the user happens to have a cron daemon installed.

If we didn't have to support 2 different init systems, this would be a lot easier.
Comment 8 Alex Brandt (RETIRED) gentoo-dev 2014-12-06 04:24:10 UTC
Would it be acceptable to simply remove the executable permissions from cron files that are installed if the system uses systemd?  Would the systemd use flag be appropriate for this purpose?
Comment 9 Richard Freeman gentoo-dev 2014-12-06 04:59:09 UTC
(In reply to Alex Brandt from comment #8)
> Would it be acceptable to simply remove the executable permissions from cron
> files that are installed if the system uses systemd?  Would the systemd use
> flag be appropriate for this purpose?

Define "system uses systemd."  It isn't the same as system has systemd installed, or USE=systemd is set, etc.

I use systemd timers but for distro-provided cron scripts it probably makes more sense to keep putting them in /etc/cron.d/ directories and using something like systemd-cron to run them, or whatever cron the user prefers.
Comment 10 Alex Brandt (RETIRED) gentoo-dev 2014-12-06 15:37:06 UTC
(In reply to Richard Freeman from comment #9)
> Define "system uses systemd."  It isn't the same as system has systemd
> installed, or USE=systemd is set, etc.

Good point.
 
> I use systemd timers but for distro-provided cron scripts it probably makes
> more sense to keep putting them in /etc/cron.d/ directories and using
> something like systemd-cron to run them, or whatever cron the user prefers.

I would propose we install the timers for things like logrotate but continue enabling the cron files by default.  If the user wants to they can manually disable the cron components and enable the timers.  Would that be acceptable?
Comment 11 Ivan P. 2015-02-14 16:30:15 UTC
(In reply to Alex Brandt from comment #10)
> (In reply to Richard Freeman from comment #9)
> > Define "system uses systemd."  It isn't the same as system has systemd
> > installed, or USE=systemd is set, etc.
> 
> Good point.
>  
> > I use systemd timers but for distro-provided cron scripts it probably makes
> > more sense to keep putting them in /etc/cron.d/ directories and using
> > something like systemd-cron to run them, or whatever cron the user prefers.
> 
> I would propose we install the timers for things like logrotate but continue
> enabling the cron files by default.  If the user wants to they can manually
> disable the cron components and enable the timers.  Would that be acceptable?

Yes, agree.

Or just simply adding the "cron" USE flag like other packages, if the user don't want the cron script, just disable cron USE flag.
Comment 12 Andrew Udvare 2015-03-09 12:34:00 UTC
Running into this semi-issue with several packages. I would rather see a profile using systemd or USE="systemd" globally default to assuming there is no cron daemon (other than systemd's timers) and then only install the timer/service files in that case.

If a package needs a script, perhaps that script should go in /usr/sbin and that path should be referenced in both the systemd unit file *and* the regular cron script file. This way less code is being placed in /etc.
Comment 13 Richard Freeman gentoo-dev 2015-03-09 13:42:51 UTC
I think that this really needs a discussion at the systemd team level - not at the individual package level.

Systemd users can use cron or timers, and they can also use openrc.  The solution needs to reflect this and not make assumptions.
Comment 14 Chris Mayo 2017-06-26 18:54:31 UTC
cron USE flag now exists, PR adding systemd timer:
https://github.com/gentoo/gentoo/pull/4994
Comment 15 Chema Alonso Josa (RETIRED) gentoo-dev 2017-07-02 14:12:21 UTC
Thanks for the PR. It should be fixed now: