# 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-print-notifications
profile gsd-print-notifications @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/bus-session>
  include <abstractions/bus-system>
  include <abstractions/bus/org.freedesktop.Avahi>
  include <abstractions/bus/org.gnome.SessionManager>
  include <abstractions/nameservice-strict>

  network inet stream,
  network inet6 stream,

  signal (receive) set=(term, hup) peer=gdm*,
  signal (send) set=(hup) peer=gsd-printer,

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

  # dbus receive bus=system path=/org/cups/cupsd/Notifier
  #      interface=org.cups.cupsd.Notifier,

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

  @{exec_path} mr,
  @{lib}/gsd-printer rPx,

  /etc/cups/client.conf r,

  @{run}/cups/cups.sock rw,

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

  owner /dev/tty@{int} rw,

  include if exists <local/gsd-print-notifications>
}
