# 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}/geoclue @{lib}/geoclue-2.0/demos/agent
@{att} = /att/geoclue/
profile geoclue /{{,usr/}lib{,exec,32,64}/geoclue,{,usr/}lib{,exec,32,64}/geoclue-2.0/demos/agent}  flags=(attach_disconnected,attach_disconnected.path=@{att},complain) {
  include <abstractions/attached/base>
  include <abstractions/bus-system>
  include <abstractions/bus/org.freedesktop.ModemManager1>
  include <abstractions/bus/org.freedesktop.NetworkManager>
  include <abstractions/bus/system/fi.w1.wpa_supplicant1>
  include <abstractions/bus/system/org.freedesktop.Avahi.Server>
  include <abstractions/bus/system/org.freedesktop.Avahi.ServiceBrowser>
  include <abstractions/attached/consoles>
  include <abstractions/gschemas>
  include <abstractions/nameservice-strict>
  include <abstractions/p11-kit>
  include <abstractions/ssl_certs>

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

  include <abstractions/bus/system/own>

  dbus bind bus=system name=org.freedesktop.GeoClue2{,.*},
  dbus receive bus=system path=/org/freedesktop/GeoClue2{,/**}
       interface=org.freedesktop.GeoClue2{,.*}
       peer=(name="@{busname}"),
  dbus send bus=system path=/org/freedesktop/GeoClue2{,/**}
       interface=org.freedesktop.GeoClue2{,.*}
       peer=(name="{@{busname},org.freedesktop.DBus}"),
  dbus (send receive) bus=system path=/org/freedesktop/GeoClue2{,/**}
       interface=org.freedesktop.DBus.Properties
       member={Get,GetAll,Set,PropertiesChanged}
       peer=(name="{@{busname},org.freedesktop.DBus}"),
  dbus receive bus=system path=/org/freedesktop/GeoClue2{,/**}
       interface=org.freedesktop.DBus.Introspectable
       member=Introspect
       peer=(name="@{busname}"),
  dbus receive bus=system path=/org/freedesktop/GeoClue2{,/**}
       interface=org.freedesktop.DBus.ObjectManager
       member=GetManagedObjects
       peer=(name="{@{busname},org.freedesktop.GeoClue2{,.*}}"),
  dbus send bus=system path=/org/freedesktop/GeoClue2{,/**}
       interface=org.freedesktop.DBus.ObjectManager
       member={InterfacesAdded,InterfacesRemoved}
       peer=(name="{@{busname},org.freedesktop.DBus}"),

  @{exec_path} mr,

  /etc/geoclue/{,**} r,
  /etc/sysconfig/proxy r,

  /var/lib/nscd/services r,
  /var/lib/dbus/machine-id r,

  @{run}/systemd/resolve/io.systemd.Resolve rw,

  @{PROC}/@{pids}/cgroup r,
  @{PROC}/sys/net/ipv{4,6}/conf/all/disable_ipv{4,6} r,

  include if exists <local/geoclue>
}

# vim:syntax=apparmor
