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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140 | From de90b6637af75e1f774a1ab350da6ec9936c7259 Mon Sep 17 00:00:00 2001
From: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Date: Thu, 5 May 2016 14:14:11 +0200
Subject: [PATCH] add pulseaudio client interface
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
---
interfaces/builtin/all.go | 1 +
interfaces/builtin/pulseaudio.go | 95 ++++++++++++++++++++++++++++++++++++++++
snap/implicit.go | 1 +
3 files changed, 97 insertions(+)
create mode 100644 interfaces/builtin/pulseaudio.go
diff --git a/interfaces/builtin/all.go b/interfaces/builtin/all.go
index 5cc9edf..0661ef8 100644
--- a/interfaces/builtin/all.go
+++ b/interfaces/builtin/all.go
@@ -42,6 +42,7 @@ var allInterfaces = []interfaces.Interface{
NewUnity7Interface(),
NewX11Interface(),
NewOpenglInterface(),
+ &PulseAudioInterface{},
}
// Interfaces returns all of the built-in interfaces.
diff --git a/interfaces/builtin/pulseaudio.go b/interfaces/builtin/pulseaudio.go
new file mode 100644
index 0000000..7d7f315
--- /dev/null
+++ b/interfaces/builtin/pulseaudio.go
@@ -0,0 +1,95 @@
+// -*- Mode: Go; indent-tabs-mode: t -*-
+
+/*
+ * Copyright (C) 2016 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
+
+import (
+ "github.com/ubuntu-core/snappy/interfaces"
+)
+
+var pulseaudioConnectedPlugAppArmor = []byte(`
+/etc/pulse r,
+/etc/pulse/* r,
+/dev/shm/pulse-shm-* mrwlkix,
+owner /run/user/*/pulse/native rw,
+`)
+
+var pulseaudioConnectedPlugSecComp = []byte(`
+setsockopt
+connect
+sendto
+`)
+
+type PulseAudioInterface struct{}
+
+func (iface *PulseAudioInterface) Name() string {
+ return "pulseaudio"
+}
+
+func (iface *PulseAudioInterface) PermanentPlugSnippet(plug *interfaces.Plug, securitySystem interfaces.SecuritySystem) ([]byte, error) {
+ switch securitySystem {
+ case interfaces.SecurityDBus, interfaces.SecurityAppArmor, interfaces.SecuritySecComp, interfaces.SecurityUDev:
+ return nil, nil
+ default:
+ return nil, interfaces.ErrUnknownSecurity
+ }
+}
+
+func (iface *PulseAudioInterface) ConnectedPlugSnippet(plug *interfaces.Plug, slot *interfaces.Slot, securitySystem interfaces.SecuritySystem) ([]byte, error) {
+ switch securitySystem {
+ case interfaces.SecurityAppArmor:
+ return pulseaudioConnectedPlugAppArmor, nil
+ case interfaces.SecuritySecComp:
+ return pulseaudioConnectedPlugSecComp, nil
+ case interfaces.SecurityUDev, interfaces.SecurityDBus:
+ return nil, nil
+ default:
+ return nil, interfaces.ErrUnknownSecurity
+ }
+}
+
+func (iface *PulseAudioInterface) PermanentSlotSnippet(slot *interfaces.Slot, securitySystem interfaces.SecuritySystem) ([]byte, error) {
+ switch securitySystem {
+ case interfaces.SecurityDBus, interfaces.SecurityAppArmor, interfaces.SecuritySecComp, interfaces.SecurityUDev:
+ return nil, nil
+ default:
+ return nil, interfaces.ErrUnknownSecurity
+ }
+}
+
+func (iface *PulseAudioInterface) ConnectedSlotSnippet(plug *interfaces.Plug, slot *interfaces.Slot, securitySystem interfaces.SecuritySystem) ([]byte, error) {
+ switch securitySystem {
+ case interfaces.SecurityDBus, interfaces.SecurityAppArmor, interfaces.SecuritySecComp, interfaces.SecurityUDev:
+ return nil, nil
+ default:
+ return nil, interfaces.ErrUnknownSecurity
+ }
+}
+
+func (iface *PulseAudioInterface) SanitizePlug(slot *interfaces.Plug) error {
+ return nil
+}
+
+func (iface *PulseAudioInterface) SanitizeSlot(slot *interfaces.Slot) error {
+ return nil
+}
+
+func (iface *PulseAudioInterface) AutoConnect() bool {
+ return true
+}
diff --git a/snap/implicit.go b/snap/implicit.go
index 839d8d4..88e4bff 100644
--- a/snap/implicit.go
+++ b/snap/implicit.go
@@ -37,6 +37,7 @@ var implicitSlots = []string{
"unity7",
"x11",
"opengl",
+ "pulseaudio",
}
// AddImplicitSlots adds implicitly defined slots to a given snap.
--
2.7.4
|