github.com/kubiko/snapd@v0.0.0-20201013125620-d4f3094d9ddf/interfaces/builtin/snapd_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 import ( 23 "fmt" 24 25 "github.com/snapcore/snapd/snap" 26 ) 27 28 const snapdControlSummary = `allows communicating with snapd` 29 30 const snapdControlBaseDeclarationPlugs = ` 31 snapd-control: 32 allow-installation: false 33 deny-auto-connection: true 34 ` 35 36 const snapdControlBaseDeclarationSlots = ` 37 snapd-control: 38 allow-installation: 39 slot-snap-type: 40 - core 41 deny-auto-connection: true 42 ` 43 44 const snapdControlConnectedPlugAppArmor = ` 45 # Description: Can manage snaps via snapd. 46 47 /run/snapd.socket rw, 48 ` 49 50 type snapControlInterface struct { 51 commonInterface 52 } 53 54 func (iface *snapControlInterface) BeforePreparePlug(plug *snap.PlugInfo) error { 55 if refreshSchedule, ok := plug.Attrs["refresh-schedule"].(string); ok { 56 if refreshSchedule != "managed" { 57 return fmt.Errorf("unsupported refresh-schedule value: %q", refreshSchedule) 58 } 59 } 60 61 return nil 62 } 63 64 func init() { 65 registerIface(&snapControlInterface{commonInterface{ 66 name: "snapd-control", 67 summary: snapdControlSummary, 68 implicitOnCore: true, 69 implicitOnClassic: true, 70 baseDeclarationPlugs: snapdControlBaseDeclarationPlugs, 71 baseDeclarationSlots: snapdControlBaseDeclarationSlots, 72 connectedPlugAppArmor: snapdControlConnectedPlugAppArmor, 73 }}) 74 }