# 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}/tailscale
profile tailscale @{exec_path} {
  include <abstractions/base>
  include <abstractions/nameservice-strict>

  capability sys_ptrace,

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

  ptrace (read),

  @{exec_path} mr,

  @{bin}/ip rPx,

  owner @{run}/tailscale/tailscaled.sock rw,

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

        @{PROC}/ r,
        @{PROC}/@{pids}/stat r,
        @{PROC}/sys/net/core/somaxconn r,
  owner @{PROC}/@{pids}/environ r,

  include if exists <local/tailscale>
}