# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2021-2024 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only

abi <abi/3.0>,

include <tunables/global>

@{exec_path} = @{lib}/gsd-sharing
profile gsd-sharing @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/bus-session>
  include <abstractions/bus-system>
  include <abstractions/bus/org.freedesktop.NetworkManager>
  include <abstractions/bus/org.gnome.SessionManager>
  include <abstractions/dconf-write>

  signal (receive) set=(term, hup) peer=gdm*,

  #aa:dbus own bus=session name=org.gnome.SettingsDaemon.Sharing

  dbus send bus=session path=/org/freedesktop/systemd1
       interface=org.freedesktop.systemd1.Manager
       member=StopUnit
       peer=(name=org.freedesktop.systemd1),

  dbus receive bus=session
       interface=org.freedesktop.DBus.Introspectable
       member=Introspect
       peer=(name=:*, label=gnome-shell),

  @{exec_path} mr,

  /usr/share/dconf/profile/gdm r,
  /usr/share/gdm/greeter-dconf-defaults r,
  /usr/share/glib-2.0/schemas/gschemas.compiled r,

  owner @{GDM_HOME}/greeter-dconf-defaults r,
  owner @{gdm_config_dirs}/dconf/user r,

  @{run}/systemd/sessions/* r,
  @{run}/systemd/users/@{uid} r,

  @{PROC}/@{pid}/cgroup r,

  owner /dev/tty@{int} rw,

  include if exists <local/gsd-sharing>
}

# vim:syntax=apparmor
