interfaces/builtin: add online-accounts-service interface #2869

Merged
merged 28 commits into from May 11, 2017

Conversation

Projects
None yet
7 participants
Contributor

mardy commented Feb 16, 2017

No description provided.

@niemeyer niemeyer changed the title from Add Online Accounts interface to interfaces/builtin: add interface related to online accounts (?) Feb 23, 2017

I'll let @jdstrand take the first pass on this, but as an early comment we need a better scoped name for the interface. "online-accounts" doesn't give any hint about what the snap is really asking for or being provided.

@niemeyer niemeyer requested a review from jdstrand Feb 23, 2017

Contributor

mardy commented Feb 23, 2017

We can prefix it with "ubuntu-" to distinguish it from other implementations, but a name is just a name, it's not a description. I don't find "bluez" or "dcdbas" very descriptive either :-)

Contributor

niemeyer commented Feb 23, 2017

"bluez" is the well-known name of one particular software. "online accounts" is a concept.

"ubuntu-online-accounts" doesn't seem so great either, as we have many of those (unfortunately).

Can you provide a better idea of what this is really giving access to?

Contributor

mardy commented Feb 24, 2017

The interface gives access to the online accounts API, which is described here:
https://developer.ubuntu.com/en/phone/platform/guides/online-accounts-developer-guide/

For a more user-oriented look, you can have a look at the UX design page:
https://wiki.ubuntu.com/OnlineAccounts

Contributor

niemeyer commented Mar 10, 2017

Thanks for the details. Let's go with your ubuntu-online-accounts suggestion then. I can't think of anything else which wouldn't hurt more than it'd help.

@jdstrand This is just waiting for your review now.

@niemeyer niemeyer changed the title from interfaces/builtin: add interface related to online accounts (?) to interfaces/builtin: add ubuntu-online-accounts interface Mar 10, 2017

Contributor

niemeyer commented Mar 10, 2017

Wait.. I propose something else here: let's establish a new fallback pattern and call this online-accounts-service. We have another extremely generic piece of software called "storage framework" which suffers the same problem, so that one might be storage-framework-service. The pattern is when the interface allows establishing communication with a piece of software with an extremely general name, we can suffix it with -service to make it slightly more clear.

@niemeyer niemeyer changed the title from interfaces/builtin: add ubuntu-online-accounts interface to interfaces/builtin: add online-accounts-service interface Mar 10, 2017

Contributor

niemeyer commented Mar 10, 2017

Just for emphasis, we shouldn't append the -service prefix if the software name is very well known or clearly represents a unique piece of software (docker, bluez, etc).

Contributor

mardy commented Mar 10, 2017

I've just renamed the interface to ubuntu-online-accounts, but in principle online-accounts-service is fine for me. I'll just wait for Jamie's opinion as well, just to avoid the risk of renaming the interface too many times. :-)

Contributor

niemeyer commented Mar 10, 2017

Sorry for the trouble, but can you please rename to online-accounts-service now assuming you do have a moment for doing so? If @jdstrand is happy with this, we can then merge immediately.

mardy added some commits Mar 10, 2017

Contributor

mardy commented Mar 10, 2017

Sure, done :-)

+var onlineAccountsServiceConnectedPlugAppArmor = []byte(`
+# Description: Allow using Online Accounts service. Common because the access
+# to user data is actually mediated by the Online Accounts service itself.
+# Usage: common
@jdstrand

jdstrand Mar 10, 2017

Contributor

Please drop 'Usage' metadata here and elsewhere. It is no longer needed with the base declaration.

+dbus (receive, send)
+ bus=session
+ interface=com.ubuntu.OnlineAccounts.Manager
+ peer=(label=###SLOT_SECURITY_TAGS###),
@jdstrand

jdstrand Mar 10, 2017

Contributor

Is it possible to use a path element in this rule?

+ peer=(label=###SLOT_SECURITY_TAGS###),
+`)
+
+var onlineAccountsServicePermanentSlotSecComp = []byte(`
@jdstrand

jdstrand Mar 10, 2017

Contributor

Please use const instead of var here and elsewhere as that is the coding style for security policy.

+sendmmsg
+sendmsg
+sendto
+shutdown
@jdstrand

jdstrand Mar 10, 2017

Contributor

All the send* and recv* syscalls are now in the default template.

+send
+sendto
+sendmsg
+`)
@jdstrand

jdstrand Mar 10, 2017

Contributor

This can just be dropped since it is all recv* and send* syscalls.

