# apparmor.d - Full set of apparmor profiles
# 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-ca-trust
profile update-ca-trust @{exec_path} {
  include <abstractions/base>
  include <abstractions/ssl_certs>

  capability dac_read_search,

  @{exec_path} mr,

  @{bin}/bash   rix,
  @{bin}/find   rix,
  @{bin}/ln     rix,
  @{bin}/trust  rix,

  / r,
  /usr/share/p11-kit/modules/{,*} r,

  /etc/ca-certificates/extracted/{tls,email,objsign}-ca-bundle.pem{,.*} w,
  /etc/ca-certificates/extracted/ca-bundle.trust.crt{,.*} w,
  /etc/ca-certificates/extracted/cadir/{,*} rw,
  /etc/ca-certificates/extracted/edk2-cacerts.bin{,.*} w,
  /etc/ssl/certs/{,*} rw,
  /etc/ssl/certs/java/cacerts{,.*} w,

  /dev/tty rw,

  # Inherit silencer
  deny network inet6 stream,
  deny network inet stream,

  include if exists <local/update-ca-trust>
}