# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2019-2021 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}/vidcutter
profile vidcutter @{exec_path} {
  include <abstractions/base>
  include <abstractions/audio-client>
  include <abstractions/dconf-write>
  include <abstractions/desktop>
  include <abstractions/fontconfig-cache-read>
  include <abstractions/graphics>
  include <abstractions/nameservice-strict>
  include <abstractions/python>
  include <abstractions/qt5>
  include <abstractions/qt5-compose-cache-write>
  include <abstractions/qt5-settings-write>
  include <abstractions/qt5-shader-cache>
  include <abstractions/ssl_certs>
  include <abstractions/user-download-strict>

  @{exec_path} r,
  @{bin}/python3.@{int} r,

  @{bin}/ r,
  @{bin}/ldconfig  rix,

  @{bin}/ffmpeg     rPx,
  @{bin}/ffprobe    rPx,
  @{bin}/mediainfo  rPx,

  @{open_path}         rPx -> child-open,

  /etc/fstab r,
  /etc/vdpau_wrapper.cfg r,

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

  owner @{HOME}/ r,
  owner @{user_music_dirs}/{,**} rw,
  owner @{user_pictures_dirs}/{,**} rw,
  owner @{user_torrents_dirs}/{,**} rw,
  owner @{user_videos_dirs}/{,**} rw,

  owner @{user_config_dirs}/vidcutter/ rw,
  owner @{user_config_dirs}/vidcutter/* rwkl -> @{user_config_dirs}/vidcutter/#@{int},

  owner @{tmp}/vidcutter-@{uuid} w,
  owner @{tmp}/#@{int} rw,
  owner @{tmp}/*.jpg rwl -> /tmp/#@{int},
  owner @{tmp}/vidcutter/{,*} rw,

  deny owner @{PROC}/@{pid}/cmdline r,
       owner @{PROC}/@{pid}/fd/ r,
       owner @{PROC}/@{pid}/mountinfo r,
       owner @{PROC}/@{pid}/mounts r,
  deny       @{PROC}/sys/kernel/random/boot_id r,

  /dev/ r,
  /dev/shm/#@{int} rw,
  /dev/disk/*/ r,

  owner /dev/tty@{int} rw,

  include if exists <local/vidcutter>
}

# vim:syntax=apparmor
