# apparmor.d - Full set of apparmor profiles
# Copyright (C) 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}/yt-dlp
@{att} = ""
profile yt-dlp /{,usr/}bin/yt-dlp flags=(complain) {
  include <abstractions/base-strict>
  include <abstractions/consoles>
  include <abstractions/nameservice-strict>
  include <abstractions/python>
  include <abstractions/ssl_certs>
  include <abstractions/user-download-strict>
  include <abstractions/xdg-desktop>

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

  @{exec_path} r,
  @{python_path} r,

  @{bin}/ r,
  @{bin}/file    rix,
  @{bin}/uname   rix,

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

  /etc/magic r,

  owner @{user_music_dirs}/{,**} rwk,
  owner @{user_videos_dirs}/{,**} rwk,

  owner @{user_cache_dirs}/yt-dlp/{,**} rw,

  owner @{user_config_dirs}/yt-dlp/{,**} rw,

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

  include if exists <local/yt-dlp>
}

# vim:syntax=apparmor
