# 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} = @{sbin}/update-pciids
@{att} = ""
profile update-pciids /{,usr/}{,s}bin/update-pciids flags=(complain) {
  include <abstractions/base-strict>
  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 flags=(complain) {
    include <abstractions/base-strict>
    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_browse>
  }

  include if exists <local/update-pciids>
}

# vim:syntax=apparmor
