# 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} = @{lib}/apt/methods/ftp
profile apt-methods-ftp @{exec_path} {
  include <abstractions/base>
  include <abstractions/consoles>

  # The "_apt" user is created by the postinst script of the "apt" package. It's the owner of the
  # dirs "/var/cache/apt/archives/partial/" and "/var/lib/apt/lists/partial/" . The "_apt" user is
  # used by APT to download packages, package list, and other things using APT methods as an
  # unprivileged user/group (_apt/nogroup).
  capability setgid,
  capability setuid,

  signal (receive) peer=apt,
  signal (receive) peer=apt-get,
  signal (receive) peer=aptitude,
  signal (receive) peer=synaptic,

  @{exec_path} mr,

        /var/lib/apt/lists/{,**} r,
  owner /var/lib/apt/lists/* rw,
  owner /var/lib/apt/lists/partial/* rw,

  # For shell pwd
  / r,
  /etc/ r,
  /root/ r,

  # For package building
  @{user_build_dirs}/** rwkl -> @{user_build_dirs}/**,

  # file_inherit
  owner /dev/tty@{int} rw,

  include if exists <local/apt-methods-ftp>
}

# vim:syntax=apparmor
