[packages/postfix] Up to 3.11.5

arekm arekm at pld-linux.org
Wed Jul 29 07:16:26 CEST 2026


commit 77af3fbe11e2a135df6b466fe731f58c8171e19c
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Mon Jul 27 13:01:10 2026 +0200

    Up to 3.11.5
    
    3.6 is EOL; pcre2, dropped dead/upstreamed patches, restart on systemd upgrade (3.10 delivery agent protocol change).

 format-security.patch          |   27 -
 glibc-2.34.patch               |   10 -
 postfix-conf.patch             |    8 +-
 postfix-config.patch           |   48 +-
 postfix-dictname.patch         |   29 +-
 postfix-egrep.patch            |   42 --
 postfix-header_if_reject.patch |  189 ------
 postfix-master.cf_cyrus.patch  |    7 +-
 postfix-scache_clnt.patch      |   11 -
 postfix-vda-bigquota.patch     |  204 ------
 postfix-vda.patch              | 1376 ----------------------------------------
 postfix.spec                   |  107 ++--
 12 files changed, 91 insertions(+), 1967 deletions(-)
---
diff --git a/postfix.spec b/postfix.spec
index df931fb..192738a 100644
--- a/postfix.spec
+++ b/postfix.spec
@@ -8,8 +8,6 @@
 %bcond_without	ssl	# SSL/TLS support
 %bcond_without	cdb	# cdb map support
 %bcond_without	lmdb	# lmdb map support
-%bcond_with	vda	# VDA patch
-%bcond_with	hir	# Beeth's header_if_reject patch
 %bcond_with	tcp	# unofficial tcp: lookup table
 %if "%{pld_release}" == "ac"
 %bcond_with	epoll	# epoll support for 2.6 kernels
@@ -21,7 +19,6 @@
 %bcond_without	epoll	# epoll support (Linux >= 2.6)
 %endif
 
-%define		vda_ver v13-2.10.0
 Summary:	Postfix Mail Transport Agent
 Summary(cs.UTF-8):	Postfix - program pro přepravu pošty (MTA)
 Summary(es.UTF-8):	Postfix - Un MTA (Mail Transport Agent) de alto desempeño
@@ -30,43 +27,30 @@ Summary(pl.UTF-8):	Serwer SMTP Postfix
 Summary(pt_BR.UTF-8):	Postfix - Um MTA (Mail Transport Agent) de alto desempenho
 Summary(sk.UTF-8):	Agent prenosu pošty Postfix
 Name:		postfix
-Version:	3.6.18
-Release:	5
+Version:	3.11.5
+Release:	1
 Epoch:		2
 License:	IBM Public License or Eclipse Public License v2.0
 Group:		Networking/Daemons/SMTP
 Source0:	ftp://ftp.porcupine.org/mirrors/postfix-release/official/%{name}-%{version}.tar.gz
-# Source0-md5:	10aed60e989a78df19b093e077c58dcc
+# Source0-md5:	bf04d33ca8050322160df2d8d88a13e4
 Source1:	%{name}.aliases
 Source2:	%{name}.cron
 Source3:	%{name}.init
 Source4:	%{name}.sysconfig
 Source5:	%{name}.sasl
 Source6:	%{name}.pamd
-Source7:	%{name}-vda.patch
-#Source7:	http://vda.sourceforge.net/VDA/%{name}-vda-%{vda_ver}.patch
-# -ource7-md5:	01e1b031d79b85f3cb67d98ceddd775d
 Source8:	%{name}-bounce.cf.pl
 # http://postfix.state-of-mind.de/bounce-templates/bounce.de-DE.cf
 Source9:	%{name}-bounce.cf.de
 Source10:	%{name}.monitrc
-Source11:	%{name}-vda-bigquota.patch
-#Source11:	http://vda.sourceforge.net/VDA/%{name}-%{vda_ver}-vda-ng-bigquota.patch.gz
-# -ource11-md5:	d46103195b43ec5784ea2c166b238f71
 Source12:	%{name}.service
 Patch0:		%{name}-config.patch
-Patch1:         %{name}-egrep.patch
 
 Patch3:		%{name}-master.cf_cyrus.patch
-# from http://akson.sgh.waw.pl/~chopin/unix/postfix-2.1.5-header_if_reject.diff
-Patch4:		%{name}-header_if_reject.patch
 
 Patch7:		%{name}-conf.patch
 Patch8:		%{name}-dictname.patch
-
-Patch11:	%{name}-scache_clnt.patch
-Patch12:	format-security.patch
-Patch13:	glibc-2.34.patch
 URL:		http://www.postfix.org/
 %{?with_sasl:BuildRequires:	cyrus-sasl-devel}
 BuildRequires:	db-devel
@@ -74,12 +58,12 @@ BuildRequires:	db-devel
 BuildRequires:	glibc-devel >= 6:2.3.4
 BuildRequires:	libicu-devel
 BuildRequires:	libnsl-devel
-BuildRequires:	m4
 %{?with_lmdb:BuildRequires:	lmdb-devel}
+BuildRequires:	m4
 %{?with_mysql:BuildRequires:	mysql-devel}
 %{?with_ldap:BuildRequires:	openldap-devel >= 2.0.12}
-%{?with_ssl:BuildRequires:	openssl-devel >= 0.9.7l}
-BuildRequires:	pcre-devel
+%{?with_ssl:BuildRequires:	openssl-devel >= 1.1.1}
+BuildRequires:	pcre2-8-devel
 BuildRequires:	perl-base
 %{?with_pgsql:BuildRequires:	postgresql-devel}
 BuildRequires:	rpm >= 4.4.9-56
@@ -102,8 +86,8 @@ Requires:	diffutils
 Requires:	findutils
 Requires:	rc-scripts
 Requires:	sed
-%{?with_cdb:Requires:tinycdb}
 Requires:	systemd-units >= 38
+%{?with_cdb:Requires:	tinycdb}
 Suggests:	cyrus-sasl-saslauthd
 Provides:	group(maildrop)
 Provides:	group(postfix)
