interfaces/builtin: support time and date settings via 'org.freedesktop.timedate1 #1832

Merged
merged 21 commits into from Sep 28, 2016

Conversation

Projects
None yet
4 participants
Contributor

stolowski commented Sep 2, 2016

Added new timedate-control interface and updated two existing interfaces: timeserver-control and timezone-control to allow access to respective parts of systemd' org.freedesktop.timedate1 interface (lp #1616052).

The test shamelessly stolen from unity7_test.go.

Tested introspection and a property getter manually with:

$ timedatetest.gdbus introspect --system --dest org.freedesktop.timedate1 --object-path /org/freedesktop/timedate1
$ timedatetest.gdbus call --system --dest org.freedesktop.timedate1 --object-path /org/freedesktop/timedate1 --method org.freedesktop.DBus.Properties.Get "org.freedesktop.timedate1" "Timezone"

with the following simple snap:

name: timedatetest
version: 1.0
summary: A test
description: A test

apps:
gdbus:
command: usr/bin/gdbus
plugs: [timedate-control]

parts:
gdbus:
plugin: nil
stage-packages:
- libglib2.0-bin

interfaces/builtin/timedate_control.go
+ member="Set{Time,Timezone,LocalRTC,NTP}"
+ peer=(label=unconfined),
+
+dbus (receive, send)
@zyga

zyga Sep 2, 2016

Contributor

Why send and receive? // my knowledge of apparmor is rusty here.

@stolowski

stolowski Sep 2, 2016

Contributor

Fair point. receive is needed for property change signals (and only for them) and it was a little bit too lenient. I've split this block into two and added comments - property change signals need 'receive', Get & GetAll need 'send'.

