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

include <tunables/global>

@{exec_path} = @{bin}/busctl
profile busctl @{exec_path} {
  include <abstractions/base>
  include <abstractions/bus-accessibility>
  include <abstractions/bus-session>
  include <abstractions/bus-system>
  include <abstractions/bus/org.a11y>
  include <abstractions/common/systemd>
  include <abstractions/consoles>
  include <abstractions/nameservice-strict>

  capability net_admin,
  capability sys_ptrace,

  ptrace (read),

  unix (bind) type=stream addr=@@{hex}/bus/busctl/busctl,

  signal (send) set=(cont) peer=child-pager,

  dbus eavesdrop bus=accessibility,
  dbus eavesdrop bus=session,
  dbus eavesdrop bus=system,

  dbus send bus=system path=/org/freedesktop/DBus
       interface=org.freedesktop.DBus.Monitoring
       member=BecomeMonitor
       peer=(name=org.freedesktop.DBus, label=dbus-system),

  @{exec_path} mr,

  @{bin}/less  rPx -> child-pager,
  @{bin}/more  rPx -> child-pager,
  @{bin}/pager rPx -> child-pager,

        @{PROC}/@{pid}/cgroup r,
        @{PROC}/@{pid}/comm r,
        @{PROC}/@{pid}/stat r,
  owner @{PROC}/@{pid}/cmdline r,
  owner @{PROC}/@{pid}/loginuid r,
  owner @{PROC}/@{pid}/sessionid r,

  include if exists <local/busctl>
}