github.com/bugraaydogar/snapd@v0.0.0-20210315170335-8c70bb858939/interfaces/builtin/camera.go (about) 1 // -*- Mode: Go; indent-tabs-mode: t -*- 2 3 /* 4 * Copyright (C) 2016-2017 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 cameraSummary = `allows access to all cameras` 23 24 const cameraBaseDeclarationSlots = ` 25 camera: 26 allow-installation: 27 slot-snap-type: 28 - core 29 deny-auto-connection: true 30 ` 31 32 const cameraConnectedPlugAppArmor = ` 33 # Until we have proper device assignment, allow access to all cameras 34 /dev/video[0-9]* rw, 35 36 # VideoCore cameras (shared device with VideoCore/EGL) 37 /dev/vchiq rw, 38 39 # Allow detection of cameras. Leaks plugged in USB device info 40 /sys/bus/usb/devices/ r, 41 /sys/devices/pci**/usb*/**/busnum r, 42 /sys/devices/pci**/usb*/**/devnum r, 43 /sys/devices/pci**/usb*/**/idVendor r, 44 /sys/devices/pci**/usb*/**/idProduct r, 45 /sys/devices/pci**/usb*/**/interface r, 46 /sys/devices/pci**/usb*/**/modalias r, 47 /sys/devices/pci**/usb*/**/speed r, 48 /run/udev/data/c81:[0-9]* r, # video4linux (/dev/video*, etc) 49 /run/udev/data/+usb:* r, 50 /sys/class/video4linux/ r, 51 /sys/devices/pci**/usb*/**/video4linux/** r, 52 ` 53 54 var cameraConnectedPlugUDev = []string{ 55 `KERNEL=="video[0-9]*"`, 56 `KERNEL=="vchiq"`, 57 } 58 59 func init() { 60 registerIface(&commonInterface{ 61 name: "camera", 62 summary: cameraSummary, 63 implicitOnCore: true, 64 implicitOnClassic: true, 65 baseDeclarationSlots: cameraBaseDeclarationSlots, 66 connectedPlugAppArmor: cameraConnectedPlugAppArmor, 67 connectedPlugUDev: cameraConnectedPlugUDev, 68 }) 69 }