A few years ago I implemented a new dict for
Postfix, dict_fnmatch.  It is a shell-style
pattern matcher with patterns placed _inline_,
right in the config file, without any additional
files like pcre/regex (the simplest dictionaries
which does not use indexed files) and others.

The usage is quite simple but perhaps somewhat
ugly:

check_client_access
  fnmatch:*.example.com|*.example.org:554\sGo\saway

This line sums it all up.  The format is:

  fnmatch:[!]pattern[|pattern...]:result

without spaces allowed (because postfix config
parser treats spaces as delimiters) but where
escapes like \s \n etc are recognized.

The good side of this ugliness is that it is
immediately visible what's going on, right when
reading main.cf, -- for short lists anyway.  It
is also a quick way to add something to the
configuration in case of emergency and the like.

It is like an extension for "static" map, but
quite flexible while at it.

Why I'm writing this email is because I installed
distribution-provided Postfix package a few days
ago to one of systems I maintain (before I always
used my own packages), and realized that I quite
used to use this dictionary type which is not
provided by the distribution and by the original
Postfix codebase.

So I thought I'd ask for people's opinion on this
stuff.

Sure it is possible to extend it to take /file/name
argument as usual, but the most important here is
the ability to inline some map contents right into
the config file.  But there, no "syntax sugar" for
you, because of the (quite simple) rules of the
parser.

Current code is available at
 http://www.corpit.ru/mjt/dict_fnmatch.tar.gz
it contains the two C files with implementation
in src/util/, and a shell script that will
patch the dict support into Postfix source
(adding stuff to appropriate Makefile and to
dict_open.c).

Thanks!

/mjt

Reply via email to