+ <allow send_destination="com.ubuntu.OnlineAccounts.Manager"/>
+ <allow send_interface="com.ubuntu.OnlineAccounts.Manager"/>
+</policy>
+`)
@jdstrand

jdstrand Mar 10, 2017

Contributor

I don't think this dbus policy is quite right because, AIUI, this is meant to be run as a session service, but the DBus backend currently only supports system bus services. Is online accounts DBus-activatable? If so, you will be interested in: #2592

+ return nil, nil
+ default:
+ return nil, nil
+ }
@jdstrand

jdstrand Mar 10, 2017

Contributor

This can just avoid the case statement and return nil, nil

+func (iface *OnlineAccountsServiceInterface) ConnectedPlugSnippet(plug *interfaces.Plug, slot *interfaces.Slot, securitySystem interfaces.SecuritySystem) ([]byte, error) {
+ switch securitySystem {
+ case interfaces.SecurityAppArmor:
+ return onlineAccountsServiceConnectedPlugAppArmor, nil
@jdstrand

jdstrand Mar 10, 2017

Contributor

You need to do the substitutions for ###SLOT_SECURITY_TAGS### in onlineAccountsServiceConnectedPlugAppArmor here. See the mir interface for an example.

+ case interfaces.SecuritySecComp:
+ return onlineAccountsServiceConnectedPlugSecComp, nil
+ case interfaces.SecurityUDev, interfaces.SecurityMount:
+ return nil, nil
@jdstrand

jdstrand Mar 10, 2017

Contributor

Drop this case and just use 'default'.

+ case interfaces.SecuritySecComp:
+ return onlineAccountsServicePermanentSlotSecComp, nil
+ case interfaces.SecurityUDev, interfaces.SecurityMount:
+ return nil, nil
@jdstrand

jdstrand Mar 10, 2017

Contributor

You can drop this and fallback to 'default'

Contributor

mardy commented Mar 14, 2017

Branch updated, I believe I addressed all points.

Member

chipaca commented Mar 15, 2017

@mardy you need to fix those test failures

chipaca added some commits Mar 15, 2017

Member

chipaca commented Mar 15, 2017

@mardy fixed go fmt issues and merged master for you

mardy and others added some commits Mar 15, 2017

Contributor

stolowski commented Mar 27, 2017

I've updated the branch for the API changes in master.

Thanks for all the updates! In general the base decalaraion, the security policy and tests look good with a few more small things.

You need to change over to using the new spec implementation that landed in recent weeks and address the testsuite failures.

+ allow-installation:
+ slot-snap-type:
+ - app
+ deny-connection: true
@jdstrand

jdstrand Mar 27, 2017

Contributor

The base declaration is fine since this is a trusted helper that is safe for all snaps to auto-connect.

@zyga

zyga May 5, 2017

Contributor

Why is this marked as deny-connection then?

@jdstrand

jdstrand May 5, 2017

Contributor

This was mostly talking about how auto-connection is allowed (because it is omitted), but to make this clear, the base declaration is saying that:

  • the slot implementation may only be supplied by app snaps
  • slot implementations by default may not use this interface
  • plugging snaps are auto-connected by default

If there is a slot implementation that is deemed safe and operates how the interface is designed (and safe for auto-connection), then a snap declaration can be issued to the slot implementation snap allowing it to use the interface and then all snaps plugging this interface auto-connect.

@jdstrand

jdstrand May 5, 2017

Contributor

This is in contrast to say, an implicit interface that is provided by core for some service. In that situation, we trust that the service is operating within the interface design constraints because the service is coming from a trusted archive (eg, the Ubuntu archive). With app snap slot implementations, that guarantee is not there so we block the slot implementation by default.

@zyga

zyga May 9, 2017

Contributor

Ah, thank you for taking the time to explain this!

+
+const onlineAccountsServicePermanentSlotAppArmor = `
+# Description: Allow operating as the Online Accounts service. Reserved because
+# this gives privileged access to the system.
@jdstrand

jdstrand Mar 27, 2017

Contributor

You can remove the 'Reserved' sentence since there is nothing particularly privileged in the interface beyond what the base declaration already implies.

