# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2018-2021 Mikhail Morfikov
# 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} = @{bin}/vnstatd
@{att} = ""
profile vnstatd /{,usr/}bin/vnstatd flags=(complain) {
  include <abstractions/base-strict>

  @{exec_path} mr,

  # vnstat daemon config
  /etc/vnstat.conf r,

  # To determine capacity of a network interface
  @{sys}/devices/@{pci}/net/**/speed r,
  @{sys}/devices/virtual/net/**/speed r,

  # To collect interfaces' data
  @{PROC}/@{pid}/net/dev r,

  # To store the collected data
  owner /var/lib/vnstat/ rw,
  owner /var/lib/vnstat/vnstat.db rwk,
  owner /var/lib/vnstat/vnstat.db-journal rw,

  include if exists <local/vnstatd>
}

# vim:syntax=apparmor
