interfaces: expose bluez interface on classic OS #3812

Merged
merged 1 commit into from Aug 31, 2017

Conversation

Projects
None yet
6 participants
Contributor

willdeberry commented Aug 26, 2017

No description provided.

codecov-io commented Aug 26, 2017

Codecov Report

Merging #3812 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3812      +/-   ##
==========================================
+ Coverage    75.7%   75.71%   +<.01%     
==========================================
  Files         409      409              
  Lines       35227    35241      +14     
==========================================
+ Hits        26670    26684      +14     
  Misses       6672     6672              
  Partials     1885     1885
Impacted Files Coverage Δ
interfaces/builtin/bluez.go 100% <100%> (ø) ⬆️
wrappers/binaries.go 72.72% <0%> (-6.82%) ⬇️
interfaces/sorting.go 98.71% <0%> (-1.29%) ⬇️
overlord/snapstate/snapstate.go 80.7% <0%> (+0.25%) ⬆️
cmd/snap/cmd_aliases.go 95% <0%> (+1.66%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 93c1d78...1d52415. Read the comment docs.

@pedronis pedronis changed the title from Expose bluez interface on classic OS to interfaces: expose bluez interface on classic OS Aug 29, 2017

@zyga zyga requested review from jdstrand and zyga and removed request for jdstrand Aug 30, 2017

zyga approved these changes Aug 30, 2017

Looks good to me, please resolve the conflicts and get a 2nd +1 from @jdstrand

@zyga zyga requested a review from jdstrand Aug 30, 2017

Member

chipaca commented Aug 30, 2017

Shouldn't this only expose bluez if the system has bluez running?

Thanks for the updates! This is well on its way, just a few more small changes and we should be able to commit this.

deny-auto-connection: true
+ deny-connection:
+ on-classic: false
`
@jdstrand

jdstrand Aug 30, 2017

Contributor

The base declaration changes look good.

- spec.AddSnippet(bluezPermanentSlotAppArmor)
+ if !release.OnClassic {
+ spec.AddSnippet(bluezPermanentSlotAppArmor)
+ }
return nil
}
@jdstrand

jdstrand Aug 30, 2017

Contributor

You need to do this same sort of thing in SecCompPermanentSlot()

interfaces/builtin/bluez_test.go
}
func (s *BluezInterfaceSuite) TestDBusSpec(c *C) {
+ restore := release.MockOnClassic(false)
@jdstrand

jdstrand Aug 30, 2017

Contributor

Please add this comment before this line:

// on a core system with bluez slot coming from a regular app snap.
interfaces/builtin/bluez_test.go
c.Assert(spec.SecurityTags(), DeepEquals, []string{"snap.producer.app"})
c.Assert(spec.SnippetForTag("snap.producer.app"), testutil.Contains, `<allow own="org.bluez"/>`)
+
+ spec = &dbus.Specification{}
@jdstrand

jdstrand Aug 30, 2017

Contributor

Before this line you should:

// on a classic system with bluez slot coming from the core snap.
restore = release.MockOnClassic(true)
defer restore()
}
func (s *BluezInterfaceSuite) TestSecCompSpec(c *C) {
spec := &seccomp.Specification{}
- c.Assert(spec.AddPermanentSlot(s.iface, s.slot), IsNil)
+ c.Assert(spec.AddPermanentSlot(s.iface, s.appSlot), IsNil)
c.Assert(spec.SecurityTags(), DeepEquals, []string{"snap.producer.app"})
c.Assert(spec.SnippetForTag("snap.producer.app"), testutil.Contains, "listen\n")
@jdstrand

jdstrand Aug 30, 2017

Contributor

Like in TestAppArmorSpec, you need to test for when on classic and when not on classic (to test the (requested) changes to SecCompPermanentSlot(), above)

interfaces/builtin/bluez_test.go
c.Assert(spec.SecurityTags(), DeepEquals, []string{"snap.producer.app"})
c.Assert(spec.SnippetForTag("snap.producer.app"), testutil.Contains, "listen\n")
}
func (s *BluezInterfaceSuite) TestUDevSpec(c *C) {
spec := &udev.Specification{}
- c.Assert(spec.AddConnectedPlug(s.iface, s.plug, nil, s.slot, nil), IsNil)
+ c.Assert(spec.AddConnectedPlug(s.iface, s.plug, nil, s.appSlot, nil), IsNil)
c.Assert(spec.Snippets(), HasLen, 1)
c.Assert(spec.Snippets()[0], testutil.Contains, `KERNEL=="rfkill", TAG+="snap_consumer_app"`)
@jdstrand

jdstrand Aug 30, 2017

Contributor

Here you should test for both when on classic and when not on classic. In this case, the resulting testutil.Contains will be the same, since you didn't (and we don't need to) change UDevConnectedPlug().

@jdstrand

jdstrand Aug 30, 2017

Contributor

Also, while I didn't explicitly request it, please add the appropriate comments // on a classic|core system with bluez slot coming from the core|app snap. when updating the testsuite for udev and seccomp.

Contributor

jdstrand commented Aug 30, 2017

"Shouldn't this only expose bluez if the system has bluez running?"

@chipaca - no. In terms of security policy, it doesn't matter if the slot side (in this case, bluez on classic) is running.

In terms of dynamic slots (something planned for the future), this is interesting to think about. For example, the plan is that on boot the core snap would be able to enumerate the serial ports, i2c devices, etc and then dynamically expose them as slots. It is theoretically possible to extend this to classic services-- eg, if bluez or network-manager isn't running, don't expose those slots. This is a bit tricky because the services not running could simply be a temporary situation (admin stopped them, they come up after snapd, etc). @niemeyer - perhaps you want to have in the back of your mind dynamic slots for (classic) services when considering hotplugging (obviously not for this PR :).

interfaces/builtin/bluez_test.go
+ defer restore()
+
+ spec = &udev.Specification{}
+ c.Assert(spec.AddConnectedPlug(s.iface, s.plug, nil, s.appSlot, nil), IsNil)
@jdstrand

jdstrand Aug 30, 2017

Contributor

This one should be s.coreSlot.

One last item, inline.

Thanks for all your care on this PR! Assuming the tests pass, LGTM.

Collaborator

mvo5 commented Aug 31, 2017

Thanks a lot @willdeberry - also thanks for signing the contributor agreement!

@mvo5 mvo5 merged commit b013aa7 into snapcore:master Aug 31, 2017

7 checks passed

artful-amd64 autopkgtest finished (success)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
xenial-amd64 autopkgtest finished (success)
Details
xenial-i386 autopkgtest finished (success)
Details
xenial-ppc64el autopkgtest finished (success)
Details
yakkety-amd64 autopkgtest finished (success)
Details
zesty-amd64 autopkgtest finished (success)
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment