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

include <tunables/global>

@{exec_path} = @{bin}/losetup
profile losetup @{exec_path} {
  include <abstractions/base>
  include <abstractions/consoles>

  capability dac_override,
  capability dac_read_search,

  unix (receive) type=stream,

  @{exec_path} mr,

  @{sys}/devices/**/usb[0-9]/{,**} r,

  /dev/loop-control rw,
  /dev/loop[0-9]* rw,

  include if exists <local/losetup>
}