Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 715618 - net-misc/chrony[caps]: /var/{lib,log}/chrony need access permission for ntp user
Summary: net-misc/chrony[caps]: /var/{lib,log}/chrony need access permission for ntp user
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Jeroen Roovers (RETIRED)
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks:
 
Reported: 2020-03-31 13:47 UTC by Ionen Wolkens
Modified: 2020-04-14 13:11 UTC (History)
2 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 Ionen Wolkens gentoo-dev 2020-03-31 13:47:34 UTC
Commit
    https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5eefb61d11a77c123475fec73db819fa6121b7f2
added proper support to run as non-root when USE=caps but /var/lib/chrony is still created as root:root preventing chrony from writing the drift file:
    Mar 31 09:36:12 [chronyd] chronyd exiting
    Mar 31 09:36:12 [chronyd] Could not open /var/lib/chrony/drift.tmp : Permission denied

For comparison, net-misc/ntp does:
    keepdir /var/lib/ntp
    use prefix || fowners ntp:ntp /var/lib/ntp
Although in ntp's case the addition of ntp:ntp user/group is non-conditional regardless of USE=caps

ntp:ntp on /var/lib/chrony allows it as expected:
    $ ls -l /var/lib/chrony/drift 
    -rw-r--r-- 1 ntp ntp 42 Mar 31 09:37 /var/lib/chrony/drift

The /var/log/chrony permissions is likely an issue too, but I personally mask that directory+logrotate script since I have syslog handle chrony's logs, so I won't comment more on that. Albeit I'd "personally" argue the log directory should just be done away with but it'd break configs that specify 'logdir /var/log/chrony' and may need a notice.
Comment 1 Thomas Deutschmann (RETIRED) gentoo-dev 2020-03-31 13:54:45 UTC
@ jer: Sam will work on this.
Comment 2 Kajzer 2020-04-05 14:05:02 UTC
Would be nice if someone could accept that PR anytime soon.
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-04-05 14:15:14 UTC
(In reply to Kajzer from comment #2)
> Would be nice if someone could accept that PR anytime soon.

It should get merged later today. It looks right to me (obviously), but if you'd like to test it and give us some feedback, that would of course be appreciated.
Comment 4 Kajzer 2020-04-05 16:09:53 UTC
(In reply to Sam James (sam_c) (security padawan) from comment #3)
> It should get merged later today. It looks right to me (obviously), but if
> you'd like to test it and give us some feedback, that would of course be
> appreciated.

Okay, I installed it just now, will know the results in the next hour (in 50 minutes from now), at the moment I'm receiving this every hour :
chronyd[2945]: Could not open /var/lib/chrony/drift.tmp : Permission denied

If it doesn't happen again I would say it's good.
Comment 5 Kajzer 2020-04-05 17:05:01 UTC
Tested 4.0_pre1-r2, seems to be fine now.

chronyd[17754]: chronyd version 4.0-pre1 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER -SIGND +ASYNCDNS +NTS +SECHASH -IPV6 -DEBUG)
chronyd[17754]: Frequency -29.501 +/- 0.043 ppm read from /var/lib/chrony/drift
chronyd[17754]: Loaded seccomp filter
chronyd[17754]: Selected source 134.215.114.200
chronyd[17754]: Selected source 107.21.100.177
Comment 6 Kajzer 2020-04-06 18:51:04 UTC
It's interesting that it still works when I downgraded to r1
I guess that's because of this in r2 :
fowners ntp:ntp /var/lib/chrony
fperms 770 /var/lib/chrony
Comment 7 Ionen Wolkens gentoo-dev 2020-04-06 20:43:37 UTC
(In reply to Kajzer from comment #6)
> It's interesting that it still works when I downgraded to r1
Yes, portage doesn't update permissions of already-existing directories during merge and only copies them over the first time. This is why the workaround in pkg_postinst() is needed, users could even be switching the flag on/off and depclean+remove ntp:ntp given it's conditional.

And -r1 is oblivious to all this leaving it alone, so for anyone waiting simply setting ntp:ntp yourself to those directories is fine and won't be lost in rebuilds.
Comment 8 Larry the Git Cow gentoo-dev 2020-04-14 13:11:50 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f5fbd34fc6db83dc94cefe8cae5577e21656b1a2

commit f5fbd34fc6db83dc94cefe8cae5577e21656b1a2
Author:     Sam James (sam_c) <sam@cmpct.info>
AuthorDate: 2020-04-06 21:51:20 +0000
Commit:     Thomas Deutschmann <whissi@gentoo.org>
CommitDate: 2020-04-14 13:09:57 +0000

    net-misc/chrony: Fix permissions with USE=caps
    
    Note that we explicitly do not adjust permissions due to
    possible security problems and it is counter to user-expectations.
    
    mjo has a good writeup [Link 1] on this which led to the decision
    to only inform the user of changes needed.
    
    Link 1: http://michael.orlitzky.com/articles/end_root_chowning_now_%28make_pkg_postinst_great_again%29.xhtml
    Closes: https://bugs.gentoo.org/715618
    Signed-off-by: Sam James (sam_c) <sam@cmpct.info>
    Closes: https://github.com/gentoo/gentoo/pull/15187
    Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>

 net-misc/chrony/chrony-3.5-r4.ebuild      | 172 +++++++++++++++++++++++++++++
 net-misc/chrony/chrony-4.0_pre1-r2.ebuild | 175 ++++++++++++++++++++++++++++++
 2 files changed, 347 insertions(+)