# 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/4.0>,

include <tunables/global>

@{exec_path} = @{lib}/gsd-printer
profile gsd-printer /{,usr/}lib{,exec,32,64}/gsd-printer  flags=(attach_disconnected,complain) {
  include <abstractions/base>
  include <abstractions/bus-session>
  include <abstractions/bus-system>
  include <abstractions/bus/org.gnome.SessionManager>
  include <abstractions/nameservice-strict>

  signal (receive) set=(term, hup) peer=gdm*,
  signal (receive) set=(hup) peer=gsd-print-notifications,

  dbus bind bus=system name=com.redhat.NewPrinterNotification{,.*},
  dbus receive bus=system path=/com/redhat/NewPrinterNotification{,/**}
       interface=com.redhat.NewPrinterNotification{,.*}
       peer=(name=":1.@{int}"),
  dbus receive bus=system path=/com/redhat/NewPrinterNotification{,/**}
       interface=org.freedesktop.DBus.Properties
       peer=(name=":1.@{int}"),
  dbus receive bus=system path=/com/redhat/NewPrinterNotification{,/**}
       interface=org.freedesktop.DBus.ObjectManager
       peer=(name=":1.@{int}"),
  dbus send bus=system path=/com/redhat/NewPrinterNotification{,/**}
       interface=com.redhat.NewPrinterNotification{,.*}
       peer=(name="{:1.@{int},org.freedesktop.DBus}"),
  dbus send bus=system path=/com/redhat/NewPrinterNotification{,/**}
       interface=org.freedesktop.DBus.Properties
       peer=(name="{:1.@{int},org.freedesktop.DBus}"),
  dbus send bus=system path=/com/redhat/NewPrinterNotification{,/**}
       interface=org.freedesktop.DBus.ObjectManager
       peer=(name="{:1.@{int},org.freedesktop.DBus}"),
  dbus receive bus=system path=/com/redhat/NewPrinterNotification{,/**}
       interface=org.freedesktop.DBus.Introspectable
       member=Introspect
       peer=(name=":1.@{int}"),
  dbus bind bus=system name=com.redhat.PrinterDriversInstaller{,.*},
  dbus receive bus=system path=/com/redhat/PrinterDriversInstaller{,/**}
       interface=com.redhat.PrinterDriversInstaller{,.*}
       peer=(name=":1.@{int}"),
  dbus receive bus=system path=/com/redhat/PrinterDriversInstaller{,/**}
       interface=org.freedesktop.DBus.Properties
       peer=(name=":1.@{int}"),
  dbus receive bus=system path=/com/redhat/PrinterDriversInstaller{,/**}
       interface=org.freedesktop.DBus.ObjectManager
       peer=(name=":1.@{int}"),
  dbus send bus=system path=/com/redhat/PrinterDriversInstaller{,/**}
       interface=com.redhat.PrinterDriversInstaller{,.*}
       peer=(name="{:1.@{int},org.freedesktop.DBus}"),
  dbus send bus=system path=/com/redhat/PrinterDriversInstaller{,/**}
       interface=org.freedesktop.DBus.Properties
       peer=(name="{:1.@{int},org.freedesktop.DBus}"),
  dbus send bus=system path=/com/redhat/PrinterDriversInstaller{,/**}
       interface=org.freedesktop.DBus.ObjectManager
       peer=(name="{:1.@{int},org.freedesktop.DBus}"),
  dbus receive bus=system path=/com/redhat/PrinterDriversInstaller{,/**}
       interface=org.freedesktop.DBus.Introspectable
       member=Introspect
       peer=(name=":1.@{int}"),
  
  dbus receive bus=session
       interface=org.freedesktop.DBus.Introspectable
       member=Introspect
       peer=(name=:*, label=gnome-shell),

  @{exec_path} mr,

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

  owner /dev/tty@{int} rw,

  include if exists <local/gsd-printer>
}
