github.com/ubuntu-core/snappy@v0.0.0-20210827154228-9e584df982bb/interfaces/builtin/timezone_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 timezoneControlSummary = `allows setting system timezone` 23 24 const timezoneControlBaseDeclarationSlots = ` 25 timezone-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/timezone-control 33 const timezoneControlConnectedPlugAppArmor = ` 34 # Description: Can manage timezones directly separate from 'config ubuntu-core'. 35 # Can change timezone 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 /usr/share/zoneinfo/ r, 42 /usr/share/zoneinfo/** r, 43 /etc/{,writable/}timezone rw, 44 /etc/{,writable/}localtime rw, 45 /etc/{,writable/}localtime.tmp rw, # Required for the timedatectl wrapper (LP: #1650688) 46 47 # Introspection of org.freedesktop.timedate1 48 # do not use peer=(label=unconfined) here since this is DBus activated 49 dbus (send) 50 bus=system 51 path=/org/freedesktop/timedate1 52 interface=org.freedesktop.DBus.Introspectable 53 member=Introspect, 54 55 dbus (send) 56 bus=system 57 path=/org/freedesktop/timedate1 58 interface=org.freedesktop.timedate1 59 member="SetTimezone" 60 peer=(label=unconfined), 61 62 # Read all properties from timedate1 63 # do not use peer=(label=unconfined) here since this is DBus activated 64 dbus (send) 65 bus=system 66 path=/org/freedesktop/timedate1 67 interface=org.freedesktop.DBus.Properties 68 member=Get{,All}, 69 70 # Receive timedate1 property changed events 71 dbus (receive) 72 bus=system 73 path=/org/freedesktop/timedate1 74 interface=org.freedesktop.DBus.Properties 75 member=PropertiesChanged 76 peer=(label=unconfined), 77 78 # As the core snap ships the timedatectl utility we can also allow 79 # clients to use it now that they have access to the relevant 80 # D-Bus method for setting the timezone via timedatectl's set-timezone 81 # command. 82 /usr/bin/timedatectl{,.real} ixr, 83 84 # Silence this noisy denial. systemd utilities look at /proc/1/environ to see 85 # if running in a container, but they will fallback gracefully. No other 86 # interfaces allow this denial, so no problems with silencing it for now. Note 87 # that allowing this triggers a 'ptrace trace peer=unconfined' denial, which we 88 # want to avoid. 89 deny @{PROC}/1/environ r, 90 ` 91 92 func init() { 93 registerIface(&commonInterface{ 94 name: "timezone-control", 95 summary: timezoneControlSummary, 96 implicitOnCore: true, 97 implicitOnClassic: true, 98 baseDeclarationSlots: timezoneControlBaseDeclarationSlots, 99 connectedPlugAppArmor: timezoneControlConnectedPlugAppArmor, 100 }) 101 }