# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2018-2021 Mikhail Morfikov
# 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}/pinentry-kwallet
profile pinentry-kwallet @{exec_path} {
  include <abstractions/base>
  include <abstractions/consoles>
  include <abstractions/freedesktop.org>

  signal (send) set=(term, kill) peer=gpg-agent,

  @{exec_path} mr,

  @{bin}/pinentry-*        rPx,

  @{bin}/kwalletcli_getpin rix,
  @{bin}/kwalletcli        rCx -> kwalletcli,

  # when wrong PIN is provided
  @{bin}/date              rix,

  @{bin}/mksh              rix,
  @{bin}/env               rix,

  owner @{HOME}/.Xauthority r,

  /usr/share/hwdata/pnp.ids r,


  profile kwalletcli {
    include <abstractions/base>

    @{bin}/kwalletcli mr,

    owner @{user_config_dirs}/kdeglobals r,
    owner @{user_config_dirs}/kwalletrc r,
    @{lib}/@{multiarch}/qt5/plugins/kf5/org.kde.kwindowsystem.platforms/KF5WindowSystemKWaylandPlugin.so mr,
    @{lib}/@{multiarch}/qt5/plugins/kf5/org.kde.kwindowsystem.platforms/KF5WindowSystemX11Plugin.so mr,

   owner @{HOME}/.Xauthority r,

   /usr/share/hwdata/pnp.ids r,

  }

  include if exists <local/pinentry-kwallet>
}
