diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/mattermost_keyring.py | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/scripts/mattermost_keyring.py b/scripts/mattermost_keyring.py index a54ed6d..59bec1b 100644 --- a/scripts/mattermost_keyring.py +++ b/scripts/mattermost_keyring.py @@ -1,4 +1,4 @@ -"""Permit the Mattermost Snap to use the desktop Secret Service.""" +"""Permit the Mattermost Snap to use the desktop keyring and tray.""" import os import re @@ -22,15 +22,55 @@ dbus (receive, send) interface=org.freedesktop.Secret.{Collection,Item,Prompt,Service,Session} peer=(label=unconfined), """ +TRAY_MARKER = "# dotfiles: Mattermost Chromium tray access" +TRAY_RULES = """ +dbus (receive) + bus=session + path=/org/chromium/StatusNotifierItem/[0-9]* + interface=org.freedesktop.DBus.Properties + member=Get{,All} + peer=(label=unconfined), +dbus (send) + bus=session + path=/org/chromium/StatusNotifierItem/[0-9]* + interface=org.freedesktop.DBus.Properties + member=PropertiesChanged + peer=(label=unconfined), +dbus (send) + bus=session + path=/org/chromium/StatusNotifierItem/[0-9]* + interface=org.kde.StatusNotifierItem + member=New* + peer=(label=unconfined), +dbus (receive) + bus=session + path=/org/chromium/StatusNotifierItem/[0-9]* + interface=org.kde.StatusNotifierItem + member={Activate,ContextMenu,Scroll,SecondaryActivate,ProvideXdgActivationToken,XAyatanaSecondaryActivate} + peer=(label=unconfined), +dbus (send) + bus=session + path=/org/chromium/DbusMenu{,/[0-9]*} + interface=com.canonical.dbusmenu + member={LayoutUpdated,ItemsPropertiesUpdated} + peer=(label=unconfined), +dbus (receive) + bus=session + path=/org/chromium/DbusMenu{,/[0-9]*} + interface={org.freedesktop.DBus.Properties,com.canonical.dbusmenu} + member={Get*,AboutTo*,Event*} + peer=(label=unconfined), +""" def patch_profile(text: str) -> str: profiles = re.findall(r'^profile "([^"]+)"', text, re.MULTILINE) if profiles != [PROFILE.name] or not text.rstrip().endswith("}"): raise ValueError("Unexpected Mattermost AppArmor profile format.") - if MARKER in text: - return text - return text.rstrip()[:-1] + MARKER + "\n" + RULES + "}\n" + for marker, rules in [(MARKER, RULES), (TRAY_MARKER, TRAY_RULES)]: + if marker not in text: + text = text.rstrip()[:-1] + marker + "\n" + rules + "}\n" + return text def install_profile(text: str) -> None: |