interfaces/builtin/timedate_control.go
+// NewTimeDateControlInterface returns a new "time-date-control" interface.
+func NewTimeDateControlInterface() interfaces.Interface {
+ return &commonInterface{
+ name: "time-date-control",
@zyga

zyga Sep 2, 2016

Contributor

This is inconsistent with the file name, either call the module time_data_control.go or rename the interface to timedate-control.

@stolowski

stolowski Sep 2, 2016

Contributor

Ok, renamed to timedate-control.

Contributor

zyga commented Sep 2, 2016

Please document this interface so that we know what it allows to do (in docs/interfaces.md) and decide if it is reserved (restricted to trusted snaps) or not. I'd say it is and it should auto-connect.

I have one question about apparmor, please ask @jdstrand for a review after you know the answer to my question.

Contributor

stolowski commented Sep 2, 2016

@zyga I've added a short doc and made it auto-connect. I'm not sure however about the making it 'reserved', is it about marking it reservedForOs (which it is already)?

Contributor

niemeyer commented Sep 19, 2016

Needs conflict solving, and a review from @jdstrand. LGTM other than that.

@niemeyer niemeyer changed the title from Added time-date-control interface for org.freedesktop.timedate1 to interfaces/builtin: time-date-control for org.freedesktop.timedate1 Sep 19, 2016

I think this PR should be renamed as "support time and date settings via 'org.freedesktop.timedate1" and you should add the timedate-control interface (please rename from time-date-control to timedate-control) and update the timezone-control and timeserver-control as described (each should work without the others, so add the seccomp and dbus introspection rules to all 3).

interfaces/builtin/timedate_control.go
+ bus=system
+ path=/org/freedesktop/timedate1
+ interface=org.freedesktop.timedate1
+ member="Set{Time,Timezone,LocalRTC,NTP}"
@jdstrand

jdstrand Sep 22, 2016

Contributor

We already have the timeserver-control interface for NTP. NTP calls should be moved there.

We already have the timezone-control interface for adjusting TZ. TZ calls should be moved there.

SetTime and SetLocalRTC can remain here.

interfaces/builtin/timedate_control.go
+ path=/org/freedesktop/timedate1
+ interface=org.freedesktop.DBus.Properties
+ member=PropertiesChanged
+ peer=(label=unconfined),
@jdstrand

jdstrand Sep 22, 2016

Contributor

Unfortunately we can't mediate on method data and systemd only provides Get methods for properties, so you'll need to have these two rules in timezone-control and timeserver-control. This means that all the time* interfaces will be able to read each others properties, but at least they won't be able to Set them.

interfaces/builtin/timedate_control.go
+ connectedPlugAppArmor: timeDateControlConnectedPlugAppArmor,
+ connectedPlugSecComp: timeDateControlConnectedPlugSecComp,
+ reservedForOS: true,
+ autoConnect: true,
@jdstrand

jdstrand Sep 22, 2016

Contributor

Adjusting the time on a system is a privileged action and this should not autoconnect.

Contributor

jdstrand commented Sep 22, 2016

'time-control' is probably a better name than timedate-control. Will want @niemeyer to weigh in on that.

@stolowski stolowski changed the title from interfaces/builtin: time-date-control for org.freedesktop.timedate1 to interfaces/builtin: support time and date settings via 'org.freedesktop.timedate1 Sep 23, 2016

Contributor

stolowski commented Sep 23, 2016

@jdstrand Thanks for the review, I have followed your suggestions and moved some permissions to the other interfaces. All interfaces have permissions to read the properties as well as to introspect timedate1 object.

+ PanicMatches, `plug is not of interface "timedate-control"`)
+}
+
+func (s *TimeDateControlTestInterfaceSuite) TestUnusedSecuritySystems(c *C) {
@zyga

zyga Sep 23, 2016

Contributor

Let's drop this test please. We just concluded a large simplification where those tests were axed.

@stolowski

stolowski Sep 25, 2016

Contributor

Ok, removed.

+1 on security policy changes. Please adjust docs/interfaces.md and implicit.go

I think that 'time-control' would be a nicer name for this interface. @niemeyer, can you comment on if you prefer 'timedate-control' or 'time-control' (or something else)?

docs/interfaces.md
+### timedate-control
+
+Can modify time/date exposed via D-Bus by systemd-timedated and read all
+all properties of /org/freedesktop/timedate1 D-Bus object.
@jdstrand

jdstrand Sep 26, 2016

Contributor

Can we rephrase this to be:

Can set system time and date and query systemd-timedated for time information.

It's possible we may allow setting the time or the date in other ways (eg, like we do with timezone-control and timeserver-control).

docs/interfaces.md
+all properties of /org/freedesktop/timedate1 D-Bus object.
+
+* Auto-Connect: yes
+
### timeserver-control
Can manage timeservers directly separate from ``config core``.
@jdstrand

jdstrand Sep 26, 2016

Contributor

Can you update this to be:

Can manage timeservers via systemd-timedated and directly separate from ``config core``

### timezone-control

Can manage timezone via systemd-timedated and directly separate from ``config core``

* Auto-Connect: no

In other words, update timeserver-control to reference systemd-timedated and add timezone-control.

@stolowski

stolowski Sep 29, 2016

Contributor

@jdstrand apologies for forgetting about this change, I'll address it in a separete PR.

snap/implicit.go
@@ -54,6 +54,7 @@ var implicitSlots = []string{
"timezone-control",
"tpm",
"kernel-module-control",
+ "timedate-control",
@jdstrand

jdstrand Sep 26, 2016

Contributor

Can you put this in alphabetical order?

Contributor

jdstrand commented Sep 26, 2016

Note that I approved the changes you made, but still request further changes (using github's 'comment' mechanism instead of 'request changes' to avoid blocking on me).

Contributor

niemeyer commented Sep 27, 2016

+1 on time-control if we intend this interface to remain intermediating the ability to set the time even if we change the backend.

LGTM once @jdstrand is happy.

@niemeyer niemeyer added the Reviewed label Sep 27, 2016

Contributor

jdstrand commented Sep 27, 2016

"+1 on time-control if we intend this interface to remain intermediating the ability to set the time even if we change the backend."

Yes this is the intent. In this manner it is similar to timezone-control and timeserver-control.

@stolowski - we now have agreement. Please rename to 'time-control' and I can do the final review.

Contributor

stolowski commented Sep 28, 2016

@jdstrand @niemeyer Ok, renamed to time-control and address other comments re docs (and I hope I didn't miss anything).

@niemeyer niemeyer merged commit 677ed08 into snapcore:master Sep 28, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Contributor

jdstrand commented Sep 28, 2016

FYI, the request to add timezone-control to docs/interfaces.md was missed in this merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment