# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2019-2021 Mikhail Morfikov
# 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} = @{bin}/top
profile top @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/consoles>
  include <abstractions/nameservice-strict>
  include <abstractions/wutmp>

  capability dac_read_search,
  capability kill,
  capability sys_nice,
  capability sys_ptrace,

  signal send,

  ptrace read,

  @{exec_path} mr,

  /usr/share/terminfo/** r,

  /etc/topdefaultrc r,
  /etc/toprc r,

  owner @{user_config_dirs}/procps/ rw,
  owner @{user_config_dirs}/procps/toprc rw,

  @{run}/systemd/sessions/ r,

  @{sys}/devices/system/node/ r,
  @{sys}/devices/system/node/node@{int}/cpumap r,
  @{sys}/devices/system/node/node@{int}/meminfo r,

  @{PROC}/ r,
  @{PROC}/@{pids}/cgroup r,
  @{PROC}/@{pids}/cmdline r,
  @{PROC}/@{pids}/environ r,
  @{PROC}/@{pids}/oom_{,score_}adj r,
  @{PROC}/@{pids}/oom_score r,
  @{PROC}/@{pids}/stat r,
  @{PROC}/@{pids}/statm r,
  @{PROC}/@{pids}/task/ r,
  @{PROC}/@{pids}/task/@{tid}/cgroup r,
  @{PROC}/@{pids}/task/@{tid}/cmdline r,
  @{PROC}/@{pids}/task/@{tid}/environ r,
  @{PROC}/@{pids}/task/@{tid}/oom_{,score_}adj r,
  @{PROC}/@{pids}/task/@{tid}/oom_score r,
  @{PROC}/@{pids}/task/@{tid}/stat r,
  @{PROC}/@{pids}/task/@{tid}/statm r,
  @{PROC}/@{pids}/task/@{tid}/status r,
  @{PROC}/@{pids}/task/@{tid}/wchan r,
  @{PROC}/@{pids}/wchan r,
  @{PROC}/loadavg r,
  @{PROC}/sys/kernel/osrelease r,
  @{PROC}/sys/kernel/pid_max r,
  @{PROC}/tty/drivers r,
  @{PROC}/uptime r,

  include if exists <local/top>
}

# vim:syntax=apparmor
