gitee.com/mysnapcore/mysnapd@v0.1.0/interfaces/builtin/audio_record.go (about) 1 // -*- Mode: Go; indent-tabs-mode: t -*- 2 3 /* 4 * Copyright (C) 2018 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 "gitee.com/mysnapcore/mysnapd/interfaces" 24 "gitee.com/mysnapcore/mysnapd/interfaces/apparmor" 25 "gitee.com/mysnapcore/mysnapd/snap" 26 ) 27 28 // The audio-record interface is the companion interface to the audio-playback 29 // interface and is not meant to be used without it. The design of this 30 // interface is based on the idea that the slot implementation (eg pulseaudio) 31 // is expected to query snapd on if the audio-record slot is connected or not 32 // and the audio service will mediate recording (ie, the rules below allow 33 // connecting to the audio service, but do not implement enforcement rules; it 34 // is up to the audio service to provide enforcement). If other audio recording 35 // servers require different security policy for record (eg, a different socket 36 // path), then those accesses will be added to this interface. 37 38 const audioRecordSummary = `allows audio recording via supporting services` 39 40 const audioRecordBaseDeclarationSlots = ` 41 audio-record: 42 allow-installation: 43 slot-snap-type: 44 - app 45 - core 46 deny-connection: 47 on-classic: false 48 deny-auto-connection: true 49 ` 50 51 const audioRecordConnectedPlugAppArmor = ` 52 # Access for communication with audio recording service done via 53 # audio-playback interface. The audio service will verify if the audio-record 54 # interface is connected. 55 ` 56 57 type audioRecordInterface struct{} 58 59 func (iface *audioRecordInterface) Name() string { 60 return "audio-record" 61 } 62 63 func (iface *audioRecordInterface) StaticInfo() interfaces.StaticInfo { 64 return interfaces.StaticInfo{ 65 Summary: audioRecordSummary, 66 ImplicitOnClassic: true, 67 BaseDeclarationSlots: audioRecordBaseDeclarationSlots, 68 } 69 } 70 71 func (iface *audioRecordInterface) AppArmorConnectedPlug(spec *apparmor.Specification, plug *interfaces.ConnectedPlug, slot *interfaces.ConnectedSlot) error { 72 spec.AddSnippet(audioRecordConnectedPlugAppArmor) 73 return nil 74 } 75 76 func (iface *audioRecordInterface) AutoConnect(*snap.PlugInfo, *snap.SlotInfo) bool { 77 return true 78 } 79 80 func init() { 81 registerIface(&audioRecordInterface{}) 82 }