diff options
| author | Tony Espy <tonyespy@users.noreply.github.com> | 2016-10-20 16:59:11 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@gmail.com> | 2016-10-20 16:59:11 +0200 |
| commit | dff477229108960d3a5fb6df36732c9d6a653847 (patch) | |
| tree | a4e8eb06c577e716ba5d2e4b1b3a650791bbd340 | |
| parent | 8c766fec8068cdbcf7045873d49c68db3d4e3f00 (diff) | |
interfaces/builtin: add dcdbas-control interface
| -rw-r--r-- | docs/interfaces.md | 7 | ||||
| -rw-r--r-- | interfaces/builtin/all.go | 1 | ||||
| -rw-r--r-- | interfaces/builtin/basedeclaration.go | 5 | ||||
| -rw-r--r-- | interfaces/builtin/dcdbas_control.go | 57 | ||||
| -rw-r--r-- | interfaces/builtin/dcdbas_control_test.go | 92 | ||||
| -rw-r--r-- | snap/implicit.go | 1 |
6 files changed, 163 insertions, 0 deletions
diff --git a/docs/interfaces.md b/docs/interfaces.md index 067eab47c6..8db0ea455c 100644 --- a/docs/interfaces.md +++ b/docs/interfaces.md @@ -263,6 +263,13 @@ printing. * Auto-Connect: no +### dcdbas-control + +Can interact with the Dell Systems Management Base Driver which provides +a sysfs interface for systems management software such as Dell OpenManage +to perform system management interrupts and host control actions (system +power cycle or power off after OS shutdown) on certain Dell systems. + ### docker Can access snaps providing the docker interface which gives privileged access diff --git a/interfaces/builtin/all.go b/interfaces/builtin/all.go index abcd891e9c..e5be9480fc 100644 --- a/interfaces/builtin/all.go +++ b/interfaces/builtin/all.go @@ -44,6 +44,7 @@ var allInterfaces = []interfaces.Interface{ &PulseAudioInterface{}, &UDisks2Interface{}, &FwupdInterface{}, + NewDcdbasControlInterface(), NewFirewallControlInterface(), NewGsettingsInterface(), NewHardwareObserveInterface(), diff --git a/interfaces/builtin/basedeclaration.go b/interfaces/builtin/basedeclaration.go index d0a99e796b..28561bfc82 100644 --- a/interfaces/builtin/basedeclaration.go +++ b/interfaces/builtin/basedeclaration.go @@ -192,6 +192,11 @@ slots: slot-snap-type: - core deny-auto-connection: true + dcdbas-control: + allow-installation: + slot-snap-type: + - core + deny-auto-connection: true docker: allow-installation: false deny-connection: true diff --git a/interfaces/builtin/dcdbas_control.go b/interfaces/builtin/dcdbas_control.go new file mode 100644 index 0000000000..1e8d21b3bd --- /dev/null +++ b/interfaces/builtin/dcdbas_control.go @@ -0,0 +1,57 @@ +// -*- Mode: Go; indent-tabs-mode: t -*- + +/* + * Copyright (C) 2016 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +package builtin + +import ( + "github.com/snapcore/snapd/interfaces" +) + +// https://www.kernel.org/doc/Documentation/dcdbas.txt +const dcdbasControlConnectedPlugAppArmor = ` +# Description: This interface allows communication with Dell Systems Management Base Driver +# which provides a sysfs interface for systems management software such as Dell OpenManage +# to perform system management interrupts and host control actions (system power cycle or +# power off after OS shutdown) on certain Dell systems. The Dell libsmbios project aims +# towards providing access to as much BIOS information as possible. +# +# See http://linux.dell.com/libsmbios/main/ for more information about the libsmbios project. + +# Usage: reserved + +# entries pertaining to System Management Interrupts (SMI) +/sys/devices/platform/dcdbas/smi_data rw, +/sys/devices/platform/dcdbas/smi_data_buf_phys_addr rw, +/sys/devices/platform/dcdbas/smi_data_buf_size rw, +/sys/devices/platform/dcdbas/smi_request rw, + +# entries pertaining to Host Control Action +/sys/devices/platform/dcdbas/host_control_action rw, +/sys/devices/platform/dcdbas/host_control_smi_type rw, +/sys/devices/platform/dcdbas/host_control_on_shutdown rw, +` + +// NewHardwareObserveInterface returns a new "dcdbas-control" interface. +func NewDcdbasControlInterface() interfaces.Interface { + return &commonInterface{ + name: "dcdbas-control", + connectedPlugAppArmor: dcdbasControlConnectedPlugAppArmor, + reservedForOS: true, + } +} diff --git a/interfaces/builtin/dcdbas_control_test.go b/interfaces/builtin/dcdbas_control_test.go new file mode 100644 index 0000000000..a6f8bed54c --- /dev/null +++ b/interfaces/builtin/dcdbas_control_test.go @@ -0,0 +1,92 @@ +// -*- Mode: Go; indent-tabs-mode: t -*- + +/* + * Copyright (C) 2016 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +package builtin_test + +import ( + . "gopkg.in/check.v1" + + "github.com/snapcore/snapd/interfaces" + "github.com/snapcore/snapd/interfaces/builtin" + "github.com/snapcore/snapd/snap" + "github.com/snapcore/snapd/testutil" +) + +type DcdbasControlInterfaceSuite struct { + iface interfaces.Interface + slot *interfaces.Slot + plug *interfaces.Plug +} + +var _ = Suite(&DcdbasControlInterfaceSuite{ + iface: builtin.NewDcdbasControlInterface(), + slot: &interfaces.Slot{ + SlotInfo: &snap.SlotInfo{ + Snap: &snap.Info{SuggestedName: "core", Type: snap.TypeOS}, + Name: "dcdbas-control", + Interface: "dcdbas-control", + }, + }, + plug: &interfaces.Plug{ + PlugInfo: &snap.PlugInfo{ + Snap: &snap.Info{SuggestedName: "other"}, + Name: "dcdbas-control", + Interface: "dcdbas-control", + }, + }, +}) + +func (s *DcdbasControlInterfaceSuite) TestName(c *C) { + c.Assert(s.iface.Name(), Equals, "dcdbas-control") +} + +func (s *DcdbasControlInterfaceSuite) TestSanitizeSlot(c *C) { + err := s.iface.SanitizeSlot(s.slot) + c.Assert(err, IsNil) + err = s.iface.SanitizeSlot(&interfaces.Slot{SlotInfo: &snap.SlotInfo{ + Snap: &snap.Info{SuggestedName: "some-snap"}, + Name: "dcdbas-control", + Interface: "dcdbas-control", + }}) + c.Assert(err, ErrorMatches, "dcdbas-control slots are reserved for the operating system snap") +} + +func (s *DcdbasControlInterfaceSuite) TestSanitizePlug(c *C) { + err := s.iface.SanitizePlug(s.plug) + c.Assert(err, IsNil) +} + +func (s *DcdbasControlInterfaceSuite) TestSanitizeIncorrectInterface(c *C) { + c.Assert(func() { s.iface.SanitizeSlot(&interfaces.Slot{SlotInfo: &snap.SlotInfo{Interface: "other"}}) }, + PanicMatches, `slot is not of interface "dcdbas-control"`) + c.Assert(func() { s.iface.SanitizePlug(&interfaces.Plug{PlugInfo: &snap.PlugInfo{Interface: "other"}}) }, + PanicMatches, `plug is not of interface "dcdbas-control"`) +} + +func (s *DcdbasControlInterfaceSuite) TestUsedSecuritySystems(c *C) { + // connected plugs have a non-nil security snippet for apparmor + snippet, err := s.iface.ConnectedPlugSnippet(s.plug, s.slot, interfaces.SecurityAppArmor) + c.Assert(err, IsNil) + c.Assert(snippet, Not(IsNil)) + c.Assert(string(snippet), testutil.Contains, `/dcdbas/smi_data`) +} + +func (s *DcdbasControlInterfaceSuite) TestLegacyAutoConnect(c *C) { + c.Check(s.iface.LegacyAutoConnect(), Equals, false) +} diff --git a/snap/implicit.go b/snap/implicit.go index 17c0272397..c8025068ab 100644 --- a/snap/implicit.go +++ b/snap/implicit.go @@ -29,6 +29,7 @@ import ( var implicitSlots = []string{ "bluetooth-control", + "dcdbas-control", "docker-support", "firewall-control", "fuse-support", |
