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

include <tunables/global>

@{exec_path} = @{bin}/update-pciids
profile update-pciids @{exec_path} {
  include <abstractions/base>
  include <abstractions/consoles>

  @{exec_path} r,
  @{sh_path}        rix,

  @{bin}/touch      rix,
  @{bin}/rm         rix,
  @{bin}/mv         rix,
  @{bin}/{,e}grep   rix,
  @{bin}/sed        rix,
  @{bin}/chown      rix,
  @{bin}/chmod      rix,
  @{bin}/echo       rix,
  @{bin}/cat        rix,
  @{bin}/which{,.debianutils}      rix,
  @{bin}/bunzip2    rix,
  @{bin}/bzip2      rix,
  @{bin}/gzip       rix,
  @{bin}/ln         rix,
  @{bin}/zgrep      rix,

  @{bin}/wget       rCx -> browse,
  @{bin}/curl       rCx -> browse,
  @{bin}/lynx       rCx -> browse,

  /usr/share/misc/ r,
  /usr/share/misc/* rwl -> /usr/share/misc/*,

   # For shell pwd
  /root/ r,


  profile browse {
    include <abstractions/base>
    include <abstractions/nameservice-strict>
    include <abstractions/ssl_certs>

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

    @{bin}/wget mr,
    @{bin}/curl mr,
    @{bin}/lynx mr,

    /etc/wgetrc r,
    owner @{HOME}/.wget-hsts rwk,

    /usr/share/misc/pci.ids.new w,
    /usr/share/misc/pci.ids.gz.new w,

  }

  include if exists <local/update-pciids>
}
