# 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} = @{bin}/strawberry
profile strawberry @{exec_path} flags=(attach_disconnected,mediate_deleted) {
  include <abstractions/base>
  include <abstractions/audio-client>
  include <abstractions/consoles>
  include <abstractions/dconf-write>
  include <abstractions/desktop>
  include <abstractions/devices-usb>
  include <abstractions/fontconfig-cache-read>
  include <abstractions/graphics>
  include <abstractions/gstreamer>
  include <abstractions/nameservice-strict>
  include <abstractions/qt5-compose-cache-write>
  include <abstractions/qt5-settings-write>
  include <abstractions/ssl_certs>
  include <abstractions/user-download-strict>

  signal (send) set=(term, kill) peer=strawberry-tagreader,

  signal (receive) set=(term, kill) peer=anyremote//*,

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

  @{exec_path} mr,

  @{bin}/strawberry-tagreader rPx -> strawberry//&strawberry-tagreader,

  @{open_path} rPx -> child-open-help,

  /etc/fstab r,

  /var/lib/dbus/machine-id r,
  /etc/machine-id r,

  owner @{HOME}/ r,

  owner @{user_music_dirs}/ r,
  owner @{user_music_dirs}/** rw,

  owner @{user_config_dirs}/strawberry/ rw,
  owner @{user_config_dirs}/strawberry/* rwkl -> @{user_config_dirs}/strawberry/#@{int},
  owner @{user_config_dirs}/strawberryrc r,

  owner @{user_share_dirs}/strawberry/ rw,
  owner @{user_share_dirs}/strawberry/** rwk,

  owner @{user_cache_dirs}/strawberry/ rw,
  owner @{user_cache_dirs}/strawberry/** rwl -> @{user_cache_dirs}/strawberry/networkcache/prepared/#@{int},

  owner @{user_cache_dirs}/xine-lib/ rw,
  owner @{user_cache_dirs}/xine-lib/plugins.cache{,.new} rw,

  owner @{tmp}/.*/ rw,
  owner @{tmp}/.*/s rw,
  owner @{tmp}/*= w,
  owner @{tmp}/#@{int} rw,
  owner @{tmp}/etilqs_@{hex16} rw,
  owner @{tmp}/kdsingleapp-daemonspudguy-strawberry w,
  owner @{tmp}/kdsingleapp-daemonspudguy-strawberry.lock rwk,
  owner @{tmp}/qipc_{systemsem,sharedmemory}_*[a-f0-9]* rw,
  owner @{tmp}/strawberry-cover-@{rand6}.jpg rwl -> @{tmp}/#@{int},
  owner @{tmp}/strawberry*[0-9] w,
  owner /dev/shm/#@{int} rw,

  @{run}/mount/utab r,

  owner @{PROC}/@{pid}/cmdline r,
  owner @{PROC}/@{pid}/fd/ r,
  owner @{PROC}/@{pid}/mountinfo r,
  owner @{PROC}/@{pid}/mounts r,

  include if exists <local/strawberry>
}

# vim:syntax=apparmor
