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

abi <abi/4.0>,

include <tunables/global>

@{exec_path} = @{lib}/cockpit/cockpit-pcp
@{att} = ""
profile cockpit-pcp /{,usr/}lib{,exec,32,64}/cockpit/cockpit-pcp flags=(complain) {
  include <abstractions/base-strict>
  include <abstractions/nameservice-strict>
  include <abstractions/disks-read>

  network inet dgram,
  network inet stream,
  network inet6 dgram,
  network inet6 stream,

  signal (receive) peer=cockpit-bridge,

  @{exec_path} mr,

  /etc/pcp.conf r,
  /etc/pcp/{,**} r,

  /var/lib/pcp/{,**} rw,

  /var/log/pcp/pmlogger/ r,
  /var/log/pcp/pmlogger/** r,

  @{sys}/fs/cgroup/{,**/} r,
  @{sys}/fs/cgroup/**/{memory,cpu}* r,
  @{sys}/devices/platform/**/hwmon/hwmon@{int}/temp* r,
  @{sys}/devices/platform/**/hwmon/hwmon@{int}/fan* r,

        @{PROC}/@{pid}/net/dev r,
        @{PROC}/diskstats r,
        @{PROC}/swaps r,
  owner @{PROC}/@{pid}/mounts r,

  include if exists <local/cockpit-pcp>
}

# vim:syntax=apparmor
