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

include <tunables/global>

@{exec_path}  = /usr/share/command-not-found/cnf-update-db
@{exec_path} += @{bin}/update-command-not-found
@{exec_path} += @{lib}/cnf-update-db
@{att} = ""
profile update-command-not-found /{usr/share/command-not-found/cnf-update-db,{,usr/}bin/update-command-not-found,{,usr/}lib{,exec,32,64}/cnf-update-db,{,usr/}bin/update-command-not-found,{,usr/}lib{,exec,32,64}/cnf-update-db} flags=(complain) {
  include <abstractions/base-strict>
  include <abstractions/consoles>
  include <abstractions/nameservice-strict>
  include <abstractions/python>

  capability dac_read_search,

  @{exec_path} r,

  @{python_path} r,
  @{lib}/ r,

  @{bin}/dpkg            rpx -> child-dpkg,
  @{lib}/apt/apt-helper  rix,

  /usr/share/dpkg/cputable r,
  /usr/share/dpkg/tupletable r,
  /usr/share/command-not-found/{,**} r,

  /etc/apt/apt.conf.d/{,*} r,
  /etc/apt/apt.conf r,

  /var/lib/command-not-found/ r,
  /var/lib/command-not-found/commands.db* rwk,

  /var/lib/apt/lists/ r,
  /var/lib/apt/lists/*_Contents-* r,
  /var/lib/apt/lists/*_Commands-* r,

  owner @{PROC}/@{pid}/fd/ r,

  # file_inherit
  /var/log/cron-apt/temp w,

  include if exists <local/update-command-not-found>
}

# vim:syntax=apparmor
