Forgot to mention: Need to add some parameters to the make Makefiles command, namely HAS_ODBC and the linking of the library with -lodbc, assuming the include files are in a standard location. make -f Makefile.init makefiles \ 'CCARGS=-DHAS_ODBC .... 'AUXLIBS=.... -lodbc ....'
-------- Original Message -------- Subject: [Code submission] Postfix ODBC supportDate: Sat, 26 Apr 2014 10:50:26 +0200From: John Fawcett <john...@erba.tv>To: Postfix users <postfix-users@postfix.org> I am submitting the attached code (patches to some existing files and two new files: dict_odbc.c and dict_odbc.h) which adds support for a new dictionary type that uses unixODBC (www.unixodbc.org). As noted in the past on this list, that could be useful in supporting map types that don't have native support. The code has been based on the dict_mysql. The main differences are that: - ODBC uses data source names instead of hostnames to connect to (I used the parameter name dsns) - ODBC supports only a few parameters like DSN name, username and password, the others like database name, server name etc are driver specific and not appropriate to include in a general implementation. I have added a parameter called add_con_params where anything driver specific can be added. Alternatively, many parameters can be setup in the odbc configuration itself (e.g. /etc/odbc.ini) - ODBC api does not have it's own quoting function - ODBC has some limitations about characters that can be used in the connection parameters. For sure the ; is a separator, so parameters that use it have to be enclosed in curly braces {}. For this reason usernames and passwords cannot begin or end with curly braces. Other characters may give problems depending on the driver. I have done some limited testing, but although I know of no problems it would probably be wise to consider this as non production code until it undergoes wider testing. I hope you may consider it for inclusion in postfix, but it may need some tidying up since I am not an expert in the use of vstring and may not always have chosen the most elegant way to accomplish things, though the base code from dict_mysql was an enormouse help. I updated the documentation in the source file. I imagine that other documentation like readme and odbc_table will be needed. I will look into that too. As a quick start, providing other parameters like hostname and database are configured in the dsn setup (e.g. /etc/odbc.ini), then the minimum postfix map configuration file may contain something like this: user = xxxxx password = yyyyyyyyy dsns = postfix query = SELECT domain FROM domain WHERE transport='virtual' and domain='%s' and active=1 Hope the files make it through the list ok. If not I'll publish them somewhere. John