# 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} = @{lib}/iwd/iwd
@{att} = ""
profile iwd /{,usr/}lib{,exec,32,64}/iwd/iwd flags=(complain) {
  include <abstractions/base-strict>

  capability net_admin,
  capability net_raw,
  capability net_bind_service,

  network inet dgram,
  network inet6 dgram,
  network inet stream,
  network inet6 stream,
  network netlink raw,
  network netlink dgram,
  network alg seqpacket, # kernel crypto API
  network packet dgram,

  @{exec_path} mr,
  @{sbin}/resolvconf rpx,

  /etc/iwd/{,**} r,
  /var/lib/iwd/{,**} rw,

  @{sys}/devices/@{pci}/ieee80211/phy@{int}/* r,
  @{sys}/devices/@{pci}/modalias r,

  @{PROC}/sys/net/ipv{4,6}/conf/wlan@{int}/arp_* rw,
  @{PROC}/sys/net/ipv{4,6}/conf/wlan@{int}/drop_* rw,
  @{PROC}/sys/net/ipv{4,6}/conf/wlan@{int}/ndisc_* rw,
  @{PROC}/sys/net/ipv{4,6}/conf/wlan@{int}/accept_ra rw,
  @{PROC}/sys/net/ipv{4,6}/conf/wlan@{int}/optimistic_dad rw,
  @{PROC}/sys/net/ipv{4,6}/conf/wlp*/arp_* rw,
  @{PROC}/sys/net/ipv{4,6}/conf/wlp*/drop_* rw,
  @{PROC}/sys/net/ipv{4,6}/conf/wlp*/ndisc_* rw,
  @{PROC}/sys/net/ipv{4,6}/conf/wlp*/accept_ra rw,
  @{PROC}/sys/net/ipv{4,6}/conf/wlp*/optimistic_dad rw,

  /dev/rfkill rw,

  include if exists <local/iwd>
}

# vim:syntax=apparmor