+
+const onlineAccountsServiceConnectedPlugAppArmor = `
+# Description: Allow using Online Accounts service. Common because the access
+# to user data is actually mediated by the Online Accounts service itself.
@jdstrand

jdstrand Mar 27, 2017

Contributor

Instead of saying 'Common' say 'Allowed to auto-connect because...'

+ iface: &builtin.OnlineAccountsServiceInterface{},
+ slot: &interfaces.Slot{
+ SlotInfo: &snap.SlotInfo{
+ Snap: &snap.Info{SuggestedName: "core", Type: snap.TypeOS},
@jdstrand

jdstrand Mar 27, 2017

Contributor

Please name this something other than "core" since "core" implies this is an implicit core interface which it is not. I suggest 'service".

+ // verify apparmor connected
+ c.Assert(string(snippet), testutil.Contains, "#include <abstractions/dbus-session-strict>")
+ // verify classic didn't connect
+ c.Assert(string(snippet), Not(testutil.Contains), "peer=(label=unconfined),")
@jdstrand

jdstrand Mar 27, 2017

Contributor

You don't have any OnClassic policy so this check can be removed.

+ c.Assert(snippet, Not(IsNil))
+
+ c.Check(string(snippet), testutil.Contains, "peer=(label=\"snap.other.*\")")
+}
@jdstrand

jdstrand Mar 27, 2017

Contributor

Can you add another similar test for ConnectedPlugSnippetAppArmor?

Contributor

zyga commented Apr 4, 2017

Hey @mardy, can you please merge master into this branch.
@niemeyer / @jdstrand can you please re-review this.

Contributor

mardy commented Apr 4, 2017

Branch updated.

There are two testsuite fixes I'd like to see, but this is fine to merge as is, so approving.

+ c.Assert(apparmorSpec.AddConnectedPlug(s.iface, s.plug, s.coreSlot), IsNil)
+ snippet := apparmorSpec.SnippetForTag("snap.other.app")
+ // verify apparmor connected
+ c.Assert(snippet, testutil.Contains, "#include <abstractions/dbus-session-strict>")
@jdstrand

jdstrand Apr 18, 2017

Contributor

Please add:

c.Check(snippet, testutil.Contains, "peer=(label=\"snap.service.oa\")")
@zyga

zyga May 9, 2017

Contributor

This has been added now

+ // verify apparmor connected
+ c.Assert(snippet, testutil.Contains, "#include <abstractions/dbus-session-strict>")
+ // verify classic didn't connect
+ c.Assert(snippet, Not(testutil.Contains), "peer=(label=unconfined),")
@jdstrand

jdstrand Apr 18, 2017

Contributor

This classic test should be dropped.

@zyga

zyga May 9, 2017

Contributor

This has been dropped now

mvo5 added some commits Apr 20, 2017

Collaborator

mvo5 commented Apr 20, 2017

This looks good to me, I addressed the points that @jdstrand raised. I'm 👍 for merging once the tests are green.

Two questions. I'm happy to iterate to address those given the answer (CC @jdstrand on this)

+ allow-installation:
+ slot-snap-type:
+ - app
+ deny-connection: true
@jdstrand

jdstrand Mar 27, 2017

Contributor

The base declaration is fine since this is a trusted helper that is safe for all snaps to auto-connect.

@zyga

zyga May 5, 2017

Contributor

Why is this marked as deny-connection then?

@jdstrand

jdstrand May 5, 2017

Contributor

This was mostly talking about how auto-connection is allowed (because it is omitted), but to make this clear, the base declaration is saying that:

  • the slot implementation may only be supplied by app snaps
  • slot implementations by default may not use this interface
  • plugging snaps are auto-connected by default

If there is a slot implementation that is deemed safe and operates how the interface is designed (and safe for auto-connection), then a snap declaration can be issued to the slot implementation snap allowing it to use the interface and then all snaps plugging this interface auto-connect.

@jdstrand

jdstrand May 5, 2017

Contributor

This is in contrast to say, an implicit interface that is provided by core for some service. In that situation, we trust that the service is operating within the interface design constraints because the service is coming from a trusted archive (eg, the Ubuntu archive). With app snap slot implementations, that guarantee is not there so we block the slot implementation by default.

@zyga

zyga May 9, 2017

Contributor

Ah, thank you for taking the time to explain this!

+ bus=session
+ interface=com.ubuntu.OnlineAccounts.Manager
+ path=/com/ubuntu/OnlineAccounts{,/**}
+ peer=(label=###SLOT_SECURITY_TAGS###),
@zyga

zyga May 5, 2017

Contributor

Do we need to add dbus introspection here? CC @jdstrand

@jdstrand

jdstrand May 5, 2017

Contributor

Yes. Please add:

# Allow clients to introspect the service
dbus (send)
    bus=session
    interface=org.freedesktop.DBus.Introspectable
    path=/com/ubuntu/OnlineAccounts
    member=Introspect
    peer=(label=###SLOT_SECURITY_TAGS###),

I have not tested this, but based on the object path in the above rule, it should work.

@zyga

zyga May 8, 2017

Contributor

I pushed a patch with this rule.

zyga added some commits May 8, 2017

interfaces/builtin: allow introspecting online accounts service
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces/builtin: use %q for quoting
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
interfaces/builtin: simplify tests for online-accounts-service
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

zyga approved these changes May 10, 2017

I updated this further to simplify tests, LGTM

mvo5 approved these changes May 10, 2017

interfaces/builtin/all_test.go
@@ -42,7 +42,6 @@ var _ = Suite(&AllSuite{})
func (s *AllSuite) TestInterfaces(c *C) {
all := builtin.Interfaces()
- c.Check(all, Contains, &builtin.StorageFrameworkServiceInterface{})
@zyga

zyga May 10, 2017

Contributor

❤️ thank you :)

mvo5 and others added some commits May 10, 2017

@mvo5 mvo5 merged commit 5ae14bd into snapcore:master May 11, 2017

6 of 7 checks passed

zesty-amd64 autopkgtest finished (failure)
Details
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment