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

abi <abi/3.0>,

include <tunables/global>

@{exec_path}  = @{bin}/Xwayland
profile xwayland @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/graphics>
  include <abstractions/nameservice-strict>
  include <abstractions/X-strict>

  signal (receive) set=(term hup) peer=gdm*,
  signal (receive) set=(term hup) peer=gnome-shell,
  signal (receive) set=(term hup) peer=kwin_wayland,
  signal (receive) set=(term hup) peer=login,

  unix type=stream addr=none peer=(label=gnome-shell, addr=none),

  @{exec_path} mrix,

  @{sh_path}        rix,
  @{bin}/xkbcomp    rPx,

  /usr/share/fonts/{,**} r,
  /usr/share/ghostscript/fonts/{,**} r,

  owner @{tmp}/server-@{int}.xkm rwk,
  owner @{run}/user/@{uid}/.mutter-Xwaylandauth.@{rand6} rw,
  owner @{run}/user/@{uid}/server-@{int}.xkm rw,
  owner @{run}/user/@{uid}/xwayland-shared-@{rand6} rw,

  @{PROC}/@{pids}/cmdline r,

  /dev/tty@{int} rw,
  /dev/tty rw,

  include if exists <local/xwayland>
}

# vim:syntax=apparmor
