Managing time, date and timezone in Ubuntu Core

What is the recommended way for time, date, settings to be managed on my Ubuntu Core platform. For now I am experimenting on the command line but eventually this will be performed from within in Java application snap.

there is a time-control interface the core snap provides that allows access to the dbus org.freedesktop.timedate1 object and to the hwclock command.

Does this interface also include access to the date command?

looking at https://github.com/snapcore/snapd/blob/master/interfaces/builtin/time_control.go it only gives access to the dbus service and the hwclock command.

Just looking into this further. Using DBus isn’t exactly what I want to do, so I was looking into also the use of timedatectl command. Is it permissible to use this with a .snap ?

i guess thats a question to the security team … @jdstrand ?

It should be alright to allow the use of the timedatectl program since it is simply a frontend for the org.freedesktop.timedate1 D-Bus interface. The interface currently only allows for using the “set-time” and “set-local-rtc” commands. Is that sufficient?

sadly not …

  • the interface doesnt allow execution of the tool(s) themselves (that is: /usr/bin/timedatectl and /usr/bin/timedatectl.real), the only binary i see allowed in the current interface is /sbin/hwclock…

  • we need to allow setting the timezone too.
    i already landed https://github.com/snapcore/snapd/pull/3316
    to allow access to /etc/localtime, we’d also need the set-timezone and list-timezones commands allowed beyond that.

Right, I was mostly asking @jenny.murphy if access to the set-timezone and list-timezone commands was needed. I would assume so judging from the subject of this thread. I didn’t notice managing the timezone being mentioned in the subject prior to my previous reply.

Allowing access to timedatectl at all times seems fine since this is just a client. Then, we can allow access to the relevant DBus objects and methods when the respective interfaces are connected (time-control, timezone-control, etc).

We also shouldn’t require a special interface to read the time, but I assume that’s already the case?

I investigated the possibility of allowing access to timedatectl at all times. It would require us to grant all applications access to the D-Bus system bus as timedatectl is useless otherwise. That’s a change that I’d want @jdstrand to weigh in on.

I’ve prepared a pull request for usage of timedatectl: https://github.com/snapcore/snapd/pull/3364

Hi, sorry for the delay in confirming, but yes my application needs to be able to change the system timezone through some means.

The fix has been committed in snapd. You’ll be able to use timedatectl to manage the time using the time-control interface and change the timezone using the timezone-control interface.

May I ask, when does this become available in an update from the stable channel?

@zyga-snapd could you give as estimate to @jenny.murphy as to when https://github.com/snapcore/snapd/commit/24d67cbdc0df5d64dcfc8edeada81bfbb5cca0a2 will be released into the stable channel? I haven’t been keeping up with the snapd release cadence to give an accurate estimate.

Hi! Is it possible to release this fix with 2.26.4 snapd? We need it so much=)

Hi, to use this will I just need to connect using the time-control interface and the timezone-control interface. In other words, timedatectl will be available to my snap. Or do I need to build the timedatectl binary into my snap similar to

timedatectl will be available in time-control, timeserver-control and timezone-control once https://github.com/snapcore/snapd/pull/3364 is in the stable core snap. This is merged in trunk and I believe it will be a part of snapd 2.26, which AIUI will hopefully be released to stable soon.

Will is be possible to use timedatectl set-ntp also with this update?