#!/usr/bin/make -f

# fortify detects a non-existent buffer overflow when processing the offline
# queue at startup at the "realpath" call. Disabling it after discussion with
# upstream.
export DEB_BUILD_MAINT_OPTIONS=hardening=-fortify

%:
	dh $@ --with autoreconf

override_dh_auto_configure:
	dh_auto_configure -- \
	    --with-pam \
	    --with-mantype=man \
	    --with-maildir=/var/mail \
	    --with-privsep-path=/var/lib/opensmtpd/empty \
	    --with-privsep-user=opensmtpd \
	    --with-queue-user=opensmtpq \
	    --with-ca-file=/etc/ssl/certs/ca-certificates.crt

override_dh_installchangelogs:
	dh_installchangelogs debian/upstream_changelog.txt

override_dh_fixperms:
	dh_fixperms
	chmod 711 debian/opensmtpd/var/spool/smtpd
	# OpenSMTPD needs the offline mail queue (for messages sent locally,
	# e.g., via /usr/sbin/sendmail) to be 1777
	chmod 1777 debian/opensmtpd/var/spool/smtpd/offline
