# 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}/filezilla
profile filezilla @{exec_path} {
  include <abstractions/base>
  include <abstractions/bus-session>
  include <abstractions/bus/org.freedesktop.Notifications>
  include <abstractions/bus/org.gnome.SessionManager>
  include <abstractions/dconf-write>
  include <abstractions/desktop>
  include <abstractions/fontconfig-cache-read>
  include <abstractions/nameservice-strict>
  include <abstractions/p11-kit>
  include <abstractions/ssl_certs>
  include <abstractions/user-download-strict>

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

  signal send set=(term, kill) peer=fzsftp,

  @{exec_path} mr,

  @{sh_path}         rix,
  @{bin}/uname       rix,

  @{bin}/fzsftp      rPx,  # When using SFTP protocol
  @{bin}/lsb_release rPx -> lsb_release,

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

  /etc/fstab r,

  / r,
  /*/ r,
  /*/*/ r,

  # FTP share folder
  owner @{MOUNTS}/ftp/ r,
  owner @{MOUNTS}/ftp/** rw,

  owner @{HOME}/ r,
  owner @{user_config_dirs}/filezilla/ rw,
  owner @{user_config_dirs}/filezilla/* rwk,

  owner @{user_cache_dirs}/filezilla/ rw,
  owner @{user_cache_dirs}/filezilla/default_*.png rw,

        /tmp/ r,
  owner @{tmp}/fz[0-9]temp-@{int}/ rw,
  owner @{tmp}/fz[0-9]temp-@{int}/fz*-lockfile rwk,
  owner @{tmp}/fz[0-9]temp-@{int}/empty_file_* rw,

  owner @{PROC}/@{pid}/fd/ r,
  owner @{PROC}/@{pid}/mountinfo r,
  owner @{PROC}/@{pid}/mounts r,

        /dev/tty rw,
  owner /dev/tty@{int} rw,

  include if exists <local/filezilla>
}

# vim:syntax=apparmor
