$ git diff
diff --git a/interfaces/builtin/bluez.go b/interfaces/builtin/bluez.go
index 11ace98..8c6cf7f 100644
--- a/interfaces/builtin/bluez.go
+++ b/interfaces/builtin/bluez.go
@@ -21,6 +21,7 @@ package builtin
import (
"github.com/ubuntu-core/snappy/interfaces"
+ "regexp"
)
var bluezPermanentSlotAppArmor = []byte(`
@@ -81,6 +82,8 @@ var bluezPermanentSlotAppArmor = []byte(`
interface=org.freedesktop.DBus.**,
`)
+var repre = regexp.MustCompile("###[A-Z]+###")
+
var bluezConnectedPlugAppArmor = []byte(`
# Description: Allow using bluez service. Reserved because this gives
# privileged access to the bluez service.
@@ -91,7 +94,7 @@ var bluezConnectedPlugAppArmor = []byte(`
# Allow all access to bluez service
dbus (receive, send)
bus=system
- peer=(label=bluez5_bluez_*),
+ peer=(label=snap.###SLOTLABEL###.*),
dbus (send)
bus=system
@@ -199,7 +202,15 @@ func (iface *BluezInterface) ConnectedPlugSnippet(plug *interfaces.Plug, slot *i
case interfaces.SecurityDBus:
return bluezConnectedPlugDBus, nil
case interfaces.SecurityAppArmor:
- return bluezConnectedPlugAppArmor, nil
+ policy := repre.ReplaceAllFunc(bluezConnectedPlugAppArmor, func(v []byte) []byte {
+ switch string(v) {
+ case "###SLOTNAME###":
+ // FIXME: this needs to be <snapname>.<app>
+ return []byte(slot.Snap.Name())
+ }
+ return v
+ })
+ return policy, nil
case interfaces.SecuritySecComp:
return bluezConnectedPlugSecComp, nil
case interfaces.SecurityUDev: