# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2017-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}/youtube-dl
profile youtube-dl @{exec_path} {
  include <abstractions/base>
  include <abstractions/audio-client>
  include <abstractions/consoles>
  include <abstractions/fontconfig-cache-read>
  include <abstractions/fonts>
  include <abstractions/freedesktop.org>
  include <abstractions/nameservice-strict>
  include <abstractions/python>
  include <abstractions/ssl_certs>
  include <abstractions/user-download-strict>
  include <abstractions/X>

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

  signal (receive) set=(term, kill),

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

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

  @{bin}/ r,
  @{bin}/{,@{multiarch}-}gcc-[0-9]* rix,
  @{bin}/git                        rix,
  @{bin}/ldconfig                   rix,
  @{bin}/rtmpdump                   rix,
  @{bin}/uname                      rix,
  @{lib}/git{,-core}/git            rix,
  @{lib}/llvm-[0-9]*/bin/clang      rix,

  /etc/mime.types r,

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

  owner @{user_cache_dirs}/ rw,
  owner @{user_cache_dirs}/youtube-dl/{,**} rw,

  owner @{user_config_dirs}/git/config r,

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

  include if exists <local/youtube-dl>
}

# vim:syntax=apparmor
