# 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/4.0>,

include <tunables/global>

@{exec_path} = @{bin}/evince @{lib}/evinced
profile evince @{exec_path} {
  include <abstractions/base>
  include <abstractions/bus-accessibility>
  include <abstractions/bus-session>
  include <abstractions/bus/org.a11y>
  include <abstractions/bus/org.freedesktop.FileManager1>
  include <abstractions/bus/org.freedesktop.portal.Desktop>
  include <abstractions/bus/org.gnome.SessionManager>
  include <abstractions/dconf-write>
  include <abstractions/gnome-strict>
  include <abstractions/ibus>
  include <abstractions/nameservice-strict>
  include <abstractions/thumbnails-cache-write>
  include <abstractions/user-download-strict>
  include <abstractions/user-read-strict>
  include <abstractions/user-write-strict>

  # also denies network mounts
  deny network inet,
  deny network inet6,

  #aa:dbus own bus=session name=org.gnome.evince

  #aa:dbus talk bus=session name=org.gnome.SettingsDaemon.MediaKeys label=gsd-media-keys
  #aa:dbus talk bus=session name=org.gtk.vfs label="gvfsd{,-*}"

  @{exec_path} rix,

  @{sh_path}                 rix,
  @{open_path}               rPx -> child-open,

  /usr/share/djvu/{,**} r,
  /usr/share/evince/{,**} r,
  /usr/share/ghostscript/{,**} r,
  /usr/share/poppler/{,**} r,
  /usr/share/thumbnailers/{,*} r,

  owner @{user_share_dirs}/ r,
  owner @{user_share_dirs}/gvfs-metadata/{,*} r,
  owner @{user_config_dirs}/evince/{,*} rw,

  owner @{tmp}/*.pdf r,
  owner @{tmp}/evince-*/{,**} rw,
  owner @{tmp}/gtkprint* rw,

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

  /dev/tty rw,

  deny @{lib}/ r, # asks when viewing PostScript files

  include if exists <local/evince>
}

# vim:syntax=apparmor
