From 9b2bef6acf5cd89c9abf7594da6d2aa1c3649b03 Mon Sep 17 00:00:00 2001
From: Wietse Venema
Date: Tue, 13 Dec 2011 00:00:00 -0500
Subject: [PATCH] postfix-2.9-20111213
---
postfix/HISTORY | 19 +
postfix/README_FILES/MEMCACHE_README | 75 ++--
postfix/RELEASE_NOTES | 27 ++
postfix/WISHLIST | 3 +
postfix/html/MEMCACHE_README.html | 93 ++---
postfix/html/memcache_table.5.html | 122 ++++---
postfix/html/proxymap.8.html | 8 +
postfix/man/man5/memcache_table.5 | 104 +++---
postfix/man/man8/proxymap.8 | 7 +
postfix/proto/MEMCACHE_README.html | 93 ++---
postfix/proto/memcache_table | 104 +++---
postfix/src/global/Makefile.in | 26 +-
postfix/src/global/dict_memcache.c | 505 ++++++++++++++-------------
postfix/src/global/dict_proxy.c | 103 +++++-
postfix/src/global/dict_proxy.h | 1 +
postfix/src/global/mail_dict.c | 11 +-
postfix/src/global/mail_proto.h | 1 +
postfix/src/global/mail_version.h | 2 +-
postfix/src/global/memcache_proto.c | 202 +++++++++++
postfix/src/global/memcache_proto.h | 34 ++
postfix/src/proxymap/proxymap.c | 70 +++-
postfix/src/util/dict.c | 4 +-
postfix/src/util/dict_test.c | 6 +-
23 files changed, 1043 insertions(+), 577 deletions(-)
create mode 100644 postfix/src/global/memcache_proto.c
create mode 100644 postfix/src/global/memcache_proto.h
diff --git a/postfix/HISTORY b/postfix/HISTORY
index c8473aa89..20a72296c 100644
--- a/postfix/HISTORY
+++ b/postfix/HISTORY
@@ -17283,3 +17283,22 @@ Apologies for any names omitted.
src/postlog/postlog.c, src/postmap/postmap.c,
src/postmulti/postmulti.c, src/postqueue/postqueue.c,
src/postsuper/postsuper.c, src/sendmail/sendmail.c.
+
+20111211
+
+ Feature: first/next (sequence) support in the proxymap
+ protocol. This is needed for cache cleanup of a proxied
+ postscreen or verify persistent cache. Files:
+ global/dict_proxy.[hc], proxymap/proxymap.c.
+
+ Feature: memcache client support without libmemcache
+ dependencies. Files: global/memcache_proto.[hc],
+ global/dict_memcache.c.
+
+ Feature: support for persistent backup database in the
+ memcache client. The database can be shared with the proxymap
+ service, but it needs to be listed as "proxy:maptype:mapname"
+ in the proxy_read_maps or proxy_write_maps parameter value
+ (depending on whether the access is read-only or read-write).
+ Support for proxymap-over-tcp (proxy:maptype:mapname@host:port)
+ is under development. File: global/dict_memcache.c.
diff --git a/postfix/README_FILES/MEMCACHE_README b/postfix/README_FILES/MEMCACHE_README
index 9c17f5551..4685f4c51 100644
--- a/postfix/README_FILES/MEMCACHE_README
+++ b/postfix/README_FILES/MEMCACHE_README
@@ -4,63 +4,36 @@ PPoossttffiixx mmeemmccaacchhee cclliieenntt HHoowwtto
IInnttrroodduuccttiioonn
-The Postfix memcache client type allows you to hook up Postfix to a memcache
-server. This implementation supports multiple memcache servers for redundancy,
-and multiple memcache clients that you can use for different table lookups. The
-Postfix memcache client supports both lookup and update operations.
+The Postfix memcache client allows you to hook up Postfix to a memcache server.
+The current implementation supports one memcache server per Postfix table, with
+one optional Postfix database that provides persistent backup. The Postfix
+memcache client supports the lookup, update, delete and sequence operations.
+The sequence (i.e. first/next) operation requires a backup database that
+supports this operation.
-Typically, a memcache map is used to reduce query load on a database server, or
-to share a low-latency database among different Postfix instances.
+Typically, the Postfix memcache client is used to reduce query load on a
+persistent database, but it may also be used to query a memory-only database
+for low-value, easy-to-create, information such as a reputation cache for
+postscreen(8), verify(8) or greylisting.
LLiimmiittaattiioonnss
- * The Postfix memcache client is based on libmemcache, which will terminate
- its process after a memcache server goes down. To avoid this, set up
- redundant memcache servers that have no common source of failure.
-
* The Postfix memcache client cannot be used for security-sensitive tables
such as alias_maps (these may contain "|command" and "/file/name"
- destinations), or virtual_uid_maps and virtual_gid_maps (these specify UNIX
- process privileges). Typically, a memcache database is shared via a TCP
- socket, and is writable not only by Postfix, but by any process that can
- talk to the memcache server.
+ destinations), or virtual_uid_maps, virtual_gid_maps and
+ virtual_mailbox_maps (these specify UNIX process privileges or "/file/name"
+ destinations). Typically, a memcache database is writable by any process
+ that can talk to the memcache server; in contrast, security-sensitive
+ tables must not be writable by the unprivileged Postfix user.
- * The Postfix memcache client requires additional configuration when used
- with the postscreen(8) and verify(8) daemons. For details see the ttl
- parameter discussion in the memcache_table(5) manual page.
-
- * The Postfix memcache client is supported only with libmemcache version
- 1.4.0. Some libmemcache features are documented by reading libmemcache
- source code, instead of a proper API.
+ * The Postfix memcache client requires additional configuration when used as
+ postscreen(8) or verify(8) cache. For details see the backup and ttl
+ parameter discussions in the memcache_table(5) manual page.
BBuuiillddiinngg PPoossttffiixx wwiitthh mmeemmccaacchhee ssuuppppoorrtt
-To build Postfix with memcache client support, specify -DHAS_MEMCACHE, the
-location of the libmemcache include files, and the location of the libmemcache
-object library.
-
-For example:
-
- % make -f Makefile.init makefiles \
- 'CCARGS=-DHAS_MEMCACHE -I/usr/local/include' \
- 'AUXLIBS=-L/usr/local/lib -lmemcache'
-
-Then run 'make'.
-
-If the build fails with "undefined reference to `mcm_buf_len'" (and with a
-similar error message for mcm_buf_remain_off), then you need to edit
-libmemcache source code.
-
-The following instructions apply to libmemcache 1.4.0.rc2.
-
- * Open the libmemcache source file include/memcache/buffer.h.
-
- * Delete the "inline" words before the functions that were reported in the
- "undefined reference" error messages.
-
- * Recompile and reinstall libmemcache.
-
-Then, continue building Postfix by running 'make'.
+The Postfix memcache client has no external dependencies, and is therefore
+built into Postfix by default.
CCoonnffiigguurriinngg mmeemmccaacchhee llooookkuupp ttaabblleess
@@ -68,8 +41,10 @@ Configuration is described in the memcache_table(5) manpage.
CCrreeddiittss
-The first memcache client for Postfix was written by Omar Kilani.
+The first memcache client for Postfix was written by Omar Kilani, and was based
+on the libmemcache library.
-Wietse wrote a new memcache client from the ground up. Besides also using
-libmemcache, the current implementation bears no resemblance to Omar's work.
+Wietse wrote the current memcache client from the ground up. This
+implementation does not use libmemcache, and bears no resemblance to earlier
+work.
diff --git a/postfix/RELEASE_NOTES b/postfix/RELEASE_NOTES
index 48cd6b1a8..c375bb3ef 100644
--- a/postfix/RELEASE_NOTES
+++ b/postfix/RELEASE_NOTES
@@ -14,6 +14,33 @@ specifies the release date of a stable release or snapshot release.
If you upgrade from Postfix 2.7 or earlier, read RELEASE_NOTES-2.8
before proceeding.
+Major changes with snapshot 20111213
+====================================
+
+Support for a persistent backup database in the memcache client.
+The memcache client updates the memcache whenever it looks up or
+modifies information in the persistent database.
+
+The persistent database can be shared with the proxymap service,
+but it needs to be listed as "proxy:maptype:mapname" in the
+proxy_read_maps or proxy_write_maps parameter value (depending on
+whether the access is read-only or read-write).
+
+Support for proxymap-over-tcp (proxy:maptype:mapname@host:port) is
+under development.
+
+Elimination of dependencies on the libmemcache library. Postfix
+memcache support is now compiled in by default.
+
+Major changes with snapshot 20111209
+====================================
+
+memcache lookup and update support. This provides a way to share
+postscreen(8) or verify(8) caches between Postfix instances. The
+Postfix memcache client can't be used for security-sensitive
+information, and it supports only libmemcache version 1.4.0. See
+MEMCACHE_README and memcache_table(5) for details and limitations.
+
Incompatible changes with snapshot 20111205
===========================================
diff --git a/postfix/WISHLIST b/postfix/WISHLIST
index d2a4e8cb9..dd11556ff 100644
--- a/postfix/WISHLIST
+++ b/postfix/WISHLIST
@@ -6,6 +6,9 @@ Wish list:
or require that they reset dict_errno on entry, either exit
with a fatal error or set dict_errno on error.
+ dict_memcache: treat "bad" key as cache miss, i.e. read/write
+ the database as if the cache did not exist.
+
Is it possible to replace msg_fatal calls in match_ops.c
by msg_warn and longjmp? The callers will have to specify
if they want the code to return instead of terminate.
diff --git a/postfix/html/MEMCACHE_README.html b/postfix/html/MEMCACHE_README.html
index ff96b8bc9..5f3226cc6 100644
--- a/postfix/html/MEMCACHE_README.html
+++ b/postfix/html/MEMCACHE_README.html
@@ -19,82 +19,44 @@
Introduction
-The Postfix memcache client type allows you to hook up Postfix to
-a memcache server. This implementation supports multiple memcache
-servers for redundancy, and multiple memcache clients that you can
-use for different table lookups. The Postfix memcache client
-supports both lookup and update operations.
+The Postfix memcache client allows you to hook up Postfix to a
+memcache server. The current implementation supports one memcache
+server per Postfix table, with one optional Postfix database that
+provides persistent backup. The Postfix memcache client supports
+the lookup, update, delete and sequence operations. The sequence
+(i.e. first/next) operation requires a backup database that supports
+this operation.
- Typically, a memcache map is used to reduce query load on a
-database server, or to share a low-latency database among different
-Postfix instances.
+ Typically, the Postfix memcache client is used to reduce query
+load on a persistent database, but it may also be used to query a
+memory-only database for low-value, easy-to-create, information
+such as a reputation cache for postscreen(8), verify(8) or greylisting.
+
Limitations
--
The Postfix memcache client is based on libmemcache, which
-will terminate its process after a memcache server goes down. To
-avoid this, set up redundant memcache servers that have no common
-source of failure.
-
-
The Postfix memcache client cannot be used for security-sensitive
tables such as alias_maps (these may contain "|command"
-and "/file/name" destinations), or virtual_uid_maps
-and virtual_gid_maps (these specify UNIX process privileges).
-Typically, a memcache database is shared via a TCP socket, and is
-writable not only by Postfix, but by any process that can talk to
-the memcache server.
+and "/file/name" destinations), or virtual_uid_maps,
+virtual_gid_maps and virtual_mailbox_maps (these
+specify UNIX process privileges or "/file/name" destinations).
+Typically, a memcache database is writable by any process that can
+talk to the memcache server; in contrast, security-sensitive tables
+must not be writable by the unprivileged Postfix user.
The Postfix memcache client requires additional configuration
-when used with the postscreen(8) and verify(8) daemons. For details
-see the ttl parameter discussion in the memcache_table(5)
-manual page.
-
- The Postfix memcache client is supported only with libmemcache
-version 1.4.0. Some libmemcache features are documented by reading
-libmemcache source code, instead of a proper API.
+when used as postscreen(8) or verify(8) cache. For details see the
+backup and ttl parameter discussions in the
+memcache_table(5) manual page.
Building Postfix with memcache support
-To build Postfix with memcache client support, specify
--DHAS_MEMCACHE, the location of the libmemcache include
-files, and the location of the libmemcache object library.
-
- For example:
-
-
-
-% make -f Makefile.init makefiles \
- 'CCARGS=-DHAS_MEMCACHE -I/usr/local/include' \
- 'AUXLIBS=-L/usr/local/lib -lmemcache'
-
-
-
- Then run 'make'.
-
- If the build fails with "undefined reference to `mcm_buf_len'"
-(and with a similar error message for mcm_buf_remain_off),
-then you need to edit libmemcache source code.
-
- The following instructions apply to libmemcache 1.4.0.rc2.
-
-
-
--
Open the libmemcache source file
-include/memcache/buffer.h.
-
- -
Delete the "inline" words before the functions
-that were reported in the "undefined reference" error
-messages.
-
- -
Recompile and reinstall libmemcache.
-
-
-
- Then, continue building Postfix by running 'make'.
+The Postfix memcache client has no external dependencies,
+and is therefore built into Postfix by default.
Configuring memcache lookup tables
@@ -102,11 +64,12 @@ messages.
Credits
- The first memcache client for Postfix was written by Omar Kilani.
+ The first memcache client for Postfix was written by Omar Kilani,
+and was based on the libmemcache library.
- Wietse wrote a new memcache client from the ground up. Besides
-also using libmemcache, the current implementation bears no resemblance
-to Omar's work.
+ Wietse wrote the current memcache client from the ground up.
+This implementation does not use libmemcache, and bears no resemblance
+to earlier work.