forked from canonical/snapd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
raw_usb.go
81 lines (68 loc) · 2.42 KB
/
raw_usb.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// -*- Mode: Go; indent-tabs-mode: t -*-
/*
* Copyright (C) 2017 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package builtin
const rawusbSummary = `allows raw access to all USB devices`
const rawusbBaseDeclarationSlots = `
raw-usb:
allow-installation:
slot-snap-type:
- core
deny-auto-connection: true
`
const rawusbConnectedPlugAppArmor = `
# Description: Allow raw access to all connected USB devices.
# This gives privileged access to the system.
/dev/bus/usb/[0-9][0-9][0-9]/[0-9][0-9][0-9] rw,
# Allow access to all ttyUSB devices too
/dev/tty{USB,ACM}[0-9]* rwk,
@{PROC}/tty/drivers r,
# Allow raw access to USB printers (i.e. for receipt printers in POS systems).
/dev/usb/lp[0-9]* rwk,
# Allow detection of usb devices. Leaks plugged in USB device info
/sys/bus/usb/devices/ r,
/sys/devices/pci**/usb[0-9]** r,
/sys/devices/platform/soc/*.usb/usb[0-9]** r,
/sys/devices/platform/scb/*.pcie/pci**/usb[0-9]** r,
/run/udev/data/c16[67]:[0-9] r, # ACM USB modems
/run/udev/data/b180:* r, # various USB block devices
/run/udev/data/c18[089]:* r, # various USB character devices: USB serial converters, etc.
/run/udev/data/+usb:* r,
`
const rawusbConnectedPlugSecComp = `
# Description: Allow raw access to all connected USB devices.
# This gives privileged access to the system.
# kernel uevents
socket AF_NETLINK - NETLINK_KOBJECT_UEVENT
`
var rawusbConnectedPlugUDev = []string{
`SUBSYSTEM=="usb"`,
`SUBSYSTEM=="usbmisc"`,
`SUBSYSTEM=="tty", ENV{ID_BUS}=="usb"`,
}
func init() {
registerIface(&commonInterface{
name: "raw-usb",
summary: rawusbSummary,
implicitOnCore: true,
implicitOnClassic: true,
baseDeclarationSlots: rawusbBaseDeclarationSlots,
connectedPlugAppArmor: rawusbConnectedPlugAppArmor,
connectedPlugSecComp: rawusbConnectedPlugSecComp,
connectedPlugUDev: rawusbConnectedPlugUDev,
})
}