# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2023-2024 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only

abi <abi/4.0>,

include <tunables/global>

@{exec_path} = @{bin}/transmission-{gtk,qt}
profile transmission @{exec_path} {
  include <abstractions/base>
  include <abstractions/bus-accessibility>
  include <abstractions/bus-session>
  include <abstractions/bus/org.a11y>
  include <abstractions/bus/org.freedesktop.Notifications>
  include <abstractions/bus/org.kde.StatusNotifierWatcher>
  include <abstractions/dconf-write>
  include <abstractions/desktop>
  include <abstractions/graphics>
  include <abstractions/nameservice-strict>
  include <abstractions/ssl_certs>
  include <abstractions/trash-strict>
  include <abstractions/user-download-strict>

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

  #aa:dbus own bus=session name=com.transmissionbt.Transmission
  #aa:dbus own bus=session name=com.transmissionbt.transmission_*
  #aa:dbus talk bus=session name=org.gtk.vfs label="gvfsd{,-*}"

  @{exec_path} mr,

  @{open_path}         rPx -> child-open,

  /usr/share/transmission/{,**} r,

  owner @{HOME}/ r,

  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}/transmission/ rw,
  owner @{user_cache_dirs}/transmission/** rwk,

  owner @{tmp}/tr_session_id_* rwk,

  @{run}/mount/utab r,

        @{PROC}/@{pid}/net/route r,
        @{PROC}/sys/net/ipv6/conf/all/disable_ipv6 r,
  owner @{PROC}/@{pid}/cmdline r,
  owner @{PROC}/@{pid}/comm r,
  owner @{PROC}/@{pid}/mountinfo r,
  owner @{PROC}/@{pid}/mounts r,
  owner @{PROC}/@{pid}/task/@{tid}/comm rw,

  deny @{user_share_dirs}/gvfs-metadata/* r,

  include if exists <local/transmission>
}

# vim:syntax=apparmor
