# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2017-2022 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} = @{bin}/scdaemon @{lib}/{,gnupg/}scdaemon
profile scdaemon @{exec_path} {
  include <abstractions/base>
  include <abstractions/devices-usb>
  include <abstractions/nameservice-strict>

  network netlink raw,

  signal (send) peer=gpg-agent,

  @{exec_path} mr,

  #aa:only pacman
  owner /etc/pacman.d/gnupg/scdaemon.conf r,
  owner /etc/pacman.d/gnupg/S.scdaemon rw,

  owner @{HOME}/@{XDG_GPG_DIR}/scdaemon.conf r,
  owner @{HOME}/@{XDG_GPG_DIR}common.conf r,
  owner @{HOME}/@{XDG_GPG_DIR}/reader_@{int}.status rw,

  owner @{run}/user/@{uid}/gnupg/S.scdaemon rw,
  owner @{run}/user/@{uid}/gnupg/d.@{rand}/S.scdaemon rw,

  owner /var/tmp/zypp.*/PublicKey/S.scdaemon w,
  owner /var/tmp/zypp.*/zypp-general-kr*/S.scdaemon w,
  owner /var/tmp/zypp.*/zypp-trusted-*/S.scdaemon w,

  @{PROC}/@{pid}/task/@{tid}/comm rw,

  @{sys}/devices/@{pci}/bConfigurationValue r,

  include if exists <local/scdaemon>
}

# vim:syntax=apparmor
