# 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} = @{bin}/cups-browsed
profile cups-browsed @{exec_path} {
  include <abstractions/base>
  include <abstractions/bus-system>
  include <abstractions/bus/org.freedesktop.Avahi>
  include <abstractions/bus/org.freedesktop.NetworkManager>
  include <abstractions/cups-client>
  include <abstractions/nameservice-strict>
  include <abstractions/p11-kit>

  capability net_admin,
  capability net_bind_service,
  capability sys_nice,

  network inet dgram,
  network inet6 dgram,
  network inet stream,
  network inet6 stream,
  network netlink raw,

  dbus receive bus=system path=/
       interface=org.freedesktop.Avahi.Server
       member=StateChanged
       peer=(name=:*, label=avahi-daemon),

  dbus receive bus=system path=/org/freedesktop/NetworkManager
       interface=org.freedesktop.NetworkManager
       member=CheckPermissions
       peer=(name=:*, label=NetworkManager),

  @{exec_path} mr,

  /usr/share/cups/locale/{,**} r,

  /etc/cups/{,**} r,

  /var/cache/cups/{,**} rw,
  /var/log/cups/{,**} rw,

  @{run}/cups/certs/* r,

  @{PROC}/sys/net/ipv6/conf/all/disable_ipv6 r,

  include if exists <local/cups-browsed>
}

# vim:syntax=apparmor