@@ -125,7 +109,7 @@ desea tener un servidor SMTP *rápido*, debe instalar este paquete.
 %description -l fr.UTF-8
 Postfix (voir http://www.postfix.org/) se veut une alternative à
 sendmail, responsable de l'acheminement de 70% des courriers
-électroniques sur Internet. IBM en a suppotré le développement, mais
+électroniques sur Internet. IBM en a supporté le développement, mais
 ne contrôle pas son évolution. Le but est d'installer Postfix sur le
 plus grand nombre de systèmes possible. Dans cette optique, il a été
 écrit pour être totalement sous le contrôle de l'utilisateur.
@@ -298,44 +282,31 @@ Plik monitrc do monitorowania serwera Postfix.
 
 %prep
 %setup -q
-%if %{with vda}
-cat %{SOURCE7} | %{__patch} -p1 -s
-cat %{SOURCE11} | %{__patch} -p1 -s
-%endif
 
 find -type f | xargs %{__sed} -i -e 's|/etc/postfix|/etc/mail|g'
 
 %patch -P0 -p1
-%patch -P1 -p1
 
 %patch -P3 -p1
-%{?with_hir:%patch -P4 -p0}
 
-%{__sed} -i -e '/scache_clnt_create/s/server/var_scache_service/' src/global/scache_clnt.c
 %patch -P7 -p1
 %patch -P8 -p1
 
-%patch -P11 -p1
-%if %{with vda}
-%patch -P12 -p1
-%endif
-%patch -P13 -p1
-
 %if %{with tcp}
-sed -i 's/ifdef SNAPSHOT/if 1/' src/util/dict_open.c
+%{__sed} -i -e 's/ifdef SNAPSHOT/if 1/' src/util/dict_open.c
 %endif
 
 %{__sed} -i -e 's,/lib64\>,/%{_lib},' makedefs
 
 %build
 # export, as the same variables must be passed both to 'make makefiles' and 'make'
-export CCARGS="-std=gnu17 %{!?with_epoll:-DNO_EPOLL} %{?with_ldap:-DHAS_LDAP} -DHAS_PCRE %{?with_sasl:-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl} %{?with_mysql:-DHAS_MYSQL -I/usr/include/mysql} %{?with_pgsql:-DHAS_PGSQL} %{?with_ssl:-DUSE_TLS} -DMAX_DYNAMIC_MAPS %{?with_cdb:-DHAS_CDB} %{?with_sqlite:-DHAS_SQLITE} %{?with_lmdb:-DHAS_LMDB} -LHAS_SDBM"
+export CCARGS="%{!?with_epoll:-DNO_EPOLL} %{?with_ldap:-DHAS_LDAP} -DHAS_PCRE=2 %{?with_sasl:-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl} %{?with_mysql:-DHAS_MYSQL -I/usr/include/mysql} %{?with_pgsql:-DHAS_PGSQL} %{?with_ssl:-DUSE_TLS} -DMAX_DYNAMIC_MAPS %{?with_cdb:-DHAS_CDB} %{?with_sqlite:-DHAS_SQLITE} %{?with_lmdb:-DHAS_LMDB}"
 export AUXLIBS="%{rpmldflags} -lsasl -lssl -lcrypto"
 export AUXLIBS_CDB="%{?with_cdb:-lcdb}"
 export AUXLIBS_LDAP="%{?with_ldap:-lldap -llber}"
 export AUXLIBS_LMDB="%{?with_lmdb:-llmdb}"
 export AUXLIBS_MYSQL="%{?with_mysql:-lmysqlclient}"
-export AUXLIBS_PCRE="-lpcre"
+export AUXLIBS_PCRE="-lpcre2-8"
 export AUXLIBS_PGSQL="%{?with_pgsql:-lpq}"
 export AUXLIBS_SQLITE="%{?with_sqlite:-lsqlite3}"
 
@@ -355,6 +326,7 @@ export CC="%{__cc}"
 rm -rf $RPM_BUILD_ROOT
 install -d $RPM_BUILD_ROOT/etc/{cron.daily,rc.d/init.d,sysconfig,pam.d,security,monit} \
 	$RPM_BUILD_ROOT%{_sysconfdir}/{mail,sasl} \
+	$RPM_BUILD_ROOT%{_sysconfdir}/mail/{dynamicmaps.cf.d,postfix-files.d} \
 	$RPM_BUILD_ROOT{%{_bindir},%{_sbindir},%{_libdir}/postfix,/usr/lib}\
 	$RPM_BUILD_ROOT{%{_includedir}/postfix,%{_mandir}} \
 	$RPM_BUILD_ROOT%{_var}/spool/postfix/{active,corrupt,deferred,maildrop,private,saved,bounce,defer,incoming,pid,public} \
@@ -365,14 +337,14 @@ install -d $RPM_BUILD_ROOT/etc/{cron.daily,rc.d/init.d,sysconfig,pam.d,security,
        install_root=$RPM_BUILD_ROOT
 
 #cp -a conf/* $RPM_BUILD_ROOT%{_sysconfdir}/mail
-sed -e's,^daemon_directory = .*,daemon_directory = %{_libdir}/postfix,' \
+%{__sed} -e 's,^daemon_directory = .*,daemon_directory = %{_libdir}/postfix,' \
 	conf/main.cf > $RPM_BUILD_ROOT%{_sysconfdir}/mail/main.cf
 
 cp -a include/*.h $RPM_BUILD_ROOT%{_includedir}/postfix
 
 cp -a %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/mail/aliases
 install -p %{SOURCE2} $RPM_BUILD_ROOT/etc/cron.daily/postfix
-install %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/postfix
+install -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/postfix
 cp -a %{SOURCE4} $RPM_BUILD_ROOT/etc/sysconfig/postfix
 cp -a %{SOURCE5} $RPM_BUILD_ROOT%{_sysconfdir}/sasl/smtpd.conf
 cp -a %{SOURCE6} $RPM_BUILD_ROOT/etc/pam.d/smtp
@@ -394,9 +366,12 @@ touch $RPM_BUILD_ROOT/etc/security/blacklist.smtp
 
 > $RPM_BUILD_ROOT/var/spool/postfix/.nofinger
 
-%{__rm} -r $RPM_BUILD_ROOT%{_sysconfdir}/mail/makedefs.out
+%{__rm} $RPM_BUILD_ROOT%{_sysconfdir}/mail/makedefs.out
 %{__rm} $RPM_BUILD_ROOT%{_sysconfdir}/mail/{,TLS_}LICENSE
 
+# mongodb map is not built - no libmongoc in PLD
+%{__rm} $RPM_BUILD_ROOT%{_mandir}/man5/mongodb_table.5
+
 %clean
 rm -rf $RPM_BUILD_ROOT
 
@@ -427,6 +402,9 @@ fi
 /sbin/chkconfig --add postfix
 %service postfix restart "Postfix Daemon"
 %systemd_post postfix.service
+# %%service only restarts under SysV init; 3.10 changed the delivery agent
+# protocol, so a running master must be restarted or deliveries fail
+%systemd_service_restart postfix.service
 
 %preun
 if [ "$1" = "0" ]; then
@@ -455,24 +433,30 @@ fi
 %dir %{_sysconfdir}/mail
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mail/access
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mail/aliases
-%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mail/bounce.cf.default
 %lang(de) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mail/bounce.cf.de
 %lang(pl) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mail/bounce.cf.pl
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mail/canonical
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mail/generic
-#%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mail/regexp_table
+#%%config(noreplace) %%verify(not md5 mtime size) %%{_sysconfdir}/mail/regexp_table
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mail/relocated
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mail/transport
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mail/virtual
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mail/header_checks
-#%ghost %{_sysconfdir}/mail/*.db
-%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mail/dynamicmaps.cf
+#%%ghost %%{_sysconfdir}/mail/*.db
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mail/main.cf
-%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mail/main.cf.default
-%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mail/main.cf.proto
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mail/master.cf
-%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mail/master.cf.proto
-%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mail/postfix-files
+# package-owned reference and generated files, so let upgrades replace them:
+# a stale postfix-files would revert postlog's setgid bit and a stale
+# dynamicmaps.cf would list the wrong plugins. Local additions belong in
+# main.cf, master.cf or the matching *.d directory.
+%config %verify(not md5 mtime size) %{_sysconfdir}/mail/bounce.cf.default
+%config %verify(not md5 mtime size) %{_sysconfdir}/mail/dynamicmaps.cf
+%config %verify(not md5 mtime size) %{_sysconfdir}/mail/main.cf.default
+%config %verify(not md5 mtime size) %{_sysconfdir}/mail/main.cf.proto
+%config %verify(not md5 mtime size) %{_sysconfdir}/mail/master.cf.proto
+%config %verify(not md5 mtime size) %{_sysconfdir}/mail/postfix-files
+%dir %{_sysconfdir}/mail/dynamicmaps.cf.d
+%dir %{_sysconfdir}/mail/postfix-files.d
 %attr(740,root,root) /etc/cron.daily/postfix
 %attr(754,root,root) /etc/rc.d/init.d/postfix
 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/postfix
@@ -486,7 +470,8 @@ fi
 %attr(755,root,root) %{_sbindir}/postfix
 %attr(755,root,root) %{_sbindir}/postalias
 %attr(755,root,root) %{_sbindir}/postkick
-%attr(755,root,root) %{_sbindir}/postl*
+%attr(755,root,root) %{_sbindir}/postlock
+%attr(2755,root,maildrop) %{_sbindir}/postlog
 %attr(755,root,root) %{_sbindir}/postc*
 %attr(755,root,root) %{_sbindir}/postmap
 %attr(755,root,root) %{_sbindir}/postmulti
@@ -502,18 +487,20 @@ fi
 %attr(755,root,root) %{_libdir}/postfix/dnsblog
 %attr(755,root,root) %{_libdir}/postfix/error
 %attr(755,root,root) %{_libdir}/postfix/flush
-%attr(755,root,root) %{_libdir}/postfix/libpostfix-dns.so
-%attr(755,root,root) %{_libdir}/postfix/libpostfix-global.so
-%attr(755,root,root) %{_libdir}/postfix/libpostfix-master.so
-%attr(755,root,root) %{_libdir}/postfix/libpostfix-tls.so
-%attr(755,root,root) %{_libdir}/postfix/libpostfix-util.so
+%{_libdir}/postfix/libpostfix-dns.so
+%{_libdir}/postfix/libpostfix-global.so
+%{_libdir}/postfix/libpostfix-master.so
+%{_libdir}/postfix/libpostfix-tls.so
+%{_libdir}/postfix/libpostfix-util.so
 %attr(755,root,root) %{_libdir}/postfix/lmtp
 %attr(755,root,root) %{_libdir}/postfix/local
 %attr(755,root,root) %{_libdir}/postfix/master
+%attr(755,root,root) %{_libdir}/postfix/nbdb_reindexd
 %attr(755,root,root) %{_libdir}/postfix/nqmgr
 %attr(755,root,root) %{_libdir}/postfix/oqmgr
 %attr(755,root,root) %{_libdir}/postfix/pickup
 %attr(755,root,root) %{_libdir}/postfix/pipe
+%attr(755,root,root) %{_libdir}/postfix/postfix-non-bdb-script
 %attr(755,root,root) %{_libdir}/postfix/postfix-script
 %attr(755,root,root) %{_libdir}/postfix/postfix-tls-script
 %attr(755,root,root) %{_libdir}/postfix/postlogd
@@ -534,7 +521,7 @@ fi
 %attr(755,root,root) %{_libdir}/postfix/trivial-rewrite
 %attr(755,root,root) %{_libdir}/postfix/verify
 %attr(755,root,root) %{_libdir}/postfix/virtual
-%attr(755,root,root) %dir %{_var}/spool/postfix
+%dir %{_var}/spool/postfix
 %attr(700,postfix,root) %dir %{_var}/spool/postfix/active
 %attr(700,postfix,root) %dir %{_var}/spool/postfix/bounce
 %attr(700,postfix,root) %dir %{_var}/spool/postfix/corrupt
@@ -542,7 +529,7 @@ fi
 %attr(700,postfix,root) %dir %{_var}/spool/postfix/deferred
 %attr(700,postfix,root) %dir %{_var}/spool/postfix/incoming
 %attr(1730,postfix,maildrop) %dir %{_var}/spool/postfix/maildrop
-%attr(755,root,root) %dir %{_var}/spool/postfix/pid
+%dir %{_var}/spool/postfix/pid
 %attr(700,postfix,root) %dir %{_var}/spool/postfix/private
 %attr(710,postfix,maildrop) %dir %{_var}/spool/postfix/public
 %attr(700,postfix,root) %dir %{_var}/spool/postfix/saved
@@ -595,7 +582,6 @@ fi
 %files dict-pcre
 %defattr(644,root,root,755)
 %attr(755,root,root) %{_libdir}/postfix/postfix-pcre.so
-#%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mail/pcre_table
 %{_mandir}/man5/pcre_table.5*
 
 %if %{with pgsql}
@@ -621,6 +607,7 @@ fi
 
 %if %{with cdb}
 %files dict-cdb
+%defattr(644,root,root,755)
 %attr(755,root,root) %{_libdir}/postfix/postfix-cdb.so
 %endif
 
diff --git a/format-security.patch b/format-security.patch
deleted file mode 100644
index 8fe53f0..0000000
--- a/format-security.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-diff -durN -x '*~' -x '*.orig' -x '*.rej' postfix-2.11.0.orig/src/virtual/maildir.c postfix-2.11.0/src/virtual/maildir.c
---- postfix-2.11.0.orig/src/virtual/maildir.c	2014-03-05 18:11:38.374082775 +0100
-+++ postfix-2.11.0/src/virtual/maildir.c	2014-03-05 18:13:58.470750715 +0100
-@@ -972,19 +972,19 @@
-         if (*var_virt_maildir_limit_message_maps != 0 && (limit_message = mail_addr_find(virtual_maildir_limit_message_maps, state.msg_attr.user, (char **) NULL)) != 0) {
-             errno = errnored;
-             if (errno == EFBIG) {
--                dsb_simple(why, "5.2.2", limit_message, NULL);
-+                dsb_simple(why, "5.2.2", "%s", limit_message);
-             }
-             if (errno == EDQUOT) {
--                dsb_simple(why, "4.2.2", limit_message, NULL);
-+                dsb_simple(why, "4.2.2", "%s", limit_message);
-             }
-         }
-         else {
-             errno = errnored;
-             if (errno == EFBIG) {
--                dsb_simple(why, "5.2.2", var_virt_maildir_limit_message, NULL);
-+                dsb_simple(why, "5.2.2", "%s", var_virt_maildir_limit_message);
-             }
-             if (errno == EDQUOT) {
--                dsb_simple(why, "4.2.2", var_virt_maildir_limit_message, NULL);
-+                dsb_simple(why, "4.2.2", "%s", var_virt_maildir_limit_message);
-             }
-         }
- 
diff --git a/glibc-2.34.patch b/glibc-2.34.patch
deleted file mode 100644
index 4ab1422..0000000
--- a/glibc-2.34.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- postfix-3.5.11/src/util/sys_defs.h~	2021-09-26 23:25:46.000000000 +0200
-+++ postfix-3.5.11/src/util/sys_defs.h	2021-09-26 23:32:57.661271117 +0200
-@@ -774,6 +774,7 @@
- #define PREPEND_PLUS_TO_OPTSTRING
- #define HAS_POSIX_REGEXP
- #define HAS_DLOPEN
-+#define HAS_CLOSEFROM
- #define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail"
- #define NATIVE_MAILQ_PATH "/usr/bin/mailq"
- #define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
diff --git a/postfix-conf.patch b/postfix-conf.patch
index cd92286..066cd13 100644
--- a/postfix-conf.patch
+++ b/postfix-conf.patch
@@ -1,6 +1,6 @@
---- postfix-2.3.0/conf/master.cf~	2006-07-25 13:36:17.245609587 +0300
-+++ postfix-2.3.0/conf/master.cf	2006-07-25 13:37:53.847756797 +0300
-@@ -79,7 +79,7 @@ postlog   unix-dgram n  -       n
+--- postfix-3.11.5.orig/conf/master.cf	2026-07-27 11:59:09.224225573 +0200
++++ postfix-3.11.5/conf/master.cf	2026-07-27 12:00:54.787674506 +0200
+@@ -97,7 +97,7 @@ postlog   unix-dgram n  -       n
  # Also specify in main.cf: maildrop_destination_recipient_limit=1
  #
  #maildrop  unix  -       n       n       -       -       pipe
@@ -9,7 +9,7 @@
  #
  # ====================================================================
  #
-@@ -76,7 +76,7 @@
+@@ -140,7 +140,7 @@ postlog   unix-dgram n  -       n
  #  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
  #
  #bsmtp     unix  -       n       n       -       -       pipe
diff --git a/postfix-config.patch b/postfix-config.patch
index b58335a..82fdf6c 100644
--- a/postfix-config.patch
+++ b/postfix-config.patch
@@ -1,7 +1,6 @@
-diff -dur -x '*~' -x '*.orig' -x '*.rej' postfix-2.11.0.orig/conf/main.cf postfix-2.11.0/conf/main.cf
---- postfix-2.11.0.orig/conf/main.cf	2014-03-05 17:54:24.197406701 +0100
-+++ postfix-2.11.0/conf/main.cf	2014-03-05 17:54:54.260740308 +0100
-@@ -39,7 +39,7 @@
+--- postfix-3.11.5.orig/conf/main.cf	2026-07-27 11:59:09.224019293 +0200
++++ postfix-3.11.5/conf/main.cf	2026-07-27 12:00:21.726549083 +0200
+@@ -62,7 +62,7 @@ command_directory = /usr/sbin
  # daemon programs (i.e. programs listed in the master.cf file). This
  # directory must be owned by root.
  #
@@ -10,7 +9,7 @@ diff -dur -x '*~' -x '*.orig' -x '*.rej' postfix-2.11.0.orig/conf/main.cf postfi
  
  # The data_directory parameter specifies the location of Postfix-writable
  # data files (caches, random numbers). This directory must be owned
-@@ -63,7 +63,7 @@
+@@ -86,7 +86,7 @@ mail_owner = postfix
  # These rights are used in the absence of a recipient user context.
  # DO NOT SPECIFY A PRIVILEGED USER OR THE POSTFIX OWNER.
  #
@@ -19,7 +18,7 @@ diff -dur -x '*~' -x '*.orig' -x '*.rej' postfix-2.11.0.orig/conf/main.cf postfi
  
  # INTERNET HOST AND DOMAIN NAMES
  # 
-@@ -95,7 +95,7 @@
+@@ -118,7 +118,7 @@ mail_owner = postfix
  # myorigin also specifies the default domain name that is appended
  # to recipient addresses that have no @domain part.
  #
@@ -28,7 +27,7 @@ diff -dur -x '*~' -x '*.orig' -x '*.rej' postfix-2.11.0.orig/conf/main.cf postfi
  #myorigin = $mydomain
  
  # RECEIVING MAIL
-@@ -379,7 +379,7 @@
+@@ -407,7 +407,7 @@ unknown_local_recipient_reject_code = 55
  # "postfix reload" to eliminate the delay.
  #
  #alias_maps = dbm:/etc/aliases
@@ -37,7 +36,7 @@ diff -dur -x '*~' -x '*.orig' -x '*.rej' postfix-2.11.0.orig/conf/main.cf postfi
  #alias_maps = hash:/etc/aliases, nis:mail.aliases
  #alias_maps = netinfo:/aliases
  
-@@ -390,7 +390,7 @@
+@@ -418,7 +418,7 @@ unknown_local_recipient_reject_code = 55
  #
  #alias_database = dbm:/etc/aliases
  #alias_database = dbm:/etc/mail/aliases
@@ -46,7 +45,7 @@ diff -dur -x '*~' -x '*.orig' -x '*.rej' postfix-2.11.0.orig/conf/main.cf postfi
  #alias_database = hash:/etc/aliases, hash:/opt/majordomo/aliases
  
  # ADDRESS EXTENSIONS (e.g., user+foo)
-@@ -418,7 +418,7 @@
+@@ -446,7 +446,7 @@ unknown_local_recipient_reject_code = 55
  # UNIX-style mailboxes are kept. The default setting depends on the
  # system type.
  #
@@ -55,7 +54,7 @@ diff -dur -x '*~' -x '*.orig' -x '*.rej' postfix-2.11.0.orig/conf/main.cf postfi
  #mail_spool_directory = /var/spool/mail
  
  # The mailbox_command parameter specifies the optional external
-@@ -440,8 +440,8 @@
+@@ -468,8 +468,8 @@ unknown_local_recipient_reject_code = 55
  # IF YOU USE THIS TO DELIVER MAIL SYSTEM-WIDE, YOU MUST SET UP AN
  # ALIAS THAT FORWARDS MAIL FOR ROOT TO A REAL USER.
  #
@@ -66,7 +65,7 @@ diff -dur -x '*~' -x '*.orig' -x '*.rej' postfix-2.11.0.orig/conf/main.cf postfi
  
  # The mailbox_transport specifies the optional transport in master.cf
  # to use after processing aliases and .forward files. This parameter
-@@ -613,45 +613,24 @@
+@@ -641,54 +641,24 @@ debugger_command =
  #	-dmS $process_name gdb $daemon_directory/$process_name
  #	$process_id & sleep 1
  
@@ -119,12 +118,20 @@ diff -dur -x '*~' -x '*.orig' -x '*.rej' postfix-2.11.0.orig/conf/main.cf postfi
 +# Contrary to what Wietse thinks (450) this should be 550
  #
 -readme_directory =
+-
+-# shlib_directory: The location of the Postfix *.so library files and
+-# database plugins.
+-shlib_directory =
+-
+-# meta_directory: The location of non-executable files that are shared
+-# between multiple Postfix instances.
+-meta_directory = /etc/mail
+-
 -inet_protocols = ipv4
 +unknown_address_reject_code = 550
-diff -dur -x '*~' -x '*.orig' -x '*.rej' postfix-2.11.0.orig/src/global/mail_params.h postfix-2.11.0/src/global/mail_params.h
---- postfix-2.11.0.orig/src/global/mail_params.h	2014-03-05 17:54:24.730740039 +0100
-+++ postfix-2.11.0/src/global/mail_params.h	2014-03-05 17:54:54.260740308 +0100
-@@ -67,7 +67,7 @@
+--- postfix-3.11.5.orig/src/global/mail_params.h	2026-07-27 11:59:09.412311163 +0200
++++ postfix-3.11.5/src/global/mail_params.h	2026-07-27 11:59:49.280874790 +0200
+@@ -116,7 +116,7 @@ extern uid_t var_owner_uid;
  extern gid_t var_owner_gid;
  
  #define VAR_SGID_GROUP		"setgid_group"
@@ -133,15 +140,14 @@ diff -dur -x '*~' -x '*.orig' -x '*.rej' postfix-2.11.0.orig/src/global/mail_par
  extern char *var_sgid_group;
  extern gid_t var_sgid_gid;
  
-diff -dur -x '*~' -x '*.orig' -x '*.rej' postfix-2.11.0.orig/src/util/sys_defs.h postfix-2.11.0/src/util/sys_defs.h
---- postfix-2.11.0.orig/src/util/sys_defs.h	2014-03-05 17:54:24.944073374 +0100
-+++ postfix-2.11.0/src/util/sys_defs.h	2014-03-05 17:58:20.204075514 +0100
-@@ -769,7 +769,7 @@
+--- postfix-3.11.5.orig/src/util/sys_defs.h	2026-07-27 11:59:09.514459752 +0200
++++ postfix-3.11.5/src/util/sys_defs.h	2026-07-27 12:00:34.123215747 +0200
+@@ -777,7 +777,7 @@ extern int initgroups(const char *, int)
  #define HAS_FSYNC
  #define HAS_DB
  #define NATIVE_DB_TYPE	"hash"
--#define ALIAS_DB_MAP	DEF_DB_TYPE ":/etc/aliases"
-+#define ALIAS_DB_MAP	DEF_DB_TYPE ":/etc/mail/aliases"
+-#define ALIAS_DB_MAP	"$default_database_type:/etc/aliases"
++#define ALIAS_DB_MAP	"$default_database_type:/etc/mail/aliases"
  #ifndef NO_NIS
  #define HAS_NIS
  #endif
diff --git a/postfix-dictname.patch b/postfix-dictname.patch
index 77ff967..71555ae 100644
--- a/postfix-dictname.patch
+++ b/postfix-dictname.patch
@@ -1,20 +1,11 @@
---- postfix-3.6.6/src/global/dynamicmaps.c~	2022-04-25 11:26:46.269075376 +0000
-+++ postfix-3.6.6/src/global/dynamicmaps.c	2022-04-25 11:29:51.989068585 +0000
-@@ -182,7 +182,7 @@
- 			  "bulk-mode creation.", dict_type);
- 	}
- 	msg_fatal("unsupported dictionary type: %s. "
--		  "Is the postfix-%s package installed?",
-+		  "Is the postfix-dict-%s package installed?",
- 		  dict_type, dict_type);
+--- postfix-3.11.5.orig/src/global/dynamicmaps.c	2026-07-27 11:59:09.402204704 +0200
++++ postfix-3.11.5/src/global/dynamicmaps.c	2026-07-27 12:01:08.630019129 +0200
+@@ -149,7 +149,7 @@ static const DICT_OPEN_INFO *dymap_dict_
+      */
+     if ((dp = (DYMAP_INFO *) htable_find(dymap_info, dict_type)) == 0) {
+ 	msg_warn("unsupported dictionary type: %s. "
+-		 "Is the postfix-%s package installed?",
++		 "Is the postfix-dict-%s package installed?",
+ 		 dict_type, dict_type);
+ 	return (0);
      }
-     if (!dp->mkmap_name)
-@@ -190,7 +190,7 @@
- 		  "bulk-mode creation.", dict_type);
-     if (stat(dp->soname, &st) < 0)
- 	msg_fatal("unsupported dictionary type: %s (%s: %m). "
--		  "Is the postfix-%s package installed?",
-+		  "Is the postfix-dict-%s package installed?",
- 		  dict_type, dp->soname, dict_type);
-     if (st.st_uid != 0 || (st.st_mode & (S_IWGRP | S_IWOTH)) != 0)
- 	msg_fatal("unsupported dictionary type: %s "
diff --git a/postfix-egrep.patch b/postfix-egrep.patch
deleted file mode 100644
index d6818c8..0000000
--- a/postfix-egrep.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-diff -urN postfix-3.6.11.org/conf/postfix-script postfix-3.6.11/conf/postfix-script
---- postfix-3.6.11.org/conf/postfix-script	2019-02-02 17:17:50.000000000 +0100
-+++ postfix-3.6.11/conf/postfix-script	2023-09-05 10:22:52.909999216 +0200
-@@ -328,7 +328,7 @@
- 	# Check Postfix mail_owner-owned directory tree owner.
- 
- 	find `ls -d $queue_directory/* | \
--	    egrep '/(saved|incoming|active|defer|deferred|bounce|hold|trace|corrupt|public|private|flush)$'` \
-+	    grep -E '/(saved|incoming|active|defer|deferred|bounce|hold|trace|corrupt|public|private|flush)$'` \
- 	    ! \( -type p -o -type s \) ! -user $mail_owner \
- 		-exec $WARN not owned by $mail_owner: {} \;
- 
-diff -urN postfix-3.6.11.org/conf/postfix-tls-script postfix-3.6.11/conf/postfix-tls-script
---- postfix-3.6.11.org/conf/postfix-tls-script	2020-05-30 16:37:04.000000000 +0200
-+++ postfix-3.6.11/conf/postfix-tls-script	2023-09-05 10:22:41.113332549 +0200
-@@ -333,7 +333,7 @@
- }
- rsa=
- ecdsa=
--for _algo in `$postconf -T public-key-algorithms | egrep '^(rsa|ecdsa)$'`
-+for _algo in `$postconf -T public-key-algorithms | grep -E '^(rsa|ecdsa)$'`
- do
-     eval $_algo=$_algo
- done
-@@ -415,7 +415,7 @@
-     for cmd in ec rsa; do
- 	$openssl $cmd -passin "pass:umask 077" -in "$1" -pubout |
- 	$openssl $cmd -pubin -outform DER |
--	hex_sha256 | egrep -v "${null256}" && return 0
-+	hex_sha256 | grep -E -v "${null256}" && return 0
-     done 2>/dev/null
-     return 1
- }
-@@ -429,7 +429,7 @@
-     for cmd in ec rsa; do
- 	$openssl x509 -pubkey -noout -in "$1" |
- 	$openssl $cmd -pubin -outform DER |
--	hex_sha256 | egrep -v "${null256}" && return 0
-+	hex_sha256 | grep -E -v "${null256}" && return 0
-     done 2>/dev/null
-     return 1
- }
diff --git a/postfix-header_if_reject.patch b/postfix-header_if_reject.patch
deleted file mode 100644
index 49caee2..0000000
--- a/postfix-header_if_reject.patch
+++ /dev/null
@@ -1,189 +0,0 @@
---- src/smtpd/smtpd.h.org	Wed Feb  9 03:00:14 2005
-+++ src/smtpd/smtpd.h	Mon Feb  7 20:06:58 2005
-@@ -111,6 +111,7 @@
-     int     sender_rcptmap_checked;	/* sender validated against maps */
-     int     recipient_rcptmap_checked;	/* recipient validated against maps */
-     int     warn_if_reject;		/* force reject into warning */
-+    int     header_if_reject;		/* add header instead of rejecting */
-     SMTPD_DEFER defer_if_reject;	/* force reject into deferral */
-     SMTPD_DEFER defer_if_permit;	/* force permit into deferral */
-     int     defer_if_permit_client;	/* force permit into warning */
---- src/global/mail_params.h.org	Wed Feb  9 03:01:31 2005
-+++ src/global/mail_params.h	Wed Feb  9 02:01:01 2005
-@@ -1578,6 +1578,7 @@
- #define CHECK_RECIP_NS_ACL	"check_recipient_ns_access"
- 
- #define WARN_IF_REJECT		"warn_if_reject"
-+#define HEADER_IF_REJECT	"header_if_reject"
- 
- #define REJECT_RBL		"reject_rbl"	/* LaMont compatibility */
- #define REJECT_RBL_CLIENT	"reject_rbl_client"
---- src/smtpd/smtpd_check.c.org	Sat Dec 27 03:54:03 2003
-+++ src/smtpd/smtpd_check.c	Wed Feb  9 06:04:25 2005
-@@ -351,29 +351,29 @@
-   * permit-style restriction fails. Otherwise, we could reject legitimate
-   * mail.
-   */
--static void PRINTFLIKE(3, 4) defer_if(SMTPD_DEFER *, int, const char *,...);
-+static void PRINTFLIKE(4, 5) defer_if(SMTPD_STATE *, SMTPD_DEFER *, int, const char *,...);
- 
- #define DEFER_IF_REJECT2(state, class, fmt, a1, a2) \
--    defer_if(&(state)->defer_if_reject, (class), (fmt), (a1), (a2))
-+    defer_if((state), &(state)->defer_if_reject, (class), (fmt), (a1), (a2))
- #define DEFER_IF_REJECT3(state, class, fmt, a1, a2, a3) \
--    defer_if(&(state)->defer_if_reject, (class), (fmt), (a1), (a2), (a3))
-+    defer_if((state), &(state)->defer_if_reject, (class), (fmt), (a1), (a2), (a3))
- #define DEFER_IF_REJECT4(state, class, fmt, a1, a2, a3, a4) \
-     defer_if(&(state)->defer_if_reject, (class), (fmt), (a1), (a2), (a3), (a4))
- #define DEFER_IF_PERMIT2(state, class, fmt, a1, a2) do { \
-     if ((state)->warn_if_reject == 0) \
--	defer_if(&(state)->defer_if_permit, (class), (fmt), (a1), (a2)); \
-+	defer_if((state), &(state)->defer_if_permit, (class), (fmt), (a1), (a2)); \
-     else \
- 	(void) smtpd_check_reject((state), (class), (fmt), (a1), (a2)); \
-     } while (0)
- #define DEFER_IF_PERMIT3(state, class, fmt, a1, a2, a3) do { \
-     if ((state)->warn_if_reject == 0) \
--	defer_if(&(state)->defer_if_permit, (class), (fmt), (a1), (a2), (a3)); \
-+	defer_if((state), &(state)->defer_if_permit, (class), (fmt), (a1), (a2), (a3)); \
-     else \
- 	(void) smtpd_check_reject((state), (class), (fmt), (a1), (a2), (a3)); \
-     } while (0)
- #define DEFER_IF_PERMIT4(state, class, fmt, a1, a2, a3, a4) do { \
-     if ((state)->warn_if_reject == 0) \
--	defer_if(&(state)->defer_if_permit, (class), (fmt), (a1), (a2), (a3), (a4)); \
-+	defer_if((state), &(state)->defer_if_permit, (class), (fmt), (a1), (a2), (a3), (a4)); \
-     else \
- 	(void) smtpd_check_reject((state), (class), (fmt), (a1), (a2), (a3), (a4)); \
-     } while (0)
-@@ -712,7 +712,18 @@
- 			              char *format,...)
- {
-     va_list ap;
-+
-+    va_start(ap, format);
-+    vstring_vsprintf(error_text, format, ap);
-+    va_end(ap);
-+    
-+    return(xsmtpd_check_reject(state, error_class, error_text));
-+}
-+static int xsmtpd_check_reject(SMTPD_STATE *state, int error_class,
-+		VSTRING *error_text)
-+{
-     int     warn_if_reject;
-+    int     header_if_reject;
-     const char *whatsup;
- 
-     /*
-@@ -726,15 +737,18 @@
- 	warn_if_reject = 0;
- 	whatsup = "reject";
-     }
-+    if (state->header_if_reject && error_class != MAIL_ERROR_SOFTWARE) {
-+	    header_if_reject = 1;
-+	    whatsup = "header_warning";
-+    } else {
-+	    header_if_reject = 0;
-+    }
- 
-     /*
-      * Update the error class mask, and format the response. XXX What about
-      * multi-line responses? For now we cheat and send whitespace.
-      */
-     state->error_mask |= error_class;
--    va_start(ap, format);
--    vstring_vsprintf(error_text, format, ap);
--    va_end(ap);
- 
-     /*
-      * Ensure RFC compliance. We could do this inside smtpd_chat_reply() and
-@@ -796,15 +810,58 @@
-      */
-     log_whatsup(state, whatsup, STR(error_text));
- 
--    return (warn_if_reject ? 0 : SMTPD_CHECK_REJECT);
-+    if (state->header_if_reject) {
-+        VSTRING *hbuf = vstring_alloc(100);
-+	int elen = strlen(STR(error_text));
-+
-+        if (state->prepend == 0)
-+            state->prepend = argv_alloc(1);
-+        printable(STR(error_text), '?');
-+
-+#define PRETTY_HEADER
-+#ifdef PRETTY_HEADER
-+        if (elen > 65) {
-+	    int len = 0, n;
-+            char *p;
-+
-+            vstring_sprintf(hbuf, "%s", "X-Reject: ");
-+            while (len < elen-65 && (p = strchr(STR(error_text)+len+64, ' '))) {
-+		*p = '\t';
-+                n = p-(STR(error_text)+len);
-+    		vstring_sprintf_append(hbuf, "%.*s\n", n, STR(error_text)+len);
-+    		len+=n;
-+            }
-+    	    vstring_sprintf_append(hbuf, "%s", STR(error_text)+len);
-+        }
-+        else {
-+            vstring_sprintf(hbuf, "X-Reject: %s", STR(error_text));
-+        }
-+#else
-+        vstring_sprintf(hbuf, "X-Reject: %.*s", 999, STR(error_text));
-+#endif
-+        argv_add(state->prepend, STR(hbuf), ARGV_END);
-+        vstring_free(hbuf);
-+    }
-+
-+    return (warn_if_reject || header_if_reject ? 0 : SMTPD_CHECK_REJECT);    
- }
- 
- /* defer_if - prepare to change our mind */
- 
--static void defer_if(SMTPD_DEFER *defer, int error_class, const char *fmt,...)
-+static void defer_if(SMTPD_STATE *state, SMTPD_DEFER *defer, int error_class, const char *fmt,...)
- {
-     va_list ap;
- 
-+    if (state->header_if_reject) {
-+        va_start(ap, fmt);
-+        vstring_vsprintf(error_text, fmt, ap);
-+        va_end(ap);
-+        if (STR(error_text)[0] == '5') {
-+            xsmtpd_check_reject(state, error_class, error_text);
-+            return;
-+        }
-+    }
-+
-     /*
-      * Keep the first reason for this type of deferral, to minimize
-      * confusion.
-@@ -3147,6 +3204,11 @@
- 		state->warn_if_reject = state->recursion;
- 	    continue;
- 	}
-+	if (strcasecmp(name, HEADER_IF_REJECT) == 0) {
-+	    if (state->header_if_reject == 0)
-+		state->header_if_reject = state->recursion;
-+	    continue;
-+	}
- 
- 	/*
- 	 * Spoof the is_map_command() routine, so that we do not have to make
-@@ -3500,6 +3562,8 @@
- 
- 	if (state->warn_if_reject >= state->recursion)
- 	    state->warn_if_reject = 0;
-+	if (state->header_if_reject >= state->recursion)
-+		state->header_if_reject = 0;
- 
- 	if (status != 0)
- 	    break;
-@@ -3554,6 +3618,7 @@
- #define SMTPD_CHECK_RESET() { \
- 	state->recursion = 0; \
- 	state->warn_if_reject = 0; \
-+	state->header_if_reject = 0; \
- 	state->defer_if_reject.active = 0; \
-     }
- 
diff --git a/postfix-master.cf_cyrus.patch b/postfix-master.cf_cyrus.patch
index b974d8c..680b6c7 100644
--- a/postfix-master.cf_cyrus.patch
+++ b/postfix-master.cf_cyrus.patch
@@ -1,6 +1,6 @@
---- postfix-2.2.2/conf/master.cf.orig	2005-01-24 20:12:46.000000000 +0100
-+++ postfix-2.2.2/conf/master.cf	2005-04-26 11:46:51.000000000 +0200
-@@ -98,14 +98,14 @@ postlog   unix-dgram n  -       n
+--- postfix-3.11.5.orig/conf/master.cf	2026-07-27 11:59:09.224225573 +0200
++++ postfix-3.11.5/conf/master.cf	2026-07-27 12:00:54.785821712 +0200
+@@ -116,14 +116,14 @@ postlog   unix-dgram n  -       n
  # Also specify in main.cf: cyrus_destination_recipient_limit=1
  #
  #cyrus     unix  -       n       n       -       -       pipe
@@ -17,4 +17,3 @@
  #
  # ====================================================================
  #
-
diff --git a/postfix-scache_clnt.patch b/postfix-scache_clnt.patch
deleted file mode 100644
index 27532ea..0000000
--- a/postfix-scache_clnt.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- postfix-2.8.3/src/global/scache_clnt.c.orig	2011-05-17 14:24:55.245798704 +0200
-+++ postfix-2.8.3/src/global/scache_clnt.c	2011-05-17 14:24:26.382381790 +0200
-@@ -414,7 +414,7 @@
-     sp->scache->size = scache_clnt_size;
-     sp->scache->free = scache_clnt_free;
- 
--    service = concatenate("local:" MAIL_CLASS_PRIVATE "/", server, (char *) 0);
-+    service = concatenate("local:" MAIL_CLASS_PRIVATE "/", var_scache_service, (char *) 0);
-     sp->auto_clnt = auto_clnt_create(service, timeout, idle_limit, ttl_limit);
-     auto_clnt_control(sp->auto_clnt,
- 		      AUTO_CLNT_CTL_HANDSHAKE, scache_clnt_handshake,
diff --git a/postfix-vda-bigquota.patch b/postfix-vda-bigquota.patch
deleted file mode 100644
index 6476645..0000000
--- a/postfix-vda-bigquota.patch
+++ /dev/null
@@ -1,204 +0,0 @@
-diff -ur postfix-2.7.0/src/virtual/maildir.c postfix-2.7.0-bg/src/virtual/maildir.c
---- postfix-2.7.0/src/virtual/maildir.c	2010-04-15 16:46:03.766130197 +0200
-+++ postfix-2.7.0-bg/src/virtual/maildir.c	2010-04-15 16:55:02.496126981 +0200
-@@ -65,6 +65,7 @@
- 
- /* Patch library. */
- 
-+#include <stdint.h>
- #include <sys/types.h> /* opendir(3), stat(2) */
- #include <sys/stat.h>  /* stat(2) */
- #include <dirent.h>    /* opendir(3) */
-@@ -98,14 +99,14 @@
-  * Returns the size of all mails as read from maildirsize,
-  * zero if it couldn't read the file.
-  */
--static long read_maildirsize(char *filename, long *sumptr, long *countptr)
-+static long read_maildirsize(char *filename, int64_t *sumptr, int64_t *countptr)
- {
-     char *myname = "read_maildirsize";
-     struct stat statbuf;
-     VSTREAM *sizefile;
-     char *p;
-     int len, first;
--    long sum = 0, count = 0, ret_value = -1;
-+    int64_t sum = 0, count = 0, ret_value = -1;
- 
-     if (msg_verbose) 
- 	msg_info("%s: we will use sizefile = '%s'", myname, filename);
-@@ -136,7 +137,7 @@
-     first = 1;
- 
-     while (*p) {
--        long n = 0, c = 0;
-+        int64_t n = 0, c = 0;
-         char *q = p;
- 
-         while (*p) {
-@@ -151,7 +152,7 @@
-             continue;
-         }
- 
--        if (sscanf(q, "%ld %ld", &n, &c) == 2) {
-+        if (sscanf(q, "%lld %lld", &n, &c) == 2) {
-             sum += n;
-             count += c;
-             /* if (msg_verbose)
-@@ -179,7 +180,7 @@
- 	ret_value = -1;
-     } else {
- 	if (msg_verbose) 
--	    msg_info("%s: we will return Maildir size = %ld, count = %ld", myname, *sumptr, *countptr);
-+	    msg_info("%s: we will return Maildir size = %lld, count = %lld", myname, *sumptr, *countptr);
- 
- 	ret_value = sum;	
-     }
-@@ -200,7 +201,7 @@
-  * Returns the size given in ",S=<size>" in the filename,
-  * zero if it cannot find ",S=<size>" in the filename.
-  */
--static long maildir_parsequota(const char *n)
-+static int64_t maildir_parsequota(const char *n)
- {
-     const char *o;
-     int yes = 0;
-@@ -225,7 +226,7 @@
-     }
- 
-     if (yes) {
--        long s = 0;
-+        int64_t s = 0;
- 
-         while (*o >= '0' && *o <= '9')
-             s = s*10 + (*o++ - '0');
-@@ -252,11 +253,11 @@
-  * Returns the sum of the sizes of all measurable files,
-  * zero if the directory could not be opened.
-  */
--static long check_dir_size(char *dirname, long *countptr)
-+static int64_t check_dir_size(char *dirname, int64_t *countptr)
- {
-     char *myname = "check_dir_size";
-     DIR *dir;
--    long sum = 0;
-+    int64_t sum = 0;
-     struct dirent *ent;
-     struct stat statbuf;
- 
-@@ -277,7 +278,7 @@
- 
-     while ((ent = readdir(dir)) != NULL) {
-         char *name = ent->d_name;
--        long tmpsum = 0;
-+        int64_t tmpsum = 0;
-         VSTRING *buffer;
- 
- 	/* do not count dot a double-dot dirs */
-@@ -324,7 +325,7 @@
-             }
-             if ((statbuf.st_mode & S_IFREG) != 0) {
-                 if (strcmp(dirname + strlen(dirname) - 3, "new") == 0 || strcmp(dirname + strlen(dirname) - 3, "cur") == 0 || strcmp(dirname + strlen(dirname) - 3, "tmp") == 0) {
--                    sum += (long) statbuf.st_size;
-+                    sum += (int64_t) statbuf.st_size;
-                     (*countptr)++;
-                 }
-             }
-@@ -338,7 +339,7 @@
-     closedir(dir);
- 
-     if (msg_verbose)
--        msg_info("%s: full scan done: dir=%s sum=%ld count=%ld", myname, dirname, sum, *countptr);
-+        msg_info("%s: full scan done: dir=%s sum=%lld count=%lld", myname, dirname, sum, *countptr);
- 
-     return sum;
- }
-@@ -456,9 +457,9 @@
-     char    *sizefilename = (char *) 0; /* Maildirsize file name. */
-     VSTRING *filequota;                 /* Quota setting from the maildirsize file. */
-     VSTREAM *sizefile;                  /* Maildirsize file handle. */
--    long     n = 0;                     /* Limit in long integer format. */
--    long     saved_count = 0;           /* The total number of files. */
--    long     saved_size = 0;            /* The total quota of all files. */
-+    int64_t  n = 0;                     /* Limit in long integer format. */
-+    int64_t  saved_count = 0;           /* The total number of files. */
-+    int64_t  saved_size = 0;            /* The total quota of all files. */
-     struct   stat mail_stat;            /* To check the size of the mail to be written. */
-     struct   stat sizefile_stat;        /* To check the size of the maildirsize file. */
-     time_t   tm;                        /* To check the age of the maildirsize file. */
-@@ -541,7 +542,7 @@
-      * warn the user, else use the value directly as the maildir limit.
-      */
-     if (*var_virt_mailbox_limit_maps != 0 && (limit_res = mail_addr_find(virtual_mailbox_limit_maps, state.msg_attr.user, (char **) NULL)) != 0) {
--        n = atol(limit_res);
-+        n = strtoll(limit_res, NULL, 10);
-         if (n > 0) {
-             if ((n < var_message_limit) && (!var_virt_mailbox_limit_override)) {
-                 n = var_virt_mailbox_limit;
-@@ -552,13 +553,13 @@
-             }
-             else {
-                 if (msg_verbose)
--                    msg_info("%s: set virtual maildir limit size for %s to %ld",
-+                    msg_info("%s: set virtual maildir limit size for %s to %lld",
-                             myname, usr_attr.mailbox, n);
-             }
-         }
-         else if (n == 0) {
-                 if (msg_verbose)
--                    msg_info("%s: set virtual maildir limit size for %s to %ld",
-+                    msg_info("%s: set virtual maildir limit size for %s to %lld",
-                             myname, usr_attr.mailbox, n);
-         }
-         else {
-@@ -580,7 +581,7 @@
- 	x >= 0 = reading successfully finished - sum si returned, so sum size of Maildir was 0 or more */
-         if (!var_virt_mailbox_limit_inbox && var_virt_maildir_extended && read_maildirsize(sizefilename, &saved_size, &saved_count) >= 0) {
-     	    if (msg_verbose)
--        	msg_info("%s: maildirsize used=%s sum=%ld count=%ld", myname, sizefilename, saved_size, saved_count);
-+        	msg_info("%s: maildirsize used=%s sum=%lld count=%lld", myname, sizefilename, saved_size, saved_count);
- 	} else {
- 	    if (msg_verbose) 
- 		msg_info("%s: var_virt_mailbox_limit == 1 OR var_virt_maildir_extended == 0 OR read_maildidrsize() returned value x < 0 as saying something failed", myname);
-@@ -693,7 +694,7 @@
-              */
-             if (stat(tmpfile, &mail_stat) == 0) {
-                 if (n != 0) {
--                    saved_size += (long) mail_stat.st_size;
-+                    saved_size += (int64_t) mail_stat.st_size;
-                     saved_count++;
-                 }
-                 if (var_virt_maildir_extended) {
-@@ -710,7 +711,7 @@
-              */
-             if (saved_size > n) {
-                 mail_copy_status = MAIL_COPY_STAT_WRITE;
--                if (((long) mail_stat.st_size > n) || (var_virt_overquota_bounce))
-+                if (((int64_t) mail_stat.st_size > n) || (var_virt_overquota_bounce))
-                     errno = EFBIG;
-                 else
-                     errno = EDQUOT;
-@@ -889,7 +890,7 @@
-                             filequota = vstring_alloc(128);
-                             vstring_get_null_bound(filequota, sizefile, 127);
-                             vstream_fclose(sizefile);
--                            if (atol(vstring_export(filequota)) != n)
-+                            if (strtoll(vstring_export(filequota), NULL, 10) != n)
-                                 unlink(sizefilename);
-                         }
- 
-@@ -909,13 +910,13 @@
- 
-                             /* If the creation worked, write to the file, otherwise just give up. */
-                             if (sizefile) {
--                                vstream_fprintf(sizefile, "%ldS\n%ld %ld\n", n, saved_size, saved_count);
-+                                vstream_fprintf(sizefile, "%lldS\n%lld %lld\n", n, saved_size, saved_count);
-                                 vstream_fclose(sizefile);
-                             }
-                         }
-                         else {
-                             /* We opened maildirsize, so let's just append this transaction and close it. */
--                            vstream_fprintf(sizefile, "%ld 1\n", (long) mail_stat.st_size);
-+                            vstream_fprintf(sizefile, "%lld 1\n", (int64_t) mail_stat.st_size);
-                             vstream_fclose(sizefile);
-                         }
- 
diff --git a/postfix-vda.patch b/postfix-vda.patch
deleted file mode 100644
index b6e6bd8..0000000
--- a/postfix-vda.patch
+++ /dev/null
@@ -1,1376 +0,0 @@
-diff -ruNp postfix-2.11.10.orig/README_FILES/VDA_README postfix-2.11.10/README_FILES/VDA_README
---- postfix-2.11.10.orig/README_FILES/VDA_README	1970-01-01 01:00:00.000000000 +0100
-+++ postfix-2.11.10/README_FILES/VDA_README	2017-07-02 00:13:25.773285426 +0200
-@@ -0,0 +1,10 @@
-+Postfix VDA patch for maildir++ quota support by 
-+    Anderson Nadal <andernadal at gmail.com>
-+    Tomas Macek <maca02 at atlas.cz>
-+    Lucca Longinotti
-+
-+See VDA patch official website http://vda.sf.net for instructions
-+howto patch the Postfix's sourcetree and configure the options 
-+provided by this patch.
-+
-+
-diff -ruNp postfix-2.11.10.orig/src/global/mail_params.h postfix-2.11.10/src/global/mail_params.h
---- postfix-2.11.10.orig/src/global/mail_params.h	2015-07-20 00:39:31.000000000 +0200
-+++ postfix-2.11.10/src/global/mail_params.h	2017-07-02 00:13:25.775285421 +0200
-@@ -2413,6 +2413,54 @@ extern char *var_virt_uid_maps;
- #define DEF_VIRT_GID_MAPS		""
- extern char *var_virt_gid_maps;
- 
-+#define VAR_VIRT_MAILBOX_LIMIT_MAPS     "virtual_mailbox_limit_maps"
-+#define DEF_VIRT_MAILBOX_LIMIT_MAPS     ""
-+extern char *var_virt_mailbox_limit_maps;
-+
-+#define VAR_VIRT_MAILBOX_LIMIT_INBOX    "virtual_mailbox_limit_inbox"
-+#define DEF_VIRT_MAILBOX_LIMIT_INBOX    0
-+extern bool var_virt_mailbox_limit_inbox;
-+
-+#define VAR_VIRT_MAILBOX_LIMIT_OVERRIDE "virtual_mailbox_limit_override"
-+#define DEF_VIRT_MAILBOX_LIMIT_OVERRIDE 0
-+extern bool var_virt_mailbox_limit_override;
-+
-+#define VAR_VIRT_MAILDIR_EXTENDED       "virtual_maildir_extended"
-+#define DEF_VIRT_MAILDIR_EXTENDED       0
-+extern bool var_virt_maildir_extended;
-+
-+#define VAR_VIRT_OVERQUOTA_BOUNCE       "virtual_overquota_bounce"
-+#define DEF_VIRT_OVERQUOTA_BOUNCE       0
-+extern bool var_virt_overquota_bounce;
-+
-+#define VAR_VIRT_MAILDIR_LIMIT_MESSAGE  "virtual_maildir_limit_message"
-+#define DEF_VIRT_MAILDIR_LIMIT_MESSAGE  "Sorry, the user's maildir has overdrawn his diskspace quota, please try again later."
-+extern char *var_virt_maildir_limit_message;
-+
-+#define VAR_VIRT_MAILDIR_LIMIT_MESSAGE_MAPS "virtual_maildir_limit_message_maps"
-+#define DEF_VIRT_MAILDIR_LIMIT_MESSAGE_MAPS ""
-+extern char *var_virt_maildir_limit_message_maps;
-+
-+#define VAR_VIRT_MAILDIR_SUFFIX         "virtual_maildir_suffix"
-+#define DEF_VIRT_MAILDIR_SUFFIX         ""
-+extern char *var_virt_maildir_suffix;
-+
-+#define VAR_VIRT_TRASH_COUNT            "virtual_trash_count"
-+#define DEF_VIRT_TRASH_COUNT            0
-+extern bool var_virt_trash_count;
-+
-+#define VAR_VIRT_TRASH_NAME             "virtual_trash_name"
-+#define DEF_VIRT_TRASH_NAME             ".Trash"
-+extern char *var_virt_trash_name;
-+
-+#define VAR_VIRT_MAILDIR_FILTER         "virtual_maildir_filter"
-+#define DEF_VIRT_MAILDIR_FILTER         0
-+extern bool var_virt_maildir_filter;
-+
-+#define VAR_VIRT_MAILDIR_FILTER_MAPS    "virtual_maildir_filter_maps"
-+#define DEF_VIRT_MAILDIR_FILTER_MAPS    ""
-+extern char *var_virt_maildir_filter_maps;
-+
- #define VAR_VIRT_MINUID			"virtual_minimum_uid"
- #define DEF_VIRT_MINUID			100
- extern int var_virt_minimum_uid;
-diff -ruNp postfix-2.11.10.orig/src/util/file_limit.c postfix-2.11.10/src/util/file_limit.c
---- postfix-2.11.10.orig/src/util/file_limit.c	2003-10-22 20:48:36.000000000 +0200
-+++ postfix-2.11.10/src/util/file_limit.c	2017-07-02 00:13:25.775285421 +0200
-@@ -85,7 +85,11 @@ void    set_file_limit(off_t limit)
- #else
-     struct rlimit rlim;
- 
--    rlim.rlim_cur = rlim.rlim_max = limit;
-+    /* rlim_max can only be changed by root. */
-+    if (getrlimit(RLIMIT_FSIZE, &rlim) < 0)
-+        msg_fatal("getrlimit: %m");
-+    rlim.rlim_cur = limit;
-+
-     if (setrlimit(RLIMIT_FSIZE, &rlim) < 0)
- 	msg_fatal("setrlimit: %m");
- #ifdef SIGXFSZ
-diff -ruNp postfix-2.11.10.orig/src/virtual/mailbox.c postfix-2.11.10/src/virtual/mailbox.c
---- postfix-2.11.10.orig/src/virtual/mailbox.c	2016-08-22 23:24:31.000000000 +0200
-+++ postfix-2.11.10/src/virtual/mailbox.c	2017-07-02 00:13:25.776285418 +0200
-@@ -52,6 +52,7 @@
- #include <mymalloc.h>
- #include <stringops.h>
- #include <set_eugid.h>
-+#include <iostuff.h>
- 
- /* Global library. */
- 
-@@ -70,6 +71,70 @@
- #define YES	1
- #define NO	0
- 
-+/* change_mailbox_limit - change limit for mailbox file */
-+static int change_mailbox_limit(LOCAL_STATE state, USER_ATTR usr_attr)
-+{
-+    char *myname = "change_mailbox_limit";
-+    const char *limit_res;
-+    long n = 0;
-+    int status = NO;
-+
-+    /*
-+     * Look up the virtual mailbox limit size for this user.
-+     * Fall back to virtual_mailbox_limit in case lookup failed.
-+     * If virtual mailbox limit size is negative, fall back to virtual_mailbox_limit.
-+     * If it's 0, set the mailbox limit to 0, which means unlimited.
-+     * If it's more than 0 (positive int), check if the value is smaller than the maximum message size,
-+     * if it is and the virtual mailbox limit can't be overridden, fall back to virtual_mailbox_limit and
-+     * warn the user, else use the value directly as the mailbox limit.
-+     */
-+    if (*var_virt_mailbox_limit_maps != 0 && (limit_res = mail_addr_find(virtual_mailbox_limit_maps, state.msg_attr.user, (char **) NULL)) != 0) {
-+        n = atol(limit_res);
-+        if (n > 0) {
-+            if ((n < var_message_limit) && (!var_virt_mailbox_limit_override)) {
-+                set_file_limit(var_virt_mailbox_limit);
-+                status = NO;
-+
-+                msg_warn("%s: recipient %s - virtual mailbox limit is "
-+                        "smaller than %s in %s - falling back to %s",
-+                        myname,
-+                        state.msg_attr.user,
-+                        VAR_MESSAGE_LIMIT,
-+                        virtual_mailbox_limit_maps->title,
-+                        VAR_VIRT_MAILBOX_LIMIT);
-+            }
-+            else {
-+                set_file_limit((off_t) n);
-+                status = YES;
-+
-+                if (msg_verbose)
-+                    msg_info("%s: set virtual mailbox limit size for %s to %ld",
-+                            myname, usr_attr.mailbox, n);
-+            }
-+        }
-+        else if (n == 0) {
-+                set_file_limit(OFF_T_MAX);
-+                status = YES;
-+
-+                if (msg_verbose)
-+                    msg_info("%s: set virtual mailbox limit size for %s to %ld",
-+                            myname, usr_attr.mailbox, OFF_T_MAX);
-+        }
-+        else {
-+            /* Invalid limit size (negative). Use default virtual_mailbox_limit. */
-+            set_file_limit(var_virt_mailbox_limit);
-+            status = NO;
-+        }
-+    }
-+    else {
-+        /* There is no limit in the maps. Use default virtual_mailbox_limit. */
-+        set_file_limit(var_virt_mailbox_limit);
-+        status = NO;
-+    }
-+
-+    return(status);
-+}
-+
- /* deliver_mailbox_file - deliver to recipient mailbox */
- 
- static int deliver_mailbox_file(LOCAL_STATE state, USER_ATTR usr_attr)
-@@ -214,62 +279,72 @@ int     deliver_mailbox(LOCAL_STATE stat
-      * Look up the mailbox owner rights. Defer in case of trouble.
-      */
-     uid_res = mail_addr_find(virtual_uid_maps, state.msg_attr.user,
--			     IGNORE_EXTENSION);
--    if (uid_res == 0) {
--	msg_warn("recipient %s: not found in %s",
--		 state.msg_attr.user, virtual_uid_maps->title);
--	dsb_simple(why, "4.3.5", "mail system configuration error");
--	*statusp = defer_append(BOUNCE_FLAGS(state.request),
--				BOUNCE_ATTR(state.msg_attr));
--	RETURN(YES);
-+                            IGNORE_EXTENSION);
-+
-+    if ((uid_res = mail_addr_find(virtual_uid_maps, state.msg_attr.user, (char **) 0)) == 0) {
-+        if ((uid_res = maps_find(virtual_uid_maps, strchr(state.msg_attr.user, '@'), DICT_FLAG_FIXED)) == 0) {
-+			msg_warn("recipient %s: not found in %s", state.msg_attr.user, virtual_uid_maps->title);
-+			dsb_simple(why, "4.3.5", "mail system configuration error");
-+			*statusp = defer_append(BOUNCE_FLAGS(state.request), BOUNCE_ATTR(state.msg_attr));
-+			RETURN(YES);
-+        }
-     }
-+
-     if ((n = atol(uid_res)) < var_virt_minimum_uid) {
--	msg_warn("recipient %s: bad uid %s in %s",
--		 state.msg_attr.user, uid_res, virtual_uid_maps->title);
--	dsb_simple(why, "4.3.5", "mail system configuration error");
--	*statusp = defer_append(BOUNCE_FLAGS(state.request),
--				BOUNCE_ATTR(state.msg_attr));
--	RETURN(YES);
-+		msg_warn("recipient %s: bad uid %s in %s", state.msg_attr.user, uid_res, virtual_uid_maps->title);
-+		dsb_simple(why, "4.3.5", "mail system configuration error");
-+		*statusp = defer_append(BOUNCE_FLAGS(state.request), BOUNCE_ATTR(state.msg_attr));
-+		RETURN(YES);
-     }
-+
-     usr_attr.uid = (uid_t) n;
- 
-     /*
-      * Look up the mailbox group rights. Defer in case of trouble.
-      */
-     gid_res = mail_addr_find(virtual_gid_maps, state.msg_attr.user,
--			     IGNORE_EXTENSION);
--    if (gid_res == 0) {
--	msg_warn("recipient %s: not found in %s",
--		 state.msg_attr.user, virtual_gid_maps->title);
--	dsb_simple(why, "4.3.5", "mail system configuration error");
--	*statusp = defer_append(BOUNCE_FLAGS(state.request),
--				BOUNCE_ATTR(state.msg_attr));
--	RETURN(YES);
-+                            IGNORE_EXTENSION);
-+
-+    if ((gid_res = mail_addr_find(virtual_gid_maps, state.msg_attr.user, (char **) 0)) == 0) {
-+        if ((gid_res = maps_find(virtual_gid_maps, strchr(state.msg_attr.user, '@'), DICT_FLAG_FIXED)) == 0) {
-+			msg_warn("recipient %s: not found in %s", state.msg_attr.user, virtual_gid_maps->title);
-+			dsb_simple(why, "4.3.5", "mail system configuration error");
-+			*statusp = defer_append(BOUNCE_FLAGS(state.request), BOUNCE_ATTR(state.msg_attr));
-+			RETURN(YES);
-+        }
-     }
-+
-     if ((n = atol(gid_res)) <= 0) {
--	msg_warn("recipient %s: bad gid %s in %s",
--		 state.msg_attr.user, gid_res, virtual_gid_maps->title);
--	dsb_simple(why, "4.3.5", "mail system configuration error");
--	*statusp = defer_append(BOUNCE_FLAGS(state.request),
--				BOUNCE_ATTR(state.msg_attr));
--	RETURN(YES);
-+		msg_warn("recipient %s: bad gid %s in %s", state.msg_attr.user, gid_res, virtual_gid_maps->title);
-+		dsb_simple(why, "4.3.5", "mail system configuration error");
-+		*statusp = defer_append(BOUNCE_FLAGS(state.request), BOUNCE_ATTR(state.msg_attr));
-+		RETURN(YES);
-     }
-+
-     usr_attr.gid = (gid_t) n;
- 
-     if (msg_verbose)
--	msg_info("%s[%d]: set user_attr: %s, uid = %u, gid = %u",
--		 myname, state.level, usr_attr.mailbox,
--		 (unsigned) usr_attr.uid, (unsigned) usr_attr.gid);
-+        msg_info("%s[%d]: set user_attr: %s, uid = %u, gid = %u",
-+                myname, state.level, usr_attr.mailbox,
-+                (unsigned) usr_attr.uid, (unsigned) usr_attr.gid);
- 
-     /*
-      * Deliver to mailbox or to maildir.
-      */
- #define LAST_CHAR(s) (s[strlen(s) - 1])
- 
--    if (LAST_CHAR(usr_attr.mailbox) == '/')
--	*statusp = deliver_maildir(state, usr_attr);
--    else
--	*statusp = deliver_mailbox_file(state, usr_attr);
-+    if (LAST_CHAR(usr_attr.mailbox) == '/') {
-+        *statusp = deliver_maildir(state, usr_attr);
-+    }
-+    else {
-+        int changed_limit;
-+
-+        changed_limit = change_mailbox_limit(state, usr_attr);
-+        *statusp = deliver_mailbox_file(state, usr_attr);
-+
-+        if (changed_limit)
-+            set_file_limit(var_virt_mailbox_limit);
-+    }
- 
-     /*
-      * Cleanup.
-diff -ruNp postfix-2.11.10.orig/src/virtual/maildir.c postfix-2.11.10/src/virtual/maildir.c
---- postfix-2.11.10.orig/src/virtual/maildir.c	2012-01-25 01:41:08.000000000 +0100
-+++ postfix-2.11.10/src/virtual/maildir.c	2017-07-02 00:13:25.779285410 +0200
-@@ -64,28 +64,420 @@
- #include <mbox_open.h>
- #include <dsn_util.h>
- 
-+/* Patch library. */
-+
-+#include <sys/types.h> /* opendir(3), stat(2) */
-+#include <sys/stat.h>  /* stat(2) */
-+#include <dirent.h>    /* opendir(3) */
-+#include <unistd.h>    /* stat(2) */
-+#include <stdlib.h>    /* atol(3) */
-+#include <string.h>    /* strrchr(3) */
-+#include <vstring_vstream.h>
-+#include <dict.h>
-+#include <dict_regexp.h>
-+#include <ctype.h>
-+#include <stdio.h>
-+#include <sys_defs.h>
-+#include <mail_addr_find.h>
-+
- /* Application-specific. */
- 
- #include "virtual.h"
- 
--/* deliver_maildir - delivery to maildir-style mailbox */
-+/* Maildirsize maximal size. */
-+
-+#define SIZEFILE_MAX 5120
-+
-+/*
-+ * Chris Stratford <chriss at pipex.net>
-+ * Read the maildirsize file to get quota info.
-+ *
-+ * Arguments:
-+ *  dirname: the maildir
-+ *  countptr: number of messages
-+ *
-+ * Returns the size of all mails as read from maildirsize,
-+ * zero if it couldn't read the file.
-+ */
-+static long read_maildirsize(char *filename, long *sumptr, long *countptr)
-+{
-+    char *myname = "read_maildirsize";
-+    struct stat statbuf;
-+    VSTREAM *sizefile;
-+    char *p;
-+    int len, first;
-+    long sum = 0, count = 0, ret_value = -1;
-+
-+    if (msg_verbose) 
-+	msg_info("%s: we will use sizefile = '%s'", myname, filename);
-+	
-+    sizefile = vstream_fopen(filename, O_RDONLY, 0);
-+    if (!sizefile) {
-+	if (msg_verbose)
-+	    msg_info("%s: cannot open %s: %m (maybe file does not exist)", myname, filename);
-+	    
-+	return -1;
-+    } else if (stat(filename, &statbuf) < 0 || statbuf.st_size > SIZEFILE_MAX) {
-+        if (sizefile) {
-+            vstream_fclose(sizefile);
-+            unlink(filename);
-+        }
-+        
-+        if (msg_verbose) 
-+	    msg_info("%s: stat() returned < 0 or filesize > SIZEFILE_MAX (filename = %s, filesize = %ld)", myname, filename, statbuf.st_size);
-+        
-+        return -1;
-+    }
-+    
-+    VSTRING *sizebuf = vstring_alloc(SIZEFILE_MAX);
-+    len = vstream_fread(sizefile, STR(sizebuf), SIZEFILE_MAX);
-+
-+    p = STR(sizebuf);
-+    *(p + len) = '\0';
-+    first = 1;
-+
-+    while (*p) {
-+        long n = 0, c = 0;
-+        char *q = p;
-+
-+        while (*p) {
-+            if (*p++ == '\n') {
-+                p[-1] = 0;
-+                break;
-+            }
-+        }
-+
-+        if (first) {
-+            first = 0;
-+            continue;
-+        }
-+
-+        if (sscanf(q, "%ld %ld", &n, &c) == 2) {
-+            sum += n;
-+            count += c;
-+            /* if (msg_verbose)
-+    		msg_info("%s: we read line '%s', totals: sum = %ld, count = %ld", myname, q, sum, count); */
-+        }
-+        else {
-+            vstream_fclose(sizefile);
-+            unlink(filename);
-+            msg_warn("%s: invalid line '%s' found in %s, removing maildirsize file", myname, q, filename);
-+            vstring_free(sizebuf);
-+
-+            return -1;
-+        }
-+    }
-+
-+    *countptr = count;
-+    *sumptr = sum;
-+        
-+    if (sum < 0 || count < 0 || (sum == 0 && count != 0) || (sum != 0 && count == 0)) {
-+	if (msg_verbose) {
-+	    msg_info("%s: we will return -1 and unlink %s, because file count or sum is <= 0 (sum = %ld, count = %ld)", myname, filename, sum, count);
-+	}
-+	
-+	unlink(filename);
-+	ret_value = -1;
-+    } else {
-+	if (msg_verbose) 
-+	    msg_info("%s: we will return Maildir size = %ld, count = %ld", myname, *sumptr, *countptr);
-+
-+	ret_value = sum;	
-+    }
-+
-+    vstream_fclose(sizefile);
-+    vstring_free(sizebuf);
-+    
-+    return ret_value;
-+}
-+
-+/*
-+ * Gives the size of the file according to the Maildir++ extension
-+ * present in the filename (code taken from courier-imap).
-+ *
-+ * Arguments:
-+ *  n: filename
-+ *
-+ * Returns the size given in ",S=<size>" in the filename,
-+ * zero if it cannot find ",S=<size>" in the filename.
-+ */
-+static long maildir_parsequota(const char *n)
-+{
-+    const char *o;
-+    int yes = 0;
-+
-+    if ((o = strrchr(n, '/')) == 0)
-+        o = n;
-+
-+    for (; *o; o++) {
-+        if (*o == ':')
-+            break;
-+    }
-+
-+    for (; o >= n; --o) {
-+        if (*o == '/')
-+            break;
-+
-+        if (*o == ',' && o[1] == 'S' && o[2] == '=') {
-+            yes = 1;
-+            o += 3;
-+            break;
-+        }
-+    }
-+
-+    if (yes) {
-+        long s = 0;
-+
-+        while (*o >= '0' && *o <= '9')
-+            s = s*10 + (*o++ - '0');
-+
-+        return s;
-+    }
-+
-+    return 0;
-+}
-+
-+/*
-+ * Computes quota usage for a directory (taken from exim).
-+ *
-+ * This function is called to determine the exact quota usage of a virtual
-+ * maildir box. To achieve maximum possible speed while doing this, it takes
-+ * advantage of the maildirsize file and the Maildir++ extensions to filenames,
-+ * when applicable and configured to be used. In all other cases it simply
-+ * stats all the files as needed to get the size information.
-+ *
-+ * Arguments:
-+ *  dirname: the name of the directory
-+ *  countptr: where to add the file count (because this function recurses)
-+ *
-+ * Returns the sum of the sizes of all measurable files,
-+ * zero if the directory could not be opened.
-+ */
-+static long check_dir_size(char *dirname, long *countptr)
-+{
-+    char *myname = "check_dir_size";
-+    DIR *dir;
-+    long sum = 0;
-+    struct dirent *ent;
-+    struct stat statbuf;
-+
-+    dir = opendir(dirname);
-+    if (dir == NULL) {
-+        if (make_dirs(dirname, 0700) == 0) {    /* Try to create the dirs. */
-+            dir = opendir(dirname);             /* Reopen the dir. */
-+            if (dir == NULL) {
-+                msg_warn("%s: cannot reopen directory: %s", myname, dirname);
-+                return 0;
-+            }
-+        }
-+        else {
-+            msg_warn("%s: cannot open directory: %s", myname, dirname);
-+            return 0;
-+        }
-+    }
-+
-+    while ((ent = readdir(dir)) != NULL) {
-+        char *name = ent->d_name;
-+        long tmpsum = 0;
-+        VSTRING *buffer;
-+
-+	/* do not count dot a double-dot dirs */
-+        if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
-+            continue;
-+        /* do not count if this is the trash subdir and if we should NOT count it */
-+	else if (var_virt_trash_count == 0 && strcmp(name, var_virt_trash_name) == 0)
-+    	    continue;
-+
-+        /*
-+         * Here comes the real logic behind this function.
-+         * Optimized to be the most efficient possible,
-+         * depending on the settings given.
-+         * See above for a more detailed description.
-+         */
-+        if (var_virt_mailbox_limit_inbox) {
-+            if (var_virt_maildir_extended && (tmpsum = maildir_parsequota(name))) {
-+                sum += tmpsum;
-+                (*countptr)++;
-+            }
-+            else {
-+                buffer = vstring_alloc(1024);
-+                vstring_sprintf(buffer, "%s/%s", dirname, name);
-+
-+                if (stat(STR(buffer), &statbuf) < 0) {
-+                    vstring_free(buffer);
-+                    continue;
-+                }
-+                if ((statbuf.st_mode & S_IFREG) != 0) {
-+                    sum += (long) statbuf.st_size;
-+                    (*countptr)++;
-+                }
-+
-+                vstring_free(buffer);
-+            }
-+        }
-+        else {
-+            buffer = vstring_alloc(1024);
-+            vstring_sprintf(buffer, "%s/%s", dirname, name);
-+
-+            if (stat(STR(buffer), &statbuf) < 0) {
-+                vstring_free(buffer);
-+                continue;
-+            }
-+            if ((statbuf.st_mode & S_IFREG) != 0) {
-+                if (strcmp(dirname + strlen(dirname) - 3, "new") == 0 || strcmp(dirname + strlen(dirname) - 3, "cur") == 0 || strcmp(dirname + strlen(dirname) - 3, "tmp") == 0) {
-+                    sum += (long) statbuf.st_size;
-+                    (*countptr)++;
-+                }
-+            }
-+            else if ((statbuf.st_mode & S_IFDIR) != 0) {
-+                sum += check_dir_size(STR(buffer), countptr);
-+            }
-+
-+            vstring_free(buffer);
-+        }
-+    }
-+    closedir(dir);
- 
--int     deliver_maildir(LOCAL_STATE state, USER_ATTR usr_attr)
-+    if (msg_verbose)
-+        msg_info("%s: full scan done: dir=%s sum=%ld count=%ld", myname, dirname, sum, *countptr);
-+
-+    return sum;
-+}
-+
-+/* Cut all occurrences of pattern from string. */
-+static char *strcut(char *str, const char *pat)
-+{
-+    char *ptr, *loc, *ret;
-+    ret = str;
-+    loc = str;
-+
-+    /* No match, return original string. */
-+    if (!strstr(loc, pat))
-+        return(str);
-+
-+    while (*loc && (ptr = strstr(loc, pat))) {
-+        while (loc < ptr)
-+            *str++ = *loc++;
-+        loc += strlen(pat);
-+    }
-+
-+    while (*loc)
-+        *str++ = *loc++;
-+
-+    *str = 0;
-+
-+    return(ret);
-+}
-+
-+/* Check if maildirfilter file is up-to-date compared to SQL, (re)write it if not. */
-+static long sql2file(char *filename, char *user)
-+{
-+    char *myname = "sql2file";
-+    char *filter_sqlres;
-+    char filter_fileres[128];
-+    long sqlmtime = 0, filemtime = 0, retval = 0;
-+    int filterfile, size_sqlres, i;
-+    struct stat statbuf;
-+
-+    if (*var_virt_maildir_filter_maps != 0) {
-+        filter_sqlres = (char *) mymalloc(16000);
-+        filter_sqlres = (char *) mail_addr_find(virtual_maildir_filter_maps, user, (char **) 0);
-+
-+        if (filter_sqlres) {
-+            strcut(filter_sqlres, "\r");
-+            if (filter_sqlres[0] == '#' && filter_sqlres[1] == ' ' && filter_sqlres[2] == 'M') {
-+                size_sqlres = strlen(filter_sqlres);
-+
-+                for (i = 4; i <= size_sqlres; i++) {
-+                    if(filter_sqlres[i] == '/' && filter_sqlres[i+1] == '^') {
-+                        filter_sqlres[i-1] = '\n';
-+                    }
-+                }
-+
-+                filter_sqlres[(size_sqlres+1)] = '\0';
-+
-+                sqlmtime = atol(filter_sqlres+3);
-+                retval = sqlmtime;
-+
-+                filterfile = open(filename, O_RDONLY, 0);
-+                if (filterfile) {
-+                    read(filterfile, (void *) filter_fileres, 127);
-+                    close(filterfile);
-+
-+                    filemtime = atol(filter_fileres+3);
-+                }
-+
-+                if (msg_verbose)
-+                    msg_info("%s: filter data: sql_size=%li sql_mtime=%ld file_mtime=%ld", myname, strlen(filter_sqlres), sqlmtime, filemtime);
-+            }
-+            if (sqlmtime != filemtime && sqlmtime != 0) {
-+                if ((filterfile = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0640))) {
-+                    if (msg_verbose)
-+                        msg_info("%s: updating filter file: %s", myname, filename);
-+                    write(filterfile, filter_sqlres, strlen(filter_sqlres));
-+                    close(filterfile);
-+                }
-+                else {
-+                    msg_warn("%s: can't create filter file: %s", myname, filename);
-+                    retval = 0;
-+                }
-+            }
-+        }
-+    }
-+    else {
-+        if (stat(filename, &statbuf) == 0)
-+            retval = (long) statbuf.st_mtime;
-+        if (msg_verbose)
-+            msg_info("%s: processing filter file: file_mtime=%ld", myname, retval);
-+    }
-+
-+    return retval;
-+}
-+
-+/* deliver_maildir - delivery to maildir-style mailbox */
-+int deliver_maildir(LOCAL_STATE state, USER_ATTR usr_attr)
- {
-     const char *myname = "deliver_maildir";
--    char   *newdir;
--    char   *tmpdir;
--    char   *curdir;
--    char   *tmpfile;
--    char   *newfile;
-+    char    *newdir;
-+    char    *tmpdir;
-+    char    *curdir;
-+    char    *newfile;
-+    char    *tmpfile;
-     DSN_BUF *why = state.msg_attr.why;
-     VSTRING *buf;
-     VSTREAM *dst;
--    int     mail_copy_status;
--    int     deliver_status;
--    int     copy_flags;
--    struct stat st;
--    struct timeval starttime;
-+    int      mail_copy_status;
-+    int      deliver_status;
-+    int      copy_flags;
-+    struct   stat st;
-+    struct   timeval starttime;
-+
-+    /* Maildir Quota. */
-+    const char *limit_res;              /* Limit from map. */
-+    char    *sizefilename = (char *) 0; /* Maildirsize file name. */
-+    VSTRING *filequota;                 /* Quota setting from the maildirsize file. */
-+    VSTREAM *sizefile;                  /* Maildirsize file handle. */
-+    long     n = 0;                     /* Limit in long integer format. */
-+    long     saved_count = 0;           /* The total number of files. */
-+    long     saved_size = 0;            /* The total quota of all files. */
-+    struct   stat mail_stat;            /* To check the size of the mail to be written. */
-+    struct   stat sizefile_stat;        /* To check the size of the maildirsize file. */
-+    time_t   tm;                        /* To check the age of the maildirsize file. */
-+
-+    /* Maildir Filters. */
-+    const char *value, *cmd_text;       /* Filter values. */
-+    char    *filtername;
-+    char    *header;
-+    char    *bkpnewfile;
-+    char    *mdffilename = (char *) 0;  /* Maildirfolder file name. */
-+    VSTRING *fltstr;
-+    VSTREAM *tmpfilter;
-+    VSTREAM *mdffile;                   /* Maildirfolder file handle. */
-+    DICT    *FILTERS;
-+    long     sqlmtime;                  /* Latest modification time from sql2file(). */
-+    int      cmd_len;
-+    int	    read_mds = -1;		/* read_maildirsize() returned value */
-+    struct   stat mdffile_stat;         /* To check if the maildirfolder file exists. */
- 
-     GETTIMEOFDAY(&starttime);
- 
-@@ -94,15 +486,14 @@ int     deliver_maildir(LOCAL_STATE stat
-      */
-     state.level++;
-     if (msg_verbose)
--	MSG_LOG_STATE(myname, state);
-+	    MSG_LOG_STATE(myname, state);
- 
-     /*
-      * Don't deliver trace-only requests.
-      */
-     if (DEL_REQ_TRACE_ONLY(state.request->flags)) {
--	dsb_simple(why, "2.0.0", "delivers to maildir");
--	return (sent(BOUNCE_FLAGS(state.request),
--		     SENT_ATTR(state.msg_attr)));
-+        dsb_simple(why, "2.0.0", "delivers to maildir");
-+        return (sent(BOUNCE_FLAGS(state.request), SENT_ATTR(state.msg_attr)));
-     }
- 
-     /*
-@@ -110,18 +501,116 @@ int     deliver_maildir(LOCAL_STATE stat
-      * attribute to reflect the final recipient.
-      */
-     if (vstream_fseek(state.msg_attr.fp, state.msg_attr.offset, SEEK_SET) < 0)
--	msg_fatal("seek message file %s: %m", VSTREAM_PATH(state.msg_attr.fp));
-+        msg_fatal("seek message file %s: %m", VSTREAM_PATH(state.msg_attr.fp));
-     state.msg_attr.delivered = state.msg_attr.rcpt.address;
-     mail_copy_status = MAIL_COPY_STAT_WRITE;
-     buf = vstring_alloc(100);
- 
--    copy_flags = MAIL_COPY_TOFILE | MAIL_COPY_RETURN_PATH
--	| MAIL_COPY_DELIVERED | MAIL_COPY_ORIG_RCPT;
-+    copy_flags = MAIL_COPY_TOFILE | MAIL_COPY_RETURN_PATH | MAIL_COPY_DELIVERED | MAIL_COPY_ORIG_RCPT;
- 
--    newdir = concatenate(usr_attr.mailbox, "new/", (char *) 0);
--    tmpdir = concatenate(usr_attr.mailbox, "tmp/", (char *) 0);
--    curdir = concatenate(usr_attr.mailbox, "cur/", (char *) 0);
-+    /*
-+     * Concatenate the maildir suffix (if set).
-+     */
-+    if (*var_virt_maildir_suffix == 0) {
-+        newdir = concatenate(usr_attr.mailbox, "new/", (char *) 0);
-+        tmpdir = concatenate(usr_attr.mailbox, "tmp/", (char *) 0);
-+        curdir = concatenate(usr_attr.mailbox, "cur/", (char *) 0);
-+    }
-+    else {
-+        newdir = concatenate(usr_attr.mailbox, var_virt_maildir_suffix, (char *) 0);
-+        tmpdir = concatenate(usr_attr.mailbox, var_virt_maildir_suffix, (char *) 0);
-+        curdir = concatenate(usr_attr.mailbox, var_virt_maildir_suffix, (char *) 0);
-+        newdir = concatenate(newdir, "new/", (char *) 0);
-+        tmpdir = concatenate(tmpdir, "tmp/", (char *) 0);
-+        curdir = concatenate(curdir, "cur/", (char *) 0);
-+    }
- 
-+    /* get the sizefilename, no matter if we use var_virt_maildir_extended */
-+    if (*var_virt_maildir_suffix == 0) {
-+        sizefilename = concatenate(usr_attr.mailbox, "maildirsize", (char *) 0);
-+    } else {
-+        sizefilename = concatenate(usr_attr.mailbox, var_virt_maildir_suffix, (char *) 0);
-+        sizefilename = concatenate(sizefilename, "maildirsize", (char *) 0);
-+    }
-+    
-+    /*
-+     * Look up the virtual maildir limit size for this user.
-+     * Fall back to virtual_mailbox_limit in case lookup failed.
-+     * If virtual maildir limit size is negative, fall back to virtual_mailbox_limit.
-+     * If it's 0, set the mailbox limit to 0, which means unlimited.
-+     * If it's more than 0 (positive int), check if the value is smaller than the maximum message size,
-+     * if it is and the virtual maildir limit can't be overridden, fall back to virtual_mailbox_limit and
-+     * warn the user, else use the value directly as the maildir limit.
-+     */
-+    if (*var_virt_mailbox_limit_maps != 0 && (limit_res = mail_addr_find(virtual_mailbox_limit_maps, state.msg_attr.user, (char **) NULL)) != 0) {
-+        n = atol(limit_res);
-+        if (n > 0) {
-+            if ((n < var_message_limit) && (!var_virt_mailbox_limit_override)) {
-+                n = var_virt_mailbox_limit;
-+
-+                msg_warn("%s: recipient %s - virtual maildir limit is smaller than %s in %s - falling back to %s",
-+                        myname, state.msg_attr.user, VAR_MESSAGE_LIMIT, virtual_mailbox_limit_maps->title,
-+                        VAR_VIRT_MAILBOX_LIMIT);
-+            }
-+            else {
-+                if (msg_verbose)
-+                    msg_info("%s: set virtual maildir limit size for %s to %ld",
-+                            myname, usr_attr.mailbox, n);
-+            }
-+        }
-+        else if (n == 0) {
-+                if (msg_verbose)
-+                    msg_info("%s: set virtual maildir limit size for %s to %ld",
-+                            myname, usr_attr.mailbox, n);
-+        }
-+        else {
-+	    if (msg_verbose)
-+		msg_info("%s: quota is negative (%ld), using default virtual_mailbox_limit (%ld)", 
-+			    myname, n, var_virt_mailbox_limit);
-+            /* Invalid limit size (negative). Use default virtual_mailbox_limit. */
-+            n = var_virt_mailbox_limit;
-+        }
-+    }
-+    else {
-+	if (msg_verbose)
-+	    msg_info("%s: no limit found in the maps, using default virtual_mailbox_limit (%ld)", 
-+			myname, var_virt_mailbox_limit);
-+        /* There is no limit in the maps. Use default virtual_mailbox_limit. */
-+        n = var_virt_mailbox_limit;
-+    }
-+
-+    /* If there should is a quota on maildir generaly, check it before delivering the mail */
-+    if (n != 0) {
-+        set_eugid(usr_attr.uid, usr_attr.gid);
-+	/* try to read the quota from maildirsize file. Returned values by read_maildirsize:
-+	x < 0  = something failed
-+	x >= 0 = reading successfully finished - sum si returned, so sum size of Maildir was 0 or more */
-+        if (!var_virt_mailbox_limit_inbox && var_virt_maildir_extended && (read_mds = read_maildirsize(sizefilename, &saved_size, &saved_count)) >= 0) {
-+    	    if (msg_verbose)
-+        	msg_info("%s: maildirsize used=%s sum=%ld count=%ld", myname, sizefilename, saved_size, saved_count);
-+	} else {
-+	    if (msg_verbose) 
-+		msg_info("%s: We will recount the quota (var_virt_mailbox_limit = %ld, var_virt_maildir_extended = %d, read_maildirsize = %d)", 
-+			    myname, var_virt_mailbox_limit, var_virt_maildir_extended, read_mds);
-+
-+	    /* sanity */
-+	    saved_size = 0; 
-+	    saved_count = 0;
-+	    
-+    	    if (var_virt_mailbox_limit_inbox) {
-+        	/* Check Inbox only (new, cur and tmp dirs). */
-+        	saved_size = check_dir_size(newdir, &saved_count);
-+        	saved_size += check_dir_size(curdir, &saved_count);
-+        	saved_size += check_dir_size(tmpdir, &saved_count);
-+    	    } else {
-+        	/* Check all boxes. */
-+        	saved_size = check_dir_size(usr_attr.mailbox, &saved_count);
-+    	    }
-+
-+    	    set_eugid(var_owner_uid, var_owner_gid);
-+    	}    	
-+    }
-+    
-     /*
-      * Create and write the file as the recipient, so that file quota work.
-      * Create any missing directories on the fly. The file name is chosen
-@@ -175,46 +664,288 @@ int     deliver_maildir(LOCAL_STATE stat
-      * [...]
-      */
-     set_eugid(usr_attr.uid, usr_attr.gid);
--    vstring_sprintf(buf, "%lu.P%d.%s",
--		 (unsigned long) starttime.tv_sec, var_pid, get_hostname());
-+    vstring_sprintf(buf, "%lu.P%d.%s", (unsigned long) starttime.tv_sec, var_pid, get_hostname());
-     tmpfile = concatenate(tmpdir, STR(buf), (char *) 0);
-     newfile = 0;
-+    bkpnewfile = 0;
-     if ((dst = vstream_fopen(tmpfile, O_WRONLY | O_CREAT | O_EXCL, 0600)) == 0
--	&& (errno != ENOENT
--	    || make_dirs(tmpdir, 0700) < 0
--	    || (dst = vstream_fopen(tmpfile, O_WRONLY | O_CREAT | O_EXCL, 0600)) == 0)) {
--	dsb_simple(why, mbox_dsn(errno, "4.2.0"),
--		   "create maildir file %s: %m", tmpfile);
--    } else if (fstat(vstream_fileno(dst), &st) < 0) {
--
--	/*
--	 * Coverity 200604: file descriptor leak in code that never executes.
--	 * Code replaced by msg_fatal(), as it is not worthwhile to continue
--	 * after an impossible error condition.
--	 */
--	msg_fatal("fstat %s: %m", tmpfile);
--    } else {
--	vstring_sprintf(buf, "%lu.V%lxI%lxM%lu.%s",
--			(unsigned long) starttime.tv_sec,
--			(unsigned long) st.st_dev,
--			(unsigned long) st.st_ino,
--			(unsigned long) starttime.tv_usec,
--			get_hostname());
--	newfile = concatenate(newdir, STR(buf), (char *) 0);
--	if ((mail_copy_status = mail_copy(COPY_ATTR(state.msg_attr),
--					  dst, copy_flags, "\n",
--					  why)) == 0) {
--	    if (sane_link(tmpfile, newfile) < 0
--		&& (errno != ENOENT
--		    || (make_dirs(curdir, 0700), make_dirs(newdir, 0700)) < 0
--		    || sane_link(tmpfile, newfile) < 0)) {
--		dsb_simple(why, mbox_dsn(errno, "4.2.0"),
--			   "create maildir file %s: %m", newfile);
--		mail_copy_status = MAIL_COPY_STAT_WRITE;
--	    }
--	}
--	if (unlink(tmpfile) < 0)
--	    msg_warn("remove %s: %m", tmpfile);
-+        && (errno != ENOENT
-+            || make_dirs(tmpdir, 0700) < 0
-+            || (dst = vstream_fopen(tmpfile, O_WRONLY | O_CREAT | O_EXCL, 0600)) == 0)) {
-+        dsb_simple(why, mbox_dsn(errno, "4.2.0"), "create maildir file %s: %m", tmpfile);
-+    }
-+    else if (fstat(vstream_fileno(dst), &st) < 0) {
-+        /*
-+         * Coverity 200604: file descriptor leak in code that never executes.
-+         * Code replaced by msg_fatal(), as it is not worthwhile to continue
-+         * after an impossible error condition.
-+         */
-+        msg_fatal("fstat %s: %m", tmpfile);
-+    }
-+    else {
-+        vstring_sprintf(buf, "%lu.V%lxI%lxM%lu.%s",
-+                (unsigned long) starttime.tv_sec,
-+                (unsigned long) st.st_dev,
-+                (unsigned long) st.st_ino,
-+                (unsigned long) starttime.tv_usec,
-+                get_hostname());
-+        newfile = concatenate(newdir, STR(buf), (char *) 0);
-+        bkpnewfile = concatenate(STR(buf), (char *) 0); /* Will need it later, if we MOVE to other folders. */
-+
-+        if ((mail_copy_status = mail_copy(COPY_ATTR(state.msg_attr), dst, copy_flags, "\n", why)) == 0) {
-+            /*
-+             * Add a ",S=<sizeoffile>" to the newly written file according to the
-+             * Maildir++ specifications: http://www.inter7.com/courierimap/README.maildirquota.html
-+             * This needs a stat(2) of the tempfile and modification of the
-+             * name of the file.
-+             */
-+            if (stat(tmpfile, &mail_stat) == 0) {
-+                if (n != 0) {
-+                    saved_size += (long) mail_stat.st_size;
-+                    saved_count++;
-+                }
-+                if (var_virt_maildir_extended) {
-+                    /* Append the size of the file to newfile. */
-+                    vstring_sprintf(buf, ",S=%ld", (long) mail_stat.st_size);
-+                    newfile = concatenate(newfile, STR(buf), (char *) 0);
-+                    bkpnewfile = concatenate(bkpnewfile, STR(buf), (char *) 0);
-+                }
-+            }
-+
-+            /*
-+             * Now we have the maildir size in saved_size, compare it to the max
-+             * quota value and eventually issue a message that we've overdrawn it.
-+             */
-+            if (saved_size > n) {
-+                mail_copy_status = MAIL_COPY_STAT_WRITE;
-+                if (((long) mail_stat.st_size > n) || (var_virt_overquota_bounce))
-+                    errno = EFBIG;
-+                else
-+                    errno = EDQUOT;
-+            }
-+            else {
-+                /* Maildirfilter code by rk at demiurg.net. */
-+                if (var_virt_maildir_filter) {
-+                    if (msg_verbose)
-+                        msg_info("%s: loading DICT filters", myname);
-+
-+#define STREQUAL(x,y,l) (strncasecmp((x), (y), (l)) == 0 && (y)[l] == 0)
-+#define MAIL_COPY_STAT_REJECT  (1<<3)
-+#define MAIL_COPY_STAT_DISCARD (1<<4)
-+
-+                    /* Read filters. */
-+                    filtername = concatenate("regexp:", usr_attr.mailbox, "maildirfilter", (char *) 0);
-+                    sqlmtime = sql2file(strchr(filtername, '/'), state.msg_attr.user);
-+
-+                    /* Check if this filter is already registered as dictionary. */
-+                    if (msg_verbose)
-+                        msg_info("%s: checking DICT filters for %s", myname, filtername);
-+
-+                    if ((FILTERS = dict_handle(filtername))) {
-+                        if (msg_verbose)
-+                            msg_info("%s: DICT filter found", myname);
-+
-+                        /*
-+                         * If we have mtime in our DICT structure, check it against sqlmtime
-+                         * and reload the filters if they differ.
-+                         */
-+                        if (FILTERS->mtime > 0 && sqlmtime > 0 && FILTERS->mtime != sqlmtime) {
-+                            if (msg_verbose)
-+                                msg_info("%s: reloading DICT filters (dict_mtime=%ld != sql_mtime=%ld)",
-+                                        myname, FILTERS->mtime, sqlmtime);
-+
-+                            dict_unregister(filtername);
-+                            FILTERS = dict_open(filtername, O_RDONLY, DICT_FLAG_LOCK);
-+                            dict_register(filtername, FILTERS);
-+                            FILTERS->mtime = sqlmtime;
-+                        }
-+                    }
-+                    else {
-+                        if (sqlmtime > 0) {
-+                            /* Registering filter as new dictionary. */
-+                            if (msg_verbose)
-+                                msg_info("%s: loading DICT filters from %s (mtime=%ld)",
-+                                        myname, filtername, sqlmtime);
-+
-+                            FILTERS = dict_open(filtername, O_RDONLY, DICT_FLAG_LOCK);
-+                            dict_register(filtername, FILTERS);
-+                            FILTERS->mtime = sqlmtime;
-+                        }
-+                    }
-+
-+                    if (FILTERS && (tmpfilter = vstream_fopen(tmpfile, O_RDONLY, 0))) {
-+                        fltstr = vstring_alloc(1024);
-+                        header = (char *) malloc(8192); /* !!!INSECURE!!! See 7168-hack below. */
-+                        header[0] = 0;
-+                        vstring_get_nonl_bound(fltstr, tmpfilter, 1023);
-+                        header = concatenate(header, STR(fltstr), (char *) 0);
-+
-+                        while(!vstream_feof(tmpfilter) && fltstr->vbuf.data[0] && strlen(header) < 7168 ) {
-+                            vstring_get_nonl_bound(fltstr, tmpfilter, 1023);
-+                            /* Glue multiline headers, replacing leading TAB with space. */
-+                            if (msg_verbose)
-+                                msg_info("%s: fltstr value: %s", myname, STR(fltstr));
-+
-+                            if (fltstr->vbuf.data[0] == ' ' || fltstr->vbuf.data[0] == '\t' ) {
-+                                if (fltstr->vbuf.data[0] == '\t')
-+                                    fltstr->vbuf.data[0] = ' ';
-+                                header = concatenate(header, STR(fltstr), (char *) 0);
-+                            }
-+                            else {
-+                                header = concatenate(header, "\n", STR(fltstr), (char *) 0);
-+                            }
-+                        }
-+
-+                        if (msg_verbose)
-+                            msg_info("%s: checking filter CMD for %s", myname, filtername);
-+
-+                        /* Check whole header part with regexp maps. */
-+                        if ((value = dict_get(FILTERS, lowercase(header))) != 0) {
-+                            if (msg_verbose)
-+                                msg_info("%s: preparing filter CMD", myname);
-+
-+                            cmd_text = value + strcspn(value, " \t");
-+                            cmd_len = cmd_text - value;
-+                            while (*cmd_text && ISSPACE(*cmd_text))
-+                                cmd_text++;
-+
-+                            if (msg_verbose)
-+                                msg_info("%s: executing filter CMD", myname);
-+
-+                            if (STREQUAL(value, "REJECT", cmd_len)) {
-+                                if (msg_verbose)
-+                                    msg_info("%s: executing filter CMD REJECT", myname);
-+
-+                                mail_copy_status = MAIL_COPY_STAT_REJECT;
-+                                vstring_sprintf(why->reason, "%s", cmd_text);
-+                                dsb_simple(why, "5.0.0", "User filter - REJECT");
-+                            }
-+
-+                            if (STREQUAL(value, "DISCARD", cmd_len)) {
-+                                if (msg_verbose)
-+                                    msg_info("%s: executing filter CMD DISCARD", myname);
-+
-+                                mail_copy_status = MAIL_COPY_STAT_DISCARD;
-+                                vstring_sprintf(why->reason, "%s", cmd_text);
-+                                dsb_simple(why, "5.0.0", "User filter - DISCARD");
-+                            }
-+
-+                            if (var_virt_maildir_extended) {
-+                                if (STREQUAL(value, "MOVE", cmd_len)) {
-+                                    if (msg_verbose)
-+                                        msg_info("%s: executing filter CMD MOVE", myname);
-+
-+                                    strcut((char *) cmd_text, " ");
-+                                    strcut((char *) cmd_text, "\t");
-+                                    strcut((char *) cmd_text, "/");
-+                                    strcut((char *) cmd_text, "..");
-+
-+                                    if (*var_virt_maildir_suffix == 0) {
-+                                        newfile = concatenate(usr_attr.mailbox, (char *) 0);
-+                                    }
-+                                    else {
-+                                        newfile = concatenate(usr_attr.mailbox, var_virt_maildir_suffix, (char *) 0);
-+                                    }
-+
-+                                    if (cmd_text[0] != '.') {
-+                                        newfile = concatenate(newfile, ".", (char *) 0);
-+                                    }
-+                                    newdir  = concatenate(newfile, cmd_text, "/", "new/", (char *) 0);
-+                                    tmpdir  = concatenate(newfile, cmd_text, "/", "tmp/", (char *) 0);
-+                                    curdir  = concatenate(newfile, cmd_text, "/", "cur/", (char *) 0);
-+                                    mdffilename = concatenate(newfile, cmd_text, "/", "maildirfolder", (char *) 0);
-+                                    newfile = concatenate(newfile, cmd_text, "/", "new/", bkpnewfile, (char *) 0);
-+                                }
-+                            }
-+
-+                            if (STREQUAL(value, "LOG", cmd_len) || STREQUAL(value, "WARN", cmd_len)) {
-+                                msg_warn("%s: header check warning: %s", myname, cmd_text);
-+                            }
-+
-+                            if (STREQUAL(value, "INFO", cmd_len)) {
-+                                msg_info("%s: header check info: %s", myname, cmd_text);
-+                            }
-+
-+                            if (msg_verbose)
-+                                msg_info("%s: exiting filter CMD", myname);
-+                        } /* End-Of-Check */
-+
-+                        myfree(header);
-+                        vstring_free(fltstr);
-+                        vstream_fclose(tmpfilter);
-+                    }
-+
-+                    myfree(filtername);
-+                } /* End-Of-Maildirfilter */
-+
-+                /* Deliver to curdir. */
-+                if (mail_copy_status == 0) {
-+                    if (sane_link(tmpfile, newfile) < 0
-+                        && (errno != ENOENT
-+                            || (make_dirs(curdir, 0700), make_dirs(newdir, 0700), make_dirs(tmpdir, 0700)) < 0
-+                            || sane_link(tmpfile, newfile) < 0)) {
-+                        dsb_simple(why, mbox_dsn(errno, "4.2.0"), "create maildir file %s: %m", newfile);
-+                        mail_copy_status = MAIL_COPY_STAT_WRITE;
-+                    }
-+
-+                    if (var_virt_maildir_extended) {
-+                        time(&tm);
-+
-+                        /* Check if the quota in the file is the same as the current one, if not, delete the file. */
-+                        sizefile = vstream_fopen(sizefilename, O_RDONLY, 0);
-+                        if (sizefile) {
-+                            filequota = vstring_alloc(128);
-+                            vstring_get_null_bound(filequota, sizefile, 127);
-+                            vstream_fclose(sizefile);
-+                            if (atol(vstring_export(filequota)) != n)
-+                                unlink(sizefilename);
-+                        }
-+
-+                        /* Open maildirsize file to append this transaction. */
-+                        sizefile = vstream_fopen(sizefilename, O_WRONLY | O_APPEND, 0640);
-+
-+                        /* If the open fails (maildirsize doesn't exist), or it's too large, or too old, overwrite it. */
-+                        if(!sizefile || (stat(sizefilename, &sizefile_stat) < 0) || (sizefile_stat.st_size > SIZEFILE_MAX) || (sizefile_stat.st_mtime + 15*60 < tm)) {
-+                            /* If the file exists, sizefile has been opened above, so close it first. */
-+                            if (sizefile) {
-+                                vstream_fclose(sizefile);
-+                                sizefile = vstream_fopen(sizefilename, O_WRONLY | O_TRUNC, 0640);
-+                            }
-+                            else {
-+                                sizefile = vstream_fopen(sizefilename, O_WRONLY | O_CREAT, 0640);
-+                            }
-+
-+                            /* If the creation worked, write to the file, otherwise just give up. */
-+                            if (sizefile) {
-+                                vstream_fprintf(sizefile, "%ldS\n%ld %ld\n", n, saved_size, saved_count);
-+                                vstream_fclose(sizefile);
-+                            }
-+                        }
-+                        else {
-+                            /* We opened maildirsize, so let's just append this transaction and close it. */
-+                            vstream_fprintf(sizefile, "%ld 1\n", (long) mail_stat.st_size);
-+                            vstream_fclose(sizefile);
-+                        }
-+
-+                        /*
-+                         * 1) mdffilename != 0, so the maildirfilter code went through the MOVE to subfolder rule.
-+                         * 2) stat() failed, maybe the file does not exist? Try to create it.
-+                         */
-+                        if (mdffilename && (stat(mdffilename, &mdffile_stat) < 0)) {
-+                            mdffile = vstream_fopen(mdffilename, O_WRONLY | O_CREAT, 0600);
-+                            if (mdffile) {
-+                                vstream_fclose(mdffile);
-+                            }
-+                            else {
-+                                msg_warn("Cannot create maildirfolder file '%s': %s", mdffilename, strerror(errno));
-+                            }
-+                        }
-+                    }
-+                }
-+            }
-+        }
-+        if (unlink(tmpfile) < 0)
-+            msg_warn("remove %s: %m", tmpfile);
-     }
-     set_eugid(var_owner_uid, var_owner_gid);
- 
-@@ -224,31 +955,64 @@ int     deliver_maildir(LOCAL_STATE stat
-      * location possibly under user control.
-      */
-     if (mail_copy_status & MAIL_COPY_STAT_CORRUPT) {
--	deliver_status = DEL_STAT_DEFER;
--    } else if (mail_copy_status != 0) {
--	if (errno == EACCES) {
--	    msg_warn("maildir access problem for UID/GID=%lu/%lu: %s",
--		     (long) usr_attr.uid, (long) usr_attr.gid,
--		     STR(why->reason));
--	    msg_warn("perhaps you need to create the maildirs in advance");
--	}
--	vstring_sprintf_prepend(why->reason, "maildir delivery failed: ");
--	deliver_status =
--	    (STR(why->status)[0] == '4' ?
--	     defer_append : bounce_append)
--	    (BOUNCE_FLAGS(state.request),
--	     BOUNCE_ATTR(state.msg_attr));
--    } else {
--	dsb_simple(why, "2.0.0", "delivered to maildir");
--	deliver_status = sent(BOUNCE_FLAGS(state.request),
--			      SENT_ATTR(state.msg_attr));
-+        deliver_status = DEL_STAT_DEFER;
-+    }
-+    else if (mail_copy_status != 0) {
-+        if (errno == EACCES) {
-+            msg_warn("maildir access problem for UID/GID=%lu/%lu: %s",
-+                    (long) usr_attr.uid, (long) usr_attr.gid, STR(why->reason));
-+            msg_warn("perhaps you need to create the maildirs in advance");
-+        }
-+
-+        /* Support per-recipient bounce messages. */
-+        const char *limit_message;
-+        int errnored = errno; /* Seems like mail_addr_find resets errno ... */
-+
-+        if (*var_virt_maildir_limit_message_maps != 0 && (limit_message = mail_addr_find(virtual_maildir_limit_message_maps, state.msg_attr.user, (char **) NULL)) != 0) {
-+            errno = errnored;
-+            if (errno == EFBIG) {
-+                dsb_simple(why, "5.2.2", limit_message, NULL);
-+            }
-+            if (errno == EDQUOT) {
-+                dsb_simple(why, "4.2.2", limit_message, NULL);
-+            }
-+        }
-+        else {
-+            errno = errnored;
-+            if (errno == EFBIG) {
-+                dsb_simple(why, "5.2.2", var_virt_maildir_limit_message, NULL);
-+            }
-+            if (errno == EDQUOT) {
-+                dsb_simple(why, "4.2.2", var_virt_maildir_limit_message, NULL);
-+            }
-+        }
-+
-+        vstring_sprintf_prepend(why->reason, "maildir delivery failed: ");
-+        deliver_status =
-+                (STR(why->status)[0] == '4' ? defer_append : bounce_append)
-+                (BOUNCE_FLAGS(state.request), BOUNCE_ATTR(state.msg_attr));
-     }
-+    else {
-+        dsb_simple(why, "2.0.0", "delivered to maildir");
-+        deliver_status = sent(BOUNCE_FLAGS(state.request), SENT_ATTR(state.msg_attr));
-+    }
-+
-     vstring_free(buf);
-+
-     myfree(newdir);
-     myfree(tmpdir);
-     myfree(curdir);
-+
-+    if (sizefilename)
-+        myfree(sizefilename);
-+    if (mdffilename)
-+        myfree(mdffilename);
-+
-     myfree(tmpfile);
-     if (newfile)
--	myfree(newfile);
-+        myfree(newfile);
-+    if (bkpnewfile)
-+        myfree(bkpnewfile);
-+
-     return (deliver_status);
- }
-diff -ruNp postfix-2.11.10.orig/src/virtual/virtual.c postfix-2.11.10/src/virtual/virtual.c
---- postfix-2.11.10.orig/src/virtual/virtual.c	2011-02-19 01:46:06.000000000 +0100
-+++ postfix-2.11.10/src/virtual/virtual.c	2017-07-02 00:13:25.779285410 +0200
-@@ -335,12 +335,30 @@ long    var_virt_mailbox_limit;
- char   *var_mail_spool_dir;		/* XXX dependency fix */
- bool    var_strict_mbox_owner;
- 
-+char   *var_virt_mailbox_limit_maps;
-+bool    var_virt_mailbox_limit_inbox;
-+bool    var_virt_mailbox_limit_override;
-+bool    var_virt_maildir_extended;
-+bool    var_virt_overquota_bounce;
-+char   *var_virt_maildir_limit_message;
-+char   *var_virt_maildir_limit_message_maps;
-+char   *var_virt_maildir_suffix;
-+bool    var_virt_trash_count;
-+char   *var_virt_trash_name;
-+bool    var_virt_maildir_filter;
-+char   *var_virt_maildir_filter_maps;
-+
-+
-  /*
-   * Mappings.
-   */
- MAPS   *virtual_mailbox_maps;
- MAPS   *virtual_uid_maps;
- MAPS   *virtual_gid_maps;
-+MAPS   *virtual_mailbox_limit_maps;
-+MAPS   *virtual_maildir_limit_message_maps;
-+MAPS   *virtual_maildir_filter_maps;
-+
- 
-  /*
-   * Bit masks.
-@@ -450,15 +468,28 @@ static void post_init(char *unused_name,
-      */
-     virtual_mailbox_maps =
- 	maps_create(VAR_VIRT_MAILBOX_MAPS, var_virt_mailbox_maps,
--		    DICT_FLAG_LOCK | DICT_FLAG_PARANOID);
-+		    DICT_FLAG_LOCK);
- 
-     virtual_uid_maps =
- 	maps_create(VAR_VIRT_UID_MAPS, var_virt_uid_maps,
--		    DICT_FLAG_LOCK | DICT_FLAG_PARANOID);
-+		    DICT_FLAG_LOCK);
- 
-     virtual_gid_maps =
- 	maps_create(VAR_VIRT_GID_MAPS, var_virt_gid_maps,
--		    DICT_FLAG_LOCK | DICT_FLAG_PARANOID);
-+		    DICT_FLAG_LOCK);
-+
-+    virtual_mailbox_limit_maps =
-+        maps_create(VAR_VIRT_MAILBOX_LIMIT_MAPS, var_virt_mailbox_limit_maps,
-+                    DICT_FLAG_LOCK);
-+
-+    virtual_maildir_limit_message_maps =
-+        maps_create(VAR_VIRT_MAILDIR_LIMIT_MESSAGE_MAPS, var_virt_maildir_limit_message_maps,
-+                    DICT_FLAG_LOCK);
-+
-+    virtual_maildir_filter_maps =
-+        maps_create(VAR_VIRT_MAILDIR_FILTER_MAPS, var_virt_maildir_filter_maps,
-+                    DICT_FLAG_LOCK);
-+
- 
-     virtual_mbox_lock_mask = mbox_lock_mask(var_virt_mailbox_lock);
- }
-@@ -510,10 +541,22 @@ int     main(int argc, char **argv)
- 	VAR_VIRT_GID_MAPS, DEF_VIRT_GID_MAPS, &var_virt_gid_maps, 0, 0,
- 	VAR_VIRT_MAILBOX_BASE, DEF_VIRT_MAILBOX_BASE, &var_virt_mailbox_base, 1, 0,
- 	VAR_VIRT_MAILBOX_LOCK, DEF_VIRT_MAILBOX_LOCK, &var_virt_mailbox_lock, 1, 0,
-+	VAR_VIRT_MAILBOX_LIMIT_MAPS, DEF_VIRT_MAILBOX_LIMIT_MAPS, &var_virt_mailbox_limit_maps, 0, 0,
-+	VAR_VIRT_MAILDIR_LIMIT_MESSAGE, DEF_VIRT_MAILDIR_LIMIT_MESSAGE, &var_virt_maildir_limit_message, 1, 0,
-+	VAR_VIRT_MAILDIR_LIMIT_MESSAGE_MAPS, DEF_VIRT_MAILDIR_LIMIT_MESSAGE_MAPS, &var_virt_maildir_limit_message_maps, 0, 0,
-+	VAR_VIRT_MAILDIR_SUFFIX, DEF_VIRT_MAILDIR_SUFFIX, &var_virt_maildir_suffix, 0, 0,
-+	VAR_VIRT_TRASH_NAME, DEF_VIRT_TRASH_NAME, &var_virt_trash_name, 0, 0,
-+	VAR_VIRT_MAILDIR_FILTER_MAPS, DEF_VIRT_MAILDIR_FILTER_MAPS, &var_virt_maildir_filter_maps, 0, 0,
- 	0,
-     };
-     static const CONFIG_BOOL_TABLE bool_table[] = {
- 	VAR_STRICT_MBOX_OWNER, DEF_STRICT_MBOX_OWNER, &var_strict_mbox_owner,
-+	VAR_VIRT_MAILBOX_LIMIT_INBOX, DEF_VIRT_MAILBOX_LIMIT_INBOX, &var_virt_mailbox_limit_inbox,
-+	VAR_VIRT_MAILBOX_LIMIT_OVERRIDE, DEF_VIRT_MAILBOX_LIMIT_OVERRIDE, &var_virt_mailbox_limit_override,
-+	VAR_VIRT_MAILDIR_EXTENDED, DEF_VIRT_MAILDIR_EXTENDED, &var_virt_maildir_extended,
-+	VAR_VIRT_OVERQUOTA_BOUNCE, DEF_VIRT_OVERQUOTA_BOUNCE, &var_virt_overquota_bounce,
-+	VAR_VIRT_TRASH_COUNT, DEF_VIRT_TRASH_COUNT, &var_virt_trash_count,
-+	VAR_VIRT_MAILDIR_FILTER, DEF_VIRT_MAILDIR_FILTER, &var_virt_maildir_filter,
- 	0,
-     };
- 
-@@ -530,6 +573,7 @@ int     main(int argc, char **argv)
- 		       MAIL_SERVER_PRE_INIT, pre_init,
- 		       MAIL_SERVER_POST_INIT, post_init,
- 		       MAIL_SERVER_PRE_ACCEPT, pre_accept,
-+                       MAIL_SERVER_BOOL_TABLE, bool_table,
- 		       MAIL_SERVER_PRIVILEGED,
- 		       0);
- }
-diff -ruNp postfix-2.11.10.orig/src/virtual/virtual.h postfix-2.11.10/src/virtual/virtual.h
---- postfix-2.11.10.orig/src/virtual/virtual.h	2006-01-08 00:59:47.000000000 +0100
-+++ postfix-2.11.10/src/virtual/virtual.h	2017-07-02 00:13:25.780285407 +0200
-@@ -34,6 +34,9 @@
- extern MAPS *virtual_mailbox_maps;
- extern MAPS *virtual_uid_maps;
- extern MAPS *virtual_gid_maps;
-+extern MAPS *virtual_mailbox_limit_maps;
-+extern MAPS *virtual_maildir_limit_message_maps;
-+extern MAPS *virtual_maildir_filter_maps;
- 
-  /*
-   * User attributes: these control the privileges for delivery to external
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/postfix.git/commitdiff/425806cea3e9e7684a1954ac622d1dbadfc48d44



More information about the pld-cvs-commit mailing list