Postfix, Omar Kilani’s Memcache Patch Try-Out

I was rewrote Omar Kilani’s memcache patch couple of weeks ago. But that was not tested due to lack of time and unavailability of servers that can be used.

Now, i got chance to implement simple test. This is my configuration:
main.cf

smtpd_recipient_restrictions =
   ...
   ...
   check_recipient_access memcache:/etc/postfix/memcache.cf,
   ...
   ...

memcache.cf

servers = localhost:11211
key_format = %s

Entry on memcache

spam@example.com	REJECT	not allowed

Query using postmap

$ postmap -q "spam@example.com" memcache:/etc/postfix/memcache.cf
postmap: dict_memcache_lookup: using key_format '%s'
postmap: plmemcache_get: fetching key spam@example.com from memcache
postmap: plmemcache_get: key spam@example.com =>; REJECT not allowed
postmap: dict_memcache_lookup: spam@example.com returned REJECT not allowed
REJECT not allowed

A little bit too verbose i guess, but it can be adjusted by modifying source code.

Here’s non-verbose version postfix-memcache patch [download#42]
Test it on the fly:

220 mx.example.com ESMTP Postfix (2.9-20110706)
ehlo othermx.example.com
250-mx.example.com
250-PIPELINING
250-SIZE 52428800
250-ETRN
250-STARTTLS
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:<foo@example.com>;
250 2.1.0 Ok
rcpt to:<spam@example.com>;
554 5.7.1 <spam@example.com>;: Recipient address rejected: not allowed
quit
221 2.0.0 Bye
Connection closed by foreign host.

Logs:

Aug  9 09:49:59 fire postfix/smtpd[7860]: connect from unknown[xxx.xxx.xx.xxx]
Aug  9 09:50:34 fire postfix/smtpd[7860]: dict_memcache_lookup: using key_format '%s'
Aug  9 09:50:34 fire postfix/smtpd[7860]: plmemcache_get: fetching key spam@example.com from memcache
Aug  9 09:50:34 fire postfix/smtpd[7860]: plmemcache_get: key spam@example.com =>; REJECT not allowed
Aug  9 09:50:34 fire postfix/smtpd[7860]: dict_memcache_lookup: spam@example.com returned REJECT not allowed
Aug  9 09:50:34 fire postfix/smtpd[7860]: NOQUEUE: reject: RCPT from unknown[xxx.xxx.xx.xx] 554 5.7.1 <spam@example.com>;: Recipient address rejected: not allowed; from=<foo@example.com>; to=<spam@example.com>; proto=ESMTP helo=<othermx.example.com>;
Aug  9 09:50:37 fire postfix/smtpd[7860]: disconnect from unknown[xxx.xxx.xx.xx]

This is only a preliminary test, i’ve found bug that causing segmentation fault in memcache config file (need some fixes), but overall everything worked fine.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *