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

abi <abi/3.0>,

include <tunables/global>

@{exec_path} = @{bin}/dhclient
profile dhclient @{exec_path} {
  include <abstractions/base>
  include <abstractions/nameservice-strict>

  capability net_admin,
  capability net_bind_service,
  capability net_raw,

  network inet dgram,
  network inet6 dgram,
  network netlink raw,
  network packet raw,

  signal (send) peer=unconfined,

  @{exec_path} mr,

  # To run dhclient scripts
  @{bin}/dhclient-script rPx,

  /etc/dhclient.conf r,
  /etc/dhcp/{,**} r,

  /var/lib/dhcp{,3}/dhclient* rw,
  owner @{run}/dhclient*.pid rw,
  owner @{run}/dhclient*.lease* rw,

  owner @{PROC}/@{pid}/task/@{tid}/comm rw,

  include if exists <local/dhclient>
}
