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

abi <abi/3.0>,

include <tunables/global>

@{exec_path} = @{lib}/systemd/systemd-timesyncd
profile systemd-timesyncd @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>
  include <abstractions/bus-system>
  include <abstractions/nameservice-strict>
  include <abstractions/common/systemd>

  capability sys_time,

  network inet dgram,
  network inet6 dgram,
  network inet stream,
  network inet6 stream,

  unix (bind) type=stream addr=@@{hex}/bus/systemd-timesyn/bus-api-timesync,
  unix (send, receive) type=dgram addr=none peer=(label=@{p_systemd}, addr=none),

  #aa:dbus own bus=system name=org.freedesktop.timesync1

  @{exec_path} mr,

  @{etc_rw}/adjtime r,
  /etc/systemd/timesyncd.conf r,
  /etc/systemd/timesyncd.conf.d/{,**} r,

  owner /var/lib/systemd/timesync/clock rw,

        @{run}/resolvconf/*.conf r,
        @{run}/systemd/netif/state r,
        @{run}/systemd/notify rw,
        @{run}/systemd/timesyncd.conf.d/{,**} r,
  owner @{run}/systemd/journal/socket w,
  owner @{run}/systemd/timesync/synchronized rw,

  @{PROC}/@{pid}/cgroup r,
  @{PROC}/pressure/* r,

  include if exists <local/systemd-timesyncd>
}
