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

abi <abi/4.0>,

include <tunables/global>

@{exec_path} = @{lib}/{,cups-pk-helper/}cups-pk-helper-mechanism
@{exec_path} += @{lib}/@{multiarch}/cups-pk-helper-mechanism
@{att} = ""
profile cups-pk-helper-mechanism /{{,usr/}lib{,exec,32,64}/{,cups-pk-helper/}cups-pk-helper-mechanism,{,usr/}lib{,exec,32,64}/*-linux-gnu*/cups-pk-helper-mechanism,{,usr/}lib{,exec,32,64}/*-linux-gnu*/cups-pk-helper-mechanism} flags=(complain) {
  include <abstractions/base-strict>
  include <abstractions/bus-system>
  include <abstractions/bus/org.freedesktop.PolicyKit1>
  include <abstractions/nameservice-strict>

  capability dac_read_search,
  capability sys_nice,

  network inet stream,
  network inet6 stream,

  include <abstractions/bus/system/own>

  dbus bind bus=system name=org.opensuse.CupsPkHelper.Mechanism{,.*},
  dbus receive bus=system path=/
       interface=org.opensuse.CupsPkHelper.Mechanism{,.*}
       peer=(name="@{busname}"),
  dbus send bus=system path=/
       interface=org.opensuse.CupsPkHelper.Mechanism{,.*}
       peer=(name="{@{busname},org.freedesktop.DBus}"),
  dbus (send receive) bus=system path=/
       interface=org.freedesktop.DBus.Properties
       member={Get,GetAll,Set,PropertiesChanged}
       peer=(name="{@{busname},org.freedesktop.DBus}"),
  dbus receive bus=system path=/
       interface=org.freedesktop.DBus.Introspectable
       member=Introspect
       peer=(name="@{busname}"),
  dbus receive bus=system path=/
       interface=org.freedesktop.DBus.ObjectManager
       member=GetManagedObjects
       peer=(name="{@{busname},org.opensuse.CupsPkHelper.Mechanism{,.*}}"),
  dbus send bus=system path=/
       interface=org.freedesktop.DBus.ObjectManager
       member={InterfacesAdded,InterfacesRemoved}
       peer=(name="{@{busname},org.freedesktop.DBus}"),

  @{exec_path} mr,

  /etc/cups/ppd/*.ppd r,

  owner @{tmp}/@{int} rw,

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

  include if exists <local/cups-pk-helper-mechanism>
}

# vim:syntax=apparmor
