Ari Johnson. Code. |
|||
IntroductionThis page lets you download various things I have written and feel are worthy of some level of public use. I do not provide a warranty of any kind and I do not support any of this software (although any improvements you might make are always welcome). Most or all of the software here is distributed under some form of open-source license. Please see the actual software to determine what license you are granted in that particular piece of software. In each case, the license will be included either in a file named LICENSE distributed with the software or in a comment near the top of the file. Postfix Virtual FilterOne of the few things I missed when I changed my Postfix/Dovecot e-mail setup to use virtual domains was my Procmail and crm114 filtering and redirecting. Postfix does not offer any way out of the box to filter e-mail and send it to mailboxes other than your inbox when you are using virtual domains, and none of the existing solutions seemed all that good. That is why I wrote this replacement for the 'virtual(8)' local delivery agent provided by Postfix. I use a PostgreSQL database to define virtual domains, mailboxes, and aliases, so at present this program only supports the same. However, it would be very easy to expand it. Just look for the word 'pgsql' anywhere in the script and add a section for your database. The script uses the Postfix configuration files to get all its configuration information. You just have to tell it where 'postconf(1)' is located. The script itself is written in Ruby, and because it needs to be setuid there is a C program that does nothing but call the Ruby script. The script is called virtual_filter.rb and the wrapper is called virtual_filter_wrapper.c. To use the script, put it somewhere and make it executable. Edit the wrapper program to point to the correct location of the script (by default, it is /usr/local/sbin/virtual_filter.rb). Then, compile the wrapper (no special flags should be needed) and put it somewhere on your system (I keep it in /usr/local/sbin as well). Make the wrapper setuid and make sure the mail user can run it (chmod 4750 and chown root:mail). Finally, edit your Postfix configuration. Add a line at the end of master.cf: vfilter unix - n n - - pipe flags=DRhu user=mail argv=/usr/local/sbin/virtual_filter_wrapper -d ${recipient} -s /etc/postfix/delivery-script.rb Also, set virtual_transport = vfilter and vfilter_destination_recipient_limit = 1, both in main.cf. Restart postfix and it should be up and running. Note that the default action when no script is available is to deliver to the user's inbox, which is assumed to be in Maildir format (see line 235 of virtual_filter.rb). You can use mbox format by omitting the trailing slash from the delivery destination. As to writing a script, see my sample script delivery-script.rb. It filters mail below a certain size through crm114, logs various things about the message (in delivery.log in the user's top-level mail directory; this is configurable in virtual_filter.rb), and delivers it to .Spam/ or to ./ depending on the output of crm114. This script currently works with PostgreSQL and flatfile virtual domains. If you want to use MySQL or LDAP, it should not be too difficult to update the script to work with them. This script requires the following Ruby libraries: optparse and rfilter. If you use PostgreSQL to store your virtual domains and addresses, then you will need the dbi library and PostgreSQL driver for it, as well. Spam ProcessingAs described above, I use crm114 to filter my spam (I also use greylisting by way of Postgrey, but anything that sneaks past that gets filtered by crm114). I have the following maildirs relevant to this: . (INBOX), .Spam (where spam is placed), .Spam.False Negatives, and .Spam.False Positives. I then have the script process_spam.rb, which is run by a crontab under the root user account every minute. This script reads the Postfix configuration and, for every mailbox in every domain, it checks for messages that the user has placed in the False Negatives and False Positives folders. It runs them through the crm114 learning utility and then puts them into the inbox (for false positives) or the Spam folder (for false negatives). ALispSometimes, you need an embedded language in some other software. There are plenty of options out there, but sometimes it is nice to have a fairly minimal language that you can add things to as you see fit. ALisp is such a language, and its main selling point is that it is safe. That is, you can let someone write any ALisp code they want, and they will not be able to affect the system outside of ALisp unless you expressly provide them with the tools to do so. The actual purpose for which I wrote this lisp was to provide an embedded language for MUSH-based simulations. I wanted the users of the system to be able to control objects within the simulation without giving them access to anything that should be beyond their simulated control. ALisp is comes with a sample driver called repl.c and a Makefile to produce an executable of the same. The code should be mostly human readable, and it is written entirely in C. There is an interpreter and an optimizing bytecode compiler, the language is lexically scoped, and it even has lisp-style macros. It is also fairly portable. You can download the tarball alisp.tar.gz and experiment as you see fit. Alternatively, you can track development (which tends to be sporadic since the current code is considered mostly complete for the purposes that I wrote ALisp) using darcs. The repository is at http://theari.com/code/darcs/alisp/ |
|
||