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

  capability dac_read_search,
  capability sys_ptrace,

  ptrace (read),

  @{exec_path} mr,

  @{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}/attr/current r,
  @{PROC}/@{pids}/cgroup r,
  @{PROC}/@{pids}/cmdline r,
  @{PROC}/@{pids}/environ r,
  @{PROC}/@{pids}/loginuid r,
  @{PROC}/@{pids}/stat r,
  @{PROC}/@{pids}/statm r,
  @{PROC}/@{pids}/task/ r,
  @{PROC}/@{pids}/task/@{tid}/cmdline r,
  @{PROC}/@{pids}/task/@{tid}/stat r,
  @{PROC}/@{pids}/task/@{tid}/status r,
  @{PROC}/@{pids}/wchan r,
  @{PROC}/sys/kernel/osrelease r,
  @{PROC}/sys/kernel/pid_max r,
  @{PROC}/sys/vm/min_free_kbytes r,
  @{PROC}/tty/drivers r,
  @{PROC}/uptime r,

  # file_inherit
  owner @{HOME}/.xsession-errors w,
  owner /dev/tty@{int} rw,

  deny @{user_share_dirs}/gvfs-metadata/* r,

  include if exists <local/ps>
}

# vim:syntax=apparmor
