Permalink
Browse files

interfaces: bluez: create dbus policy permantenly

If we don't define the dbus policy snippet for the permanent slot bluez
wouldn't start automatically as long as not plug is connected. We want
the bluez service to run even when no connection exists.

Signed-off-by: Simon Fels <simon.fels@canonical.com>
  • Loading branch information...
1 parent fd6acb7 commit bf2abcec0453ad8edd9bdcdeb6f16cd4f8c38b57 Simon Fels committed Apr 17, 2016
Showing with 9 additions and 6 deletions.
  1. +5 −5 interfaces/builtin/bluez.go
  2. +4 −1 interfaces/builtin/bluez_test.go
@@ -157,7 +157,7 @@ sendmsg
socket
`)
-var bluezConnectedPlugDBus = []byte(`
+var bluezPermantedSlotDBus = []byte(`
<policy user="root">
<allow own="org.bluez"/>
<allow own="org.bluez.obex"/>
@@ -196,13 +196,11 @@ func (iface *BluezInterface) PermanentPlugSnippet(plug *interfaces.Plug, securit
func (iface *BluezInterface) ConnectedPlugSnippet(plug *interfaces.Plug, slot *interfaces.Slot, securitySystem interfaces.SecuritySystem) ([]byte, error) {
switch securitySystem {
- case interfaces.SecurityDBus:
- return bluezConnectedPlugDBus, nil
case interfaces.SecurityAppArmor:
return bluezConnectedPlugAppArmor, nil
case interfaces.SecuritySecComp:
return bluezConnectedPlugSecComp, nil
- case interfaces.SecurityUDev:
+ case interfaces.SecurityUDev, interfaces.SecurityDBus:
return nil, nil
default:
return nil, interfaces.ErrUnknownSecurity
@@ -215,7 +213,9 @@ func (iface *BluezInterface) PermanentSlotSnippet(slot *interfaces.Slot, securit
return bluezPermanentSlotAppArmor, nil
case interfaces.SecuritySecComp:
return bluezPermanentSlotSecComp, nil
- case interfaces.SecurityUDev, interfaces.SecurityDBus:
+ case interfaces.SecurityDBus:
+ return bluezPermantedSlotDBus, nil
+ case interfaces.SecurityUDev:
return nil, nil
default:
return nil, interfaces.ErrUnknownSecurity
@@ -58,7 +58,7 @@ func (s *BluezInterfaceSuite) TestUnusedSecuritySystems(c *C) {
snippet, err = s.iface.PermanentSlotSnippet(s.slot, interfaces.SecurityUDev)
c.Assert(err, IsNil)
c.Assert(snippet, IsNil)
- snippet, err = s.iface.PermanentSlotSnippet(s.slot, interfaces.SecurityDBus)
+ snippet, err = s.iface.ConnectedPlugSnippet(s.plug, s.slot, interfaces.SecurityDBus)
c.Assert(err, IsNil)
c.Assert(snippet, IsNil)
}
@@ -76,6 +76,9 @@ func (s *BluezInterfaceSuite) TestUsedSecuritySystems(c *C) {
}
snippet, err := s.iface.ConnectedPlugSnippet(s.plug, s.slot, interfaces.SecurityDBus)
c.Assert(err, IsNil)
+ c.Assert(snippet, IsNil)
+ snippet, err = s.iface.PermanentSlotSnippet(s.slot, interfaces.SecurityDBus)
+ c.Assert(err, IsNil)
c.Assert(snippet, Not(IsNil))
}

0 comments on commit bf2abce

Please sign in to comment.