# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2020-2021 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} = @{bin}/syncthing
profile syncthing @{exec_path} {
  include <abstractions/base>
  include <abstractions/nameservice-strict>
  include <abstractions/ssl_certs>

  network inet dgram,
  network inet6 dgram,
  network inet stream,
  network inet6 stream,
  network netlink raw,

  @{exec_path} mrix,

  @{open_path}     rPx -> child-open,
  @{bin}/ip        rix,

  /usr/share/mime/{,**} r,

  /etc/mime.types r,

  owner @{HOME}/ r,
  owner @{HOME}/@{XDG_DATA_DIR}/syncthing/{,**} rwk,
  owner @{user_config_dirs}/syncthing/{,**} rwk,
  owner @{user_state_dirs}/syncthing/{,**} rwk,

  /home/ r,
  @{user_sync_dirs}/{,**} rw,

  @{sys}/kernel/mm/transparent_hugepage/hpage_pmd_size r,

        @{PROC}/@{pids}/net/route r,
        @{PROC}/sys/net/core/somaxconn r,
  owner @{PROC}/@{pid}/cgroup r,
  owner @{PROC}/@{pid}/mountinfo r,

  include if exists <local/syncthing>
}

# vim:syntax=apparmor
