# 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}/nmcli
profile nmcli @{exec_path} {
  include <abstractions/base>

  capability dac_read_search,
  capability sys_nice,

  @{exec_path} mr,

  @{bin}/less rCx -> pager,

  owner @{HOME}/.nm-vpngate/*.ovpn r,
  owner @{HOME}/.cert/nm-openvpn/*.pem rw,

  @{run}/udev/data/+pci:* r,              # Identifies all PCI devices (CPU, GPU, Network, Disks, USB, etc.)
  @{run}/udev/data/n@{int} r,

  @{sys}/devices/virtual/net/{,**} r,
  @{sys}/devices/@{pci}/net/*/{,**} r,

  profile pager {
    include <abstractions/base>
    include <abstractions/consoles>

    @{bin}/less  mr,

    owner @{HOME}/.lesshs* rw,
    owner @{user_cache_dirs}/.lesshs* rw,

  }

  include if exists <local/nmcli>
}