# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2022-2024 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only

abi <abi/3.0>,

include <tunables/global>

@{arch} = amd64 i386
@{runtime} = SteamLinuxRuntime_sniper
@{share_dirs} = @{user_share_dirs}/Steam @{HOME}/.steam/debian-installation
@{lib_dirs} = @{share_dirs}/ubuntu@{int2}_{32,64} @{share_dirs}/linux{32,64}
@{runtime_dirs} = @{lib_dirs}/steam-runtime{,-sniper}
@{app_dirs} = @{share_dirs}/steamapps/common/

@{exec_path} = @{lib_dirs}/fossilize_replay
profile steam-fossilize @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/graphics>
  include <abstractions/wayland>
  include <abstractions/X-strict>

  signal receive peer=steam,

  @{exec_path} mr,

  @{lib_dirs}/**  mr,

  owner @{HOME}/.steam/steam.pipe r,

  owner @{share_dirs}/logs/container-runtime-info.txt.@{rand6} rw,
  owner @{share_dirs}/steamapps/shadercache/@{int}/fozpipelinesv@{int}/{,**} rw,
  owner @{share_dirs}/steamapps/shadercache/@{int}/mesa_shader_cache_sf/{,**} rwk,
  owner @{share_dirs}/steamapps/shadercache/@{int}/nvidiav@{int}/GLCache/ rw,
  owner @{share_dirs}/steamapps/shadercache/@{int}/nvidiav@{int}/GLCache/** rwk,

  owner @{tmp}/runtime-info.txt.@{rand6} rw,

  owner /dev/shm/fossilize-*-@{int}-@{int} rw,

  @{sys}/devices/system/node/node@{int}/cpumap r,

        @{PROC}/@{pids}/statm r,
        @{PROC}/pressure/io r,
  owner @{PROC}/@{pid}/cmdline r,
  owner @{PROC}/@{pid}/task/@{tid}/comm rw,

  deny owner @{user_share_dirs}/gvfs-metadata/{,*} r,

  include if exists <local/steam-fossilize>
}

# vim:syntax=apparmor
