# apparmor.d - Full set of apparmor profiles
# Copyright (C) 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}/transmission-qt
profile transmission-qt @{exec_path} {
  include <abstractions/base>
  include <abstractions/desktop>
  include <abstractions/fontconfig-cache-read>
  include <abstractions/graphics>
  include <abstractions/nameservice-strict>
  include <abstractions/private-files-strict>
  include <abstractions/qt5>
  include <abstractions/qt5-settings-write>
  include <abstractions/ssl_certs>
  include <abstractions/user-download-strict>

  network inet dgram,
  network inet6 dgram,
  network inet stream,
  network inet6 stream,
  network netlink dgram,
  network netlink raw,

  @{exec_path} mr,

  # Torrent files
  owner @{user_torrents_dirs}/ r,
  owner @{user_torrents_dirs}/** rw,

  owner @{user_config_dirs}/transmission/ rw,
  owner @{user_config_dirs}/transmission/** rwk,

  owner @{user_cache_dirs}/ rw,
  owner @{user_cache_dirs}/transmission/ rw,
  owner @{user_cache_dirs}/transmission/** rwk,

  owner @{tmp}/tr_session_id_* rwk,

  deny owner @{PROC}/@{pid}/cmdline r,
       owner @{PROC}/@{pid}/mountinfo r,
       owner @{PROC}/@{pid}/mounts r,
             @{PROC}/@{pid}/net/route r,
             @{PROC}/sys/kernel/random/uuid r,

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

  include if exists <local/transmission-qt>
}
