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

include <tunables/global>

@{exec_path} = @{lib}/{,ibus/}ibus-dconf
profile ibus-dconf @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/bus-session>
  include <abstractions/bus-system>
  include <abstractions/dconf-write>
  include <abstractions/nameservice-strict>

  signal (receive) set=term peer=ibus-daemon,

  unix (send, receive, connect) type=stream peer=(addr="@/home/*/.cache/ibus/dbus-????????",          label=ibus-daemon),
  unix (send, receive, connect) type=stream peer=(addr="@/var/lib/gdm{3,}/.cache/ibus/dbus-????????", label=ibus-daemon),

  dbus receive bus=session
       interface=org.freedesktop.DBus.Introspectable
       member=Introspect
       peer=(name=:*, label=gnome-shell),

  @{exec_path} mr,

  /usr/share/gdm/greeter-dconf-defaults r,
  /usr/share/dconf/profile/gdm r,

  /etc/dconf/db/ibus r,
  /etc/dconf/profile/ibus r,

  owner @{desktop_cache_dirs}/dconf/ w,
  owner @{desktop_cache_dirs}/dconf/user rw,
  owner @{desktop_cache_dirs}/ibus/dbus-@{rand8} rw,
  owner @{desktop_config_dirs}/dconf/ w,
  owner @{desktop_config_dirs}/dconf/user rw,
  owner @{desktop_config_dirs}/ibus/bus/ r,
  owner @{desktop_config_dirs}/ibus/bus/@{hex32}-unix-{,wayland-}@{int} r,
  owner @{DESKTOP_HOME}/greeter-dconf-defaults r,

  owner @{user_cache_dirs}/ibus/dbus-@{rand8} rw,

  owner @{user_config_dirs}/ibus/bus/ r,
  owner @{user_config_dirs}/ibus/bus/@{hex32}-unix-{,wayland-}@{int} r,

  owner /dev/tty@{int} rw,

  include if exists <local/ibus-dconf>
}

# vim:syntax=apparmor
