# ------------------------------------------------------------------
#
#    Copyright (C) 2002-2006 Novell/SUSE
#    Copyright (C) 2018 Canonical, Ltd.
#    Copyright (C) 2019-2021 Christian Boltz
#
#    This program is free software; you can redistribute it and/or
#    modify it under the terms of version 2 of the GNU General Public
#    License published by the Free Software Foundation.
#
# ------------------------------------------------------------------

abi <abi/4.0>,

include <tunables/global>

@{exec_path}=/usr/lib{,exec}/postfix/{bin/,sbin/,}smtpd
profile postfix-smtpd /usr/lib{,exec}/postfix/{bin/,sbin/,}smtpd flags=(attach_disconnected.path=/apparmor/disconnected/) {
  include <abstractions/base>
  include <abstractions/nameservice>
  include <abstractions/postfix-common>
  include <abstractions/ssl_certs>
  include <abstractions/ssl_keys>

  capability dac_override,
  capability dac_read_search,

  /apparmor/disconnected/var/spool/postfix/private/auth w,

  @{exec_path} mrix,

  /usr/sbin/postdrop                           rPx,

  /dev/urandom                                r,
  /etc/aliases.{lm,}db                        rk,
  # mailman on SuSE is configured to have its own alias db
  /var/lib/mailman/data/aliases.{lm,}db       rk,
  /etc/mtab                                   r,
  /etc/fstab                                  r,
  /etc/postfix/*.regexp                       r,
  /etc/postfix/{ssl/,}*.pem                   r,
  /etc/postfix/smtpd_scache.dir               r,
  /etc/postfix/smtpd_scache.pag               rw,
  /etc/postfix/main.cf                        r,
  /etc/postfix/prng_exch                      rw,

  /usr/share/ssl/certs/ca-bundle.crt          r,

  /{var/spool/postfix/,}incoming/*               rw,
  /{var/spool/postfix/,}pid/inet.*               rwk,
  /{var/spool/postfix/,}pid/pass.smtpd           rwk,
  /{var/spool/postfix/,}private/anvil            rw,
  /{var/spool/postfix/,}private/proxymap         rw,
  /{var/spool/postfix/,}private/rewrite          rw,
  /{var/spool/postfix/,}private/tlsmgr           rw,
  /{var/spool/postfix/,}public/cleanup           rw,

  /{,var/}run/sasl2/mux                             w,

  # Site-specific additions and overrides. See local/README for details.
  include if exists <local/postfix-smtpd>
}
