Skip to content

Commit

Permalink
interfaces: bluez: create dbus policy permantenly
Browse files Browse the repository at this point in the history
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
morphis committed Apr 17, 2016
1 parent fd6acb7 commit bf2abce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 5 additions & 5 deletions interfaces/builtin/bluez.go
Expand Up @@ -157,7 +157,7 @@ sendmsg
socket
`)

var bluezConnectedPlugDBus = []byte(`
var bluezPermantedSlotDBus = []byte(`
<policy user="root">
<allow own="org.bluez"/>
<allow own="org.bluez.obex"/>
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion interfaces/builtin/bluez_test.go
Expand Up @@ -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)
}
Expand All @@ -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))
}

Expand Down

0 comments on commit bf2abce

Please sign in to comment.