many: derive implicit slots from interface meta-data #3370

Merged
merged 4 commits into from Jun 8, 2017
@@ -34,7 +34,6 @@ func (s *apiSuite) mockSnap(c *C, yamlText string) *snap.Info {
}
snapInfo := snaptest.MockSnap(c, yamlText, "", &snap.SideInfo{Revision: snap.R(1)})
- snap.AddImplicitSlots(snapInfo)
st := s.d.overlord.State()
@@ -72,6 +72,8 @@ func init() {
name: "account-control",
summary: accountControlSummary,
description: accountControlDescription,
+ implicitOnCore: true,
@mvo5

mvo5 Jun 7, 2017

Collaborator

Is there/will there ever be a case where we have implicitOnCore: false, implicitOnClassic: true ? The old code had implicit and implicitOnlyOnClassic only. Mostly wondering. Also wondering if: implicit: All, implicit: CoreOnly, implicit: ClassicOnly might look nicer (i.e. using bits).

@zyga

zyga Jun 7, 2017

Contributor

There are things that are implicit on classic, yes. I changed this from the previous code to make it less magic and more obvious as to what is added. I don't mind a single implicit bit-flag but I'd rather do that in a separate branch to allow this one to land and iterate.

+ implicitOnClassic: true,
connectedPlugAppArmor: accountControlConnectedPlugAppArmor,
connectedPlugSecComp: accountControlConnectedPlugSecComp,
reservedForOS: true,
@@ -44,6 +44,8 @@ func init() {
name: "alsa",
summary: alsaSummary,
description: alsaDescription,
+ implicitOnCore: true,
+ implicitOnClassic: true,
connectedPlugAppArmor: alsaConnectedPlugAppArmor,
reservedForOS: true,
})
@@ -58,6 +58,8 @@ func init() {
registerIface(&commonInterface{
name: "autopilot-introspection",
summary: autopilotIntrospectionSummary,
+ implicitOnCore: true,
+ implicitOnClassic: true,
connectedPlugAppArmor: autopilotIntrospectionPlugAppArmor,
connectedPlugSecComp: autopilotIntrospectionPlugSecComp,
reservedForOS: true,
@@ -117,6 +117,7 @@ func init() {
registerIface(&commonInterface{
name: "avahi-observe",
summary: avahiObserveSummary,
+ implicitOnClassic: true,
connectedPlugAppArmor: avahiObserveConnectedPlugAppArmor,
reservedForOS: true,
})
@@ -52,6 +52,8 @@ func init() {
registerIface(&commonInterface{
name: "bluetooth-control",
summary: bluetoothControlSummary,
+ implicitOnCore: true,
+ implicitOnClassic: true,
connectedPlugAppArmor: bluetoothControlConnectedPlugAppArmor,
connectedPlugSecComp: bluetoothControlConnectedPlugSecComp,
reservedForOS: true,
@@ -246,7 +246,9 @@ func (iface *browserSupportInterface) Name() string {
func (iface *browserSupportInterface) MetaData() interfaces.MetaData {
return interfaces.MetaData{
- Summary: browserSupportSummary,
+ Summary: browserSupportSummary,
+ ImplicitOnCore: true,
+ ImplicitOnClassic: true,
}
}
@@ -36,6 +36,8 @@ func init() {
registerIface(&commonInterface{
name: "camera",
summary: cameraSummary,
+ implicitOnCore: true,
+ implicitOnClassic: true,
connectedPlugAppArmor: cameraConnectedPlugAppArmor,
reservedForOS: true,
})
@@ -106,6 +106,8 @@ func init() {
registerIface(&commonInterface{
name: "classic-support",
summary: classicSupportSummary,
+ implicitOnCore: true,
+ implicitOnClassic: true,
connectedPlugAppArmor: classicSupportPlugAppArmor,
connectedPlugSecComp: classicSupportPlugSecComp,
})
@@ -42,6 +42,9 @@ type commonInterface struct {
description string
documentationURL string
+ implicitOnCore bool
+ implicitOnClassic bool
+
connectedPlugAppArmor string
connectedPlugSecComp string
reservedForOS bool
@@ -61,9 +64,11 @@ func (iface *commonInterface) Name() string {
// MetaData returns various meta-data about this interface.
func (iface *commonInterface) MetaData() interfaces.MetaData {
return interfaces.MetaData{
- Description: iface.description,
- Summary: iface.summary,
- DocumentationURL: iface.documentationURL,
+ Summary: iface.summary,
+ Description: iface.description,
+ DocumentationURL: iface.documentationURL,
+ ImplicitOnCore: iface.implicitOnCore,
+ ImplicitOnClassic: iface.implicitOnClassic,
}
}
@@ -51,8 +51,8 @@ const coreSupportConnectedPlugAppArmor = `
# Allow modifying logind configuration. For now, allow reading all logind
# configuration but only allow modifying NN-snap*.conf and snap*.conf files
-# in /etc/systemd/logind.conf.d. Also allow creating the logind.conf.d
-# directory as it may not be there for existing installs (wirtable-path
+# in /etc/systemd/logind.conf.d. Also allow creating the logind.conf.d
+# directory as it may not be there for existing installs (wirtable-path
# magic oddness).
/etc/systemd/logind.conf r,
/etc/systemd/logind.conf.d/ rw,
@@ -78,8 +78,10 @@ owner /boot/uboot/config.txt.tmp rwk,
func init() {
registerIface(&commonInterface{
- name: "core-support",
- summary: coreSupportSummary,
+ name: "core-support",
+ summary: coreSupportSummary,
+ implicitOnCore: true,
+ implicitOnClassic: true,
// NOTE: core-support implicitly contains the rules from network-bind.
connectedPlugAppArmor: coreSupportConnectedPlugAppArmor + networkBindConnectedPlugAppArmor,
connectedPlugSecComp: "" + networkBindConnectedPlugSecComp,
@@ -32,6 +32,7 @@ func init() {
registerIface(&commonInterface{
name: "cups-control",
summary: cupsControlSummary,
+ implicitOnClassic: true,
connectedPlugAppArmor: cupsControlConnectedPlugAppArmor,
reservedForOS: true,
})
@@ -47,6 +47,8 @@ func init() {
registerIface(&commonInterface{
name: "dcdbas-control",
summary: dcdbasControlSummary,
+ implicitOnCore: true,
+ implicitOnClassic: true,
connectedPlugAppArmor: dcdbasControlConnectedPlugAppArmor,
reservedForOS: true,
})
@@ -530,7 +530,9 @@ func (iface *dockerSupportInterface) Name() string {
func (iface *dockerSupportInterface) MetaData() interfaces.MetaData {
return interfaces.MetaData{
- Summary: dockerSupportSummary,
+ Summary: dockerSupportSummary,
+ ImplicitOnCore: true,
+ ImplicitOnClassic: true,
}
}
@@ -125,6 +125,8 @@ func init() {
registerIface(&commonInterface{
name: "firewall-control",
summary: firewallControlSummary,
+ implicitOnCore: true,
+ implicitOnClassic: true,
connectedPlugAppArmor: firewallControlConnectedPlugAppArmor,
connectedPlugSecComp: firewallControlConnectedPlugSecComp,
connectedPlugKModModules: firewallControlConnectedPlugKmod,
@@ -47,7 +47,9 @@ func (iface *framebufferInterface) Name() string {
func (iface *framebufferInterface) MetaData() interfaces.MetaData {
return interfaces.MetaData{
- Summary: framebufferSummary,
+ Summary: framebufferSummary,
+ ImplicitOnCore: true,
+ ImplicitOnClassic: true,
}
}
@@ -19,6 +19,10 @@
package builtin
+import (
+ "github.com/snapcore/snapd/release"
+)
+
const fuseSupportSummary = `allows access to the FUSE file system`
const fuseSupportConnectedPlugSecComp = `
@@ -72,11 +76,14 @@ deny /etc/fuse.conf r,
`
func init() {
+ // Ubuntu 14.04 does not support the fuse-support interface.
registerIface(&commonInterface{
name: "fuse-support",
summary: fuseSupportSummary,
+ implicitOnCore: true,
+ implicitOnClassic: !(release.ReleaseInfo.ID == "ubuntu" && release.ReleaseInfo.VersionID == "14.04"),
@jdstrand

jdstrand Jun 7, 2017

Contributor

This looks like an unrelated change. I'm not saying it is wrong.... It seems that this sort of thing should be captured elsewhere. Eg, I can imagine Fedora or SUSE might have different interfaces. I mention this only because if going that direction, maybe it's best to not include this change in this PR.

@zyga

zyga Jun 8, 2017

Contributor

This is not an unrelated change. It used to be defined exactly this way in implicit.go before.

+ reservedForOS: true,
connectedPlugAppArmor: fuseSupportConnectedPlugAppArmor,
connectedPlugSecComp: fuseSupportConnectedPlugSecComp,
- reservedForOS: true,
})
}
@@ -41,6 +41,7 @@ func init() {
registerIface(&commonInterface{
name: "gsettings",
summary: gsettingsSummary,
+ implicitOnClassic: true,
connectedPlugAppArmor: gsettingsConnectedPlugAppArmor,
reservedForOS: true,
})
@@ -85,6 +85,8 @@ func init() {
registerIface(&commonInterface{
name: "hardware-observe",
summary: hardwareObserveSummary,
+ implicitOnCore: true,
+ implicitOnClassic: true,
connectedPlugAppArmor: hardwareObserveConnectedPlugAppArmor,
connectedPlugSecComp: hardwareObserveConnectedPlugSecComp,
reservedForOS: true,
@@ -56,7 +56,9 @@ func (iface *hardwareRandomControlInterface) Name() string {
func (iface *hardwareRandomControlInterface) MetaData() interfaces.MetaData {
return interfaces.MetaData{
- Summary: hardwareRandomControlSummary,
+ Summary: hardwareRandomControlSummary,
+ ImplicitOnCore: true,
+ ImplicitOnClassic: true,
}
}
@@ -51,7 +51,9 @@ func (iface *hardwareRandomObserveInterface) Name() string {
func (iface *hardwareRandomObserveInterface) MetaData() interfaces.MetaData {
return interfaces.MetaData{
- Summary: hardwareRandomObserveSummary,
+ Summary: hardwareRandomObserveSummary,
+ ImplicitOnCore: true,
+ ImplicitOnClassic: true,
}
}
@@ -50,6 +50,8 @@ func init() {
registerIface(&commonInterface{
name: "home",
summary: homeSummary,
+ implicitOnCore: true,
+ implicitOnClassic: true,
connectedPlugAppArmor: homeConnectedPlugAppArmor,
reservedForOS: true,
})
@@ -59,7 +59,9 @@ func (iface *iioPortsControlInterface) Name() string {
func (iface *iioPortsControlInterface) MetaData() interfaces.MetaData {
return interfaces.MetaData{
- Summary: ioPortsControlSummary,
+ Summary: ioPortsControlSummary,
+ ImplicitOnCore: true,
+ ImplicitOnClassic: true,
}
}
@@ -48,7 +48,9 @@ func (iface *joystickInterface) Name() string {
func (iface *joystickInterface) MetaData() interfaces.MetaData {
return interfaces.MetaData{
- Summary: joystickSummary,
+ Summary: joystickSummary,
+ ImplicitOnCore: true,
+ ImplicitOnClassic: true,
}
}
@@ -51,6 +51,8 @@ func init() {
registerIface(&commonInterface{
name: "kernel-module-control",
summary: kernelModuleControlSummary,
+ implicitOnCore: true,
+ implicitOnClassic: true,
connectedPlugAppArmor: kernelModuleControlConnectedPlugAppArmor,
connectedPlugSecComp: kernelModuleControlConnectedPlugSecComp,
reservedForOS: true,
@@ -74,6 +74,8 @@ func init() {
registerIface(&commonInterface{
name: "kubernetes-support",
summary: kubernetesSupportSummary,
+ implicitOnCore: true,
+ implicitOnClassic: true,
connectedPlugAppArmor: kubernetesSupportConnectedPlugAppArmor,
connectedPlugKModModules: kubernetesSupportConnectedPlugKmod,
reservedForOS: true,
@@ -36,6 +36,7 @@ func init() {
registerIface(&commonInterface{
name: "libvirt",
summary: libvirtSummary,
+ implicitOnClassic: true,
connectedPlugAppArmor: libvirtConnectedPlugAppArmor,
connectedPlugSecComp: libvirtConnectedPlugSecComp,
reservedForOS: true,
@@ -33,6 +33,7 @@ func init() {
registerIface(&commonInterface{
name: "locale-control",
summary: localeControlSummary,
+ implicitOnClassic: true,
connectedPlugAppArmor: localeControlConnectedPlugAppArmor,
reservedForOS: true,
})
@@ -57,6 +57,8 @@ func init() {
registerIface(&commonInterface{
name: "log-observe",
summary: logObserveSummary,
+ implicitOnCore: true,
+ implicitOnClassic: true,
connectedPlugAppArmor: logObserveConnectedPlugAppArmor,
reservedForOS: true,
})
@@ -49,7 +49,9 @@ func (iface *lxdSupportInterface) Name() string {
func (iface *lxdSupportInterface) MetaData() interfaces.MetaData {
return interfaces.MetaData{
- Summary: lxdSupportSummary,
+ Summary: lxdSupportSummary,
+ ImplicitOnCore: true,
+ ImplicitOnClassic: true,
}
}
@@ -1166,7 +1166,8 @@ func (iface *modemManagerInterface) Name() string {
func (iface *modemManagerInterface) MetaData() interfaces.MetaData {
return interfaces.MetaData{
- Summary: modemManagerSummary,
+ Summary: modemManagerSummary,
+ ImplicitOnClassic: true,
}
}
@@ -60,6 +60,8 @@ func init() {
registerIface(&commonInterface{
name: "mount-observe",
summary: mountObserveSummary,
+ implicitOnCore: true,
+ implicitOnClassic: true,
connectedPlugAppArmor: mountObserveConnectedPlugAppArmor,
connectedPlugSecComp: mountObserveConnectedPlugSecComp,
reservedForOS: true,
@@ -31,6 +31,8 @@ func init() {
registerIface(&commonInterface{
name: "netlink-audit",
summary: netlinkAuditSummary,
+ implicitOnCore: true,
+ implicitOnClassic: true,
connectedPlugSecComp: netlinkAuditConnectedPlugSecComp,
reservedForOS: true,
})
@@ -34,6 +34,8 @@ func init() {
registerIface(&commonInterface{
name: "netlink-connector",
summary: netlinkConnectorSummary,
+ implicitOnCore: true,
+ implicitOnClassic: true,
connectedPlugSecComp: netlinkConnectorConnectedPlugSecComp,
reservedForOS: true,
})
@@ -55,6 +55,8 @@ func init() {
name: "network",
summary: networkSummary,
description: networkDescription,
+ implicitOnCore: true,
+ implicitOnClassic: true,
connectedPlugAppArmor: networkConnectedPlugAppArmor,
connectedPlugSecComp: networkConnectedPlugSecComp,
reservedForOS: true,
@@ -71,6 +71,8 @@ func init() {
registerIface(&commonInterface{
name: "network-bind",
summary: networkBindSummary,
+ implicitOnCore: true,
+ implicitOnClassic: true,
connectedPlugAppArmor: networkBindConnectedPlugAppArmor,
connectedPlugSecComp: networkBindConnectedPlugSecComp,
reservedForOS: true,
@@ -212,6 +212,8 @@ func init() {
registerIface(&commonInterface{
name: "network-control",
summary: networkControlSummary,
+ implicitOnCore: true,
+ implicitOnClassic: true,
connectedPlugAppArmor: networkControlConnectedPlugAppArmor,
connectedPlugSecComp: networkControlConnectedPlugSecComp,
reservedForOS: true,
Oops, something went wrong.