interfaces: add unconfined access to modem-manager #2252

Merged
merged 3 commits into from Dec 5, 2016

Conversation

Projects
None yet
4 participants
Contributor

alfonsosanchezbeato commented Nov 2, 2016

Let unconfined apps access modem-manager DBus interface, and also let
the plug access modem-manager in classic.

Thanks for the updates to this interface. There are a few requested changes. In addition, now that you are allowing unconfined to talk to modem-manager, you need to update modemManagerPermanentSlotDBus to not open a hole since policykit isn't available on all snaps. Please update modemManagerPermanentSlotDBus to have only:

<policy user="root">
    <allow own="org.freedesktop.ModemManager1"/>
    <allow send_destination="org.freedesktop.ModemManager1"/>
</policy>

Then create modemManagerConnectedPlugDBus to have:

<policy context="default">                                                      
    <deny own="org.freedesktop.ModemManager1"/>                                       
    <deny send_destination="org.freedesktop.ModemManager1"/>
</policy>   

Then adjust ConnectedPlugSnippet() to use modemManagerConnectedPlugDBus. See the udisks2 interface for an example.

Also, please add tests that search for the above udev snippets. These are currently lacking and we want to make sure that modemManagerPermanentSlotDBus is always applied and modemManagerConnectedPlugDBus conditionally applied on slot connection.

- } else {
- new = slotAppLabelExpr(slot)
+ // Let confined apps access unconfined ofono on classic
+ snippet = append(snippet, modemManagerConnectedPlugAppArmorClassic...)
@jdstrand

jdstrand Nov 8, 2016

Contributor

I liked the previous logic before-- if OnClassic, use the modemManagerConnectedPlugAppArmor policy, but with the unconfined label, otherwise use it with the slot label. What you have here is inflated policy on classic where you are allowed to talk to the modem-manager snap's label, which won't exist on classic.

AFAICT, you can drop the changes to ConnectedPlugSnippet, drop the modemManagerConnectedPlugAppArmorClassic variable and add this to modemManagerConnectedPlugAppArmor:

dbus (receive, send)
    bus=system
    path=/org/freedesktop/ModemManager1{,/**}
    interface=org.freedesktop.DBus.*
    peer=(label=###SLOT_SECURITY_TAGS###),

The changes to modemManagerPermanentSlotAppArmor can stay.

Contributor

alfonsosanchezbeato commented Nov 10, 2016

@jdstrand, thanks for the review. Branch refreshed with changes.

Additionally I had to change basedeclaration to allow connecting mmcli to MM daemon.

interfaces/builtin/basedeclaration.go
@@ -283,7 +283,6 @@ slots:
- app
deny-connection: true
modem-manager:
- deny-connection: true
@jdstrand

jdstrand Nov 10, 2016

Contributor

I realize you did this to work around https://bugs.launchpad.net/bugs/1640874, but this must be removed since the base declaration was working as intended (ie, it is meant to require a snap declaration for connections to be allowed to modem-manager).

Contributor

alfonsosanchezbeato commented Nov 11, 2016

Thanks for the review. I have removed the basedeclaration changes. Additionally, I have changed the policy again for plugs in classic, so it is now equivalent to the one in the ofono interface (that is, I consider it is possible to have a confined client using either the m-m snap or the deb on a classic system).

release.OnClassic = true
- snippet, err := s.iface.ConnectedPlugSnippet(s.plug, slot, interfaces.SecurityAppArmor)
+ snippet, err := s.iface.ConnectedPlugSnippet(s.plug, s.slot, interfaces.SecurityAppArmor)
c.Assert(err, IsNil)
c.Assert(string(snippet), testutil.Contains, "peer=(label=unconfined),")
}
@jdstrand

jdstrand Nov 14, 2016

Contributor

Can you add one more test TestConnectedPlugSnippedUsesUnconfinedLabelNotOnClassic that makes sure "peer=(label=unconfined)," is not present when release.OnClassic = false?

Contributor

alfonsosanchezbeato commented Nov 14, 2016

@jdstrand, test added

Contributor

morphis commented Nov 22, 2016

@mvo5 @niemeyer Not really sure where those autopkg test failures come from. Are they expected to be stable already? If not can you merge this PR?

alfonsosanchezbeato added some commits Nov 2, 2016

interfaces: add unconfined access to modem-manager
Let unconfined apps access modem-manager DBus interface, and also let
the plug access modem-manager in classic.
Collaborator

mvo5 commented Dec 5, 2016

👍

@mvo5 mvo5 merged commit 3288683 into snapcore:master Dec 5, 2016

5 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
xenial-amd64 autopkgtest finished (success)
Details
xenial-i386 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