Bug 1306046 - chrony systemd service unit is missing "ConditionCapability=CAP_SYS_TIME"
chrony systemd service unit is missing "ConditionCapability=CAP_SYS_TIME"
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: chrony (Show other bugs)
7.2
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Miroslav Lichvar
Karel Volný
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-02-09 18:20 EST by Elias Probst
Modified: 2017-08-01 12:20 EDT (History)
2 users (show)

See Also:
Fixed In Version: chrony-3.1-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-08-01 12:20:39 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Elias Probst 2016-02-09 18:20:12 EST
Description of problem:
Starting RHEL7/CentOS7 in a systemd-nspawn container results in chronyd failing to start, because adjtimex() can't be called from an unprivileged container.

The systemd service unit for chrony needs to have the following line in the [Unit] section to prevent it from being started in container environments:

ConditionVirtualization=!container
Comment 2 Miroslav Lichvar 2016-02-12 08:39:48 EST
What if someone wants to run chronyd in a privileged container? It's probably not very common, or even an advisable thing to do, but I'm not sure if the default unit file should be preventing it.

The chronyd service is disabled by default, so I'm wondering what has enabled in the container.
Comment 3 Elias Probst 2016-02-12 11:39:45 EST
(In reply to Miroslav Lichvar from comment #2)
> What if someone wants to run chronyd in a privileged container? It's
> probably not very common, or even an advisable thing to do, but I'm not sure
> if the default unit file should be preventing it.

I think the default units should always be built under the assumption of a most common scenario. Special scenarios like running chronyd from within a privileged container can be easily achieved through a drop-in 2-line configuration like:

/etc/systemd/system/chronyd.service.d/privileged-container.conf:
[Unit]
ConditionVirtualization=!container


> The chronyd service is disabled by default, so I'm wondering what has
> enabled in the container.

To me it looks like it is enabled by default (at least on CentOS 7.2), but I can't find a corresponding .preset file.
This is possibly a side-effect of chronyd being registered as ntp-unit in /usr/lib/systemd/ntp-units.d/50-chronyd.list
Comment 5 Miroslav Lichvar 2017-01-17 03:38:52 EST
I noticed that the chrony unit file in Debian is now using ConditionCapability=CAP_SYS_TIME. If I understand it correctly, this prevents starting of chronyd when it doesn't have privileges to call adjtimex(), i.e. the issue that was reported in this bug. To me it looks like a cleaner solution than the ConditionalVirtualization directive.
Comment 6 Elias Probst 2017-01-17 05:16:49 EST
(In reply to Miroslav Lichvar from comment #5)
> I noticed that the chrony unit file in Debian is now using
> ConditionCapability=CAP_SYS_TIME. If I understand it correctly, this
> prevents starting of chronyd when it doesn't have privileges to call
> adjtimex(), i.e. the issue that was reported in this bug. To me it looks
> like a cleaner solution than the ConditionalVirtualization directive.

I agree - this is a better solution of which I didn't think when writing the initial report.
Comment 9 errata-xmlrpc 2017-08-01 12:20:39 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:1908

Note You need to log in before you can comment on or make changes to this bug.