|
|
@@ -0,0 +1,199 @@ |
|
|
+// -*- 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 (
|
|
|
+ "bytes"
|
|
|
+
|
|
|
+ "github.com/snapcore/snapd/interfaces"
|
|
|
+)
|
|
|
+
|
|
|
+var edsCalendarPermanentSlotAppArmor = []byte(`
|
|
|
+# Description: Can access the calendar. This policy group is reserved for
|
|
|
+# vetted applications only in this version of the policy. Once LP: #1227824
|
|
|
+# is fixed, this can be moved out of reserved status.
|
|
|
+# Usage: reserved
|
|
|
+`)
|
|
|
+
|
|
|
+var edsCalendarConnectedPlugAppArmor = []byte(`
|
|
|
+# Description: Can access the calendar. This policy group is reserved for
|
|
|
+# vetted applications only in this version of the policy. Once LP: #1227824
|
|
|
+# is fixed, this can be moved out of reserved status.
|
|
|
+# Usage: reserved
|
|
|
+
|
|
|
+# DBus accesses
|
|
|
+#include <abstractions/dbus-session-strict>
|
|
|
+
|
|
|
+# Allow all access to eds service
|
|
|
+dbus (receive, send)
|
|
|
+ bus=session
|
|
|
+ peer=(label=###SLOT_SECURITY_TAGS###),
|
|
|
+
|
|
|
+dbus (send)
|
|
|
+ bus=session
|
|
|
+ path=/org/freedesktop/DBus
|
|
|
+ interface=org.freedesktop.DBus
|
|
|
+ member={Request,Release}Name
|
|
|
+ peer=(name=org.freedesktop.DBus),
|
|
|
+dbus (send)
|
|
|
+ bus=session
|
|
|
+ path=/org/freedesktop/*
|
|
|
+ interface=org.freedesktop.DBus.Properties
|
|
|
+ peer=(label=unconfined),
|
|
|
+
|
|
|
+# Evolution calendar interface
|
|
|
+dbus (receive, send)
|
|
|
+ bus=session
|
|
|
+ path=/org/gnome/evolution/dataserver/SourceManager{,/**}
|
|
|
+ peer=(label=unconfined),
|
|
|
+dbus (receive, send)
|
|
|
+ bus=session
|
|
|
+ path=/org/gnome/evolution/dataserver/CalendarFactory
|
|
|
+ peer=(label=unconfined),
|
|
|
+dbus (receive, send)
|
|
|
+ bus=session
|
|
|
+ path=/org/gnome/evolution/dataserver/Subprocess/**
|
|
|
+ peer=(label=unconfined),
|
|
|
+dbus (receive, send)
|
|
|
+ bus=session
|
|
|
+ path=/org/gnome/evolution/dataserver/CalendarView/**
|
|
|
+ peer=(label=unconfined),
|
|
|
+`)
|
|
|
+
|
|
|
+var edsCalendarPermanentSlotSecComp = []byte(`
|
|
|
+# Description: Can access the calendar. This policy group is reserved for
|
|
|
+# vetted applications only in this version of the policy. Once LP: #1227824
|
|
|
+# is fixed, this can be moved out of reserved status.
|
|
|
+# Usage: reserved
|
|
|
+`)
|
|
|
+
|
|
|
+var edsCalendarConnectedPlugSecComp = []byte(`
|
|
|
+# Description: Can access the calendar. This policy group is reserved for
|
|
|
+# vetted applications only in this version of the policy. Once LP: #1227824
|
|
|
+# is fixed, this can be moved out of reserved status.
|
|
|
+# Usage: reserved
|
|
|
+
|
|
|
+# Can communicate with DBus system service
|
|
|
+accept
|
|
|
+accept4
|
|
|
+bind
|
|
|
+connect
|
|
|
+getpeername
|
|
|
+getsockname
|
|
|
+getsockopt
|
|
|
+listen
|
|
|
+recv
|
|
|
+recvfrom
|
|
|
+recvmmsg
|
|
|
+recvmsg
|
|
|
+send
|
|
|
+sendmmsg
|
|
|
+sendmsg
|
|
|
+sendto
|
|
|
+setsockopt
|
|
|
+shutdown
|
|
|
+socketpair
|
|
|
+socket
|
|
|
+`)
|
|
|
+
|
|
|
+var edsCalendarPermanentSlotDBus = []byte(`
|
|
|
+<policy user="default">
|
|
|
+ <!-- SourceRegistry -->
|
|
|
+ <allow send_destination="org.gnome.evolution.dataserver.Sources5"
|
|
|
+ send_interface="org.freedesktop.DBus.Introspectable"/>
|
|
|
+ <allow send_destination="org.gnome.evolution.dataserver.Sources5"
|
|
|
+ send_interface="org.freedesktop.DBus.Properties"/>
|
|
|
+ <allow send_destination="org.gnome.evolution.dataserver.Sources5"
|
|
|
+ send_interface="org.freedesktop.DBus.ObjectManager"/>
|
|
|
+
|
|
|
+ <!-- CalendarFactory -->
|
|
|
+ <allow send_interface="org.gnome.evolution.dataserver.Calendar7"/>
|
|
|
+
|
|
|
+</policy>
|
|
|
+`)
|
|
|
+
|
|
|
+type EDSCalendarInterface struct{}
|
|
|
+
|
|
|
+func (iface *EDSCalendarInterface) Name() string {
|
|
|
+ return "eds-calendar"
|
|
|
+}
|
|
|
+
|
|
|
+func (iface *EDSCalendarInterface) PermanentPlugSnippet(plug *interfaces.Plug, securitySystem interfaces.SecuritySystem) ([]byte, error) {
|
|
|
+ switch securitySystem {
|
|
|
+ case interfaces.SecurityDBus, interfaces.SecurityAppArmor, interfaces.SecuritySecComp, interfaces.SecurityUDev, interfaces.SecurityMount:
|
|
|
+ return nil, nil
|
|
|
+ default:
|
|
|
+ return nil, interfaces.ErrUnknownSecurity
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (iface *EDSCalendarInterface) ConnectedPlugSnippet(plug *interfaces.Plug, slot *interfaces.Slot, securitySystem interfaces.SecuritySystem) ([]byte, error) {
|
|
|
+ switch securitySystem {
|
|
|
+ case interfaces.SecurityAppArmor:
|
|
|
+ old := []byte("###SLOT_SECURITY_TAGS###")
|
|
|
+ new := slotAppLabelExpr(slot)
|
|
|
+ snippet := bytes.Replace(edsCalendarConnectedPlugAppArmor, old, new, -1)
|
|
|
+ return snippet, nil
|
|
|
+ case interfaces.SecuritySecComp:
|
|
|
+ return edsCalendarConnectedPlugSecComp, nil
|
|
|
+ case interfaces.SecurityDBus:
|
|
|
+ return edsCalendarPermanentSlotDBus, nil
|
|
|
+ case interfaces.SecurityUDev, interfaces.SecurityMount:
|
|
|
+ return nil, nil
|
|
|
+ default:
|
|
|
+ return nil, interfaces.ErrUnknownSecurity
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (iface *EDSCalendarInterface) PermanentSlotSnippet(slot *interfaces.Slot, securitySystem interfaces.SecuritySystem) ([]byte, error) {
|
|
|
+ switch securitySystem {
|
|
|
+ case interfaces.SecurityAppArmor:
|
|
|
+ return edsCalendarPermanentSlotAppArmor, nil
|
|
|
+ case interfaces.SecuritySecComp:
|
|
|
+ return edsCalendarPermanentSlotSecComp, nil
|
|
|
+ case interfaces.SecurityDBus:
|
|
|
+ return edsCalendarPermanentSlotDBus, nil
|
|
|
+ case interfaces.SecurityUDev, interfaces.SecurityMount:
|
|
|
+ return nil, nil
|
|
|
+ default:
|
|
|
+ return nil, interfaces.ErrUnknownSecurity
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (iface *EDSCalendarInterface) ConnectedSlotSnippet(plug *interfaces.Plug, slot *interfaces.Slot, securitySystem interfaces.SecuritySystem) ([]byte, error) {
|
|
|
+ switch securitySystem {
|
|
|
+ case interfaces.SecurityDBus, interfaces.SecurityAppArmor, interfaces.SecuritySecComp, interfaces.SecurityUDev, interfaces.SecurityMount:
|
|
|
+ return nil, nil
|
|
|
+ default:
|
|
|
+ return nil, interfaces.ErrUnknownSecurity
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (iface *EDSCalendarInterface) SanitizePlug(plug *interfaces.Plug) error {
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+func (iface *EDSCalendarInterface) SanitizeSlot(slot *interfaces.Slot) error {
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+func (iface *EDSCalendarInterface) AutoConnect() bool {
|
|
|
+ return true
|
|
|
+}
|
Since you are only implementing this for talking to a system-supplied eds, you can omit this.