# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2015-2020 Mikhail Morfikov
# 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}/minitube
profile minitube @{exec_path} {
  include <abstractions/base>
  include <abstractions/audio-client>
  include <abstractions/consoles>
  include <abstractions/desktop>
  include <abstractions/fontconfig-cache-read>
  include <abstractions/graphics>
  include <abstractions/nameservice-strict>
  include <abstractions/qt5-compose-cache-write>
  include <abstractions/qt5-settings-write>
  include <abstractions/qt5-shader-cache>
  include <abstractions/ssl_certs>

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

  @{exec_path} mr,

  @{bin}/xdg-screensaver  rPx,
  @{open_path}            rPx -> child-open,

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

  /etc/vdpau_wrapper.cfg r,
  /etc/machine-id r,
  /var/lib/dbus/machine-id r,

  owner @{HOME}/vlcsnap-.png rw,

  owner "@{user_cache_dirs}/Flavio Tordini/" rw,
  owner "@{user_cache_dirs}/Flavio Tordini/Minitube/" rw,
  owner "@{user_cache_dirs}/Flavio Tordini/Minitube/**" rwl -> "@{user_cache_dirs}/Flavio Tordini/Minitube/**",

  owner "@{user_config_dirs}/Flavio Tordini/" rw,
  owner "@{user_config_dirs}/Flavio Tordini/*" rwkl -> "@{user_config_dirs}/Flavio Tordini/#@{int}",
  owner "@{user_share_dirs}/Flavio Tordini/" rw,
  owner "@{user_share_dirs}/Flavio Tordini/Minitube/" rw,
  owner "@{user_share_dirs}/Flavio Tordini/Minitube/*" rwk,

  owner @{user_pictures_dirs}/*.png rw,

  owner @{tmp}/qtsingleapp-minitu-* rw,
  owner @{tmp}/qtsingleapp-minitu-*-lockfile rwk,

  # If one is blocked, the others are probed.
  deny owner @{HOME}/#@{int} mrw,
       owner @{HOME}/.glvnd* mrw,
  #    owner @{tmp}/#@{int} mrw,
  #    owner @{tmp}/.glvnd* mrw,

  owner @{PROC}/@{pid}/cmdline r,

        /dev/shm/#@{int} rw,
  owner /dev/tty@{int} rw,

  include if exists <local/minitube>
}

# vim:syntax=apparmor
