github.com/meulengracht/snapd@v0.0.0-20210719210640-8bde69bcc84e/interfaces/builtin/timeserver_control.go (about) 1 // -*- Mode: Go; indent-tabs-mode: t -*- 2 3 /* 4 * Copyright (C) 2016 Canonical Ltd 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 3 as 8 * published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 package builtin 21 22 const timeserverControlSummary = `allows setting system time synchronization servers` 23 24 const timeserverControlBaseDeclarationSlots = ` 25 timeserver-control: 26 allow-installation: 27 slot-snap-type: 28 - core 29 deny-auto-connection: true 30 ` 31 32 // http://bazaar.launchpad.net/~ubuntu-security/ubuntu-core-security/trunk/view/head:/data/apparmor/policygroups/ubuntu-core/16.04/timeserver-control 33 const timeserverControlConnectedPlugAppArmor = ` 34 # Description: Can manage timeservers directly separate from config ubuntu-core. 35 # Can enable system clock NTP synchronization via timedated D-Bus interface, 36 # Can read all properties of /org/freedesktop/timedate1 D-Bus object; see 37 # https://www.freedesktop.org/wiki/Software/systemd/timedated/ 38 39 #include <abstractions/dbus-strict> 40 41 # Won't work until LP: #1504657 is fixed. Requires reboot until timesyncd 42 # notices the change or systemd restarts it. 43 /etc/systemd/timesyncd.conf rw, 44 45 # Introspection of org.freedesktop.timedate1 46 # do not use peer=(label=unconfined) here since this is DBus activated 47 dbus (send) 48 bus=system 49 path=/org/freedesktop/timedate1 50 interface=org.freedesktop.DBus.Introspectable 51 member=Introspect, 52 53 dbus (send) 54 bus=system 55 path=/org/freedesktop/timedate1 56 interface=org.freedesktop.timedate1 57 member="SetNTP" 58 peer=(label=unconfined), 59 60 # Read all properties from timedate1 61 # do not use peer=(label=unconfined) here since this is DBus activated 62 dbus (send) 63 bus=system 64 path=/org/freedesktop/timedate1 65 interface=org.freedesktop.DBus.Properties 66 member=Get{,All}, 67 68 # Receive timedate1 property changed events 69 dbus (receive) 70 bus=system 71 path=/org/freedesktop/timedate1 72 interface=org.freedesktop.DBus.Properties 73 member=PropertiesChanged 74 peer=(label=unconfined), 75 76 # As the core snap ships the timedatectl utility we can also allow 77 # clients to use it now that they have access to the relevant 78 # D-Bus method for controlling network time synchronization via 79 # timedatectl's set-ntp command. 80 /usr/bin/timedatectl{,.real} ixr, 81 82 # Silence this noisy denial. systemd utilities look at /proc/1/environ to see 83 # if running in a container, but they will fallback gracefully. No other 84 # interfaces allow this denial, so no problems with silencing it for now. Note 85 # that allowing this triggers a 'ptrace trace peer=unconfined' denial, which we 86 # want to avoid. 87 deny @{PROC}/1/environ r, 88 ` 89 90 func init() { 91 registerIface(&commonInterface{ 92 name: "timeserver-control", 93 summary: timeserverControlSummary, 94 implicitOnCore: true, 95 implicitOnClassic: true, 96 baseDeclarationSlots: timeserverControlBaseDeclarationSlots, 97 connectedPlugAppArmor: timeserverControlConnectedPlugAppArmor, 98 }) 99 }