1 /* $Cambridge: exim/src/src/drtables.c,v 1.9 2007/09/28 12:21:57 tom Exp $ */
3 /*************************************************
4 * Exim - an Internet mail transport agent *
5 *************************************************/
7 /* Copyright (c) University of Cambridge 1995 - 2007 */
8 /* See the file NOTICE for conditions of use and distribution. */
14 /* This module contains tables that define the lookup methods and drivers
15 that are actually included in the binary. Its contents are controlled by
16 various macros in config.h that ultimately come from Local/Makefile. They are
17 all described in src/EDITME. */
20 /* The OSF1 (Digital Unix) linker puts out a worrying warning if any sections
21 contain no executable code. It says
23 Warning: Linking some objects which contain exception information sections
24 and some which do not. This may cause fatal runtime exception handling
27 As this may cause people to worry needlessly, include a dummy function here
28 to stop the message from appearing. Make it call itself to stop picky compilers
29 compilers complaining that it is unused, and put in a dummy argument to stop
30 even pickier compilers complaining about infinite loops. */
32 static void dummy(int x) { dummy(x-1); }
35 /* Table of information about all possible lookup methods. The entries are
36 always present, but the "open" and "find" functions are set to NULL for those
37 that are not compiled into the binary. The "check" and "close" functions can
38 be NULL for methods that don't need them. */
41 #include "lookups/cdb.h"
45 #include "lookups/dbmdb.h"
49 #include "lookups/dnsdb.h"
53 #include "lookups/dsearch.h"
57 #include "lookups/ibase.h"
61 #include "lookups/ldap.h"
65 #include "lookups/lsearch.h"
69 #include "lookups/mysql.h"
73 #include "lookups/nis.h"
77 #include "lookups/nisplus.h"
81 #include "lookups/oracle.h"
85 #include "lookups/passwd.h"
89 #include "lookups/pgsql.h"
92 #ifdef EXPERIMENTAL_SPF
93 #include "lookups/spf.h"
97 #include "lookups/sqlite.h"
101 #include "lookups/testdb.h"
105 #include "lookups/whoson.h"
108 #ifdef EXPERIMENTAL_DKIM
109 #include "lookups/dkim.h"
113 /* The second field in each item below is a set of bit flags:
115 lookup_querystyle => this is a query-style lookup,
116 else single-key (+ file) style
117 lookup_absfile => an absolute file name is required,
118 (for single-key style only)
120 This list must be in alphabetical order of lookup name because it is
121 searched by binary chop, having got rather large for the original linear
124 lookup_info lookup_list[] = {
126 /* cdb lookup in single file */
129 US"cdb", /* lookup name */
130 lookup_absfile, /* uses absolute file name */
132 cdb_open, /* open function */
133 cdb_check, /* check function */
134 cdb_find, /* find function */
135 cdb_close, /* close function */
136 NULL, /* no tidy function */
137 NULL /* no quoting function */
139 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
143 /* DBM file lookup; called "dbm" because that is the name in Exim,
144 but the code is called dbmdb to avoid name clashes. */
147 US"dbm", /* lookup name */
148 lookup_absfile, /* uses absolute file name */
150 dbmdb_open, /* open function */
151 dbmdb_check, /* check function */
152 dbmdb_find, /* find function */
153 dbmdb_close, /* close function */
154 NULL, /* no tidy function */
155 NULL /* no quoting function */
157 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
161 /* This variant of DBM does not include the binary zero on the end
162 of the key strings. */
165 US"dbmnz", /* lookup name */
166 lookup_absfile, /* uses absolute file name */
168 dbmdb_open, /* sic */ /* open function */
169 dbmdb_check, /* sic */ /* check function */
170 dbmnz_find, /* find function */
171 dbmdb_close, /* sic */ /* close function */
172 NULL, /* no tidy function */
173 NULL /* no quoting function */
175 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
182 US"dkim", /* lookup name */
183 lookup_querystyle, /* query style */
184 #ifdef EXPERIMENTAL_DKIM
185 dkim_open, /* open function */
186 NULL, /* check function */
187 dkim_find, /* find function */
188 NULL, /* no close function */
189 NULL, /* no tidy function */
190 NULL /* no quoting function */
192 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
196 /* Using DNS TXT records as a database */
199 US"dnsdb", /* lookup name */
200 lookup_querystyle, /* query style */
202 dnsdb_open, /* open function */
203 NULL, /* check function */
204 dnsdb_find, /* find function */
205 NULL, /* no close function */
206 NULL, /* no tidy function */
207 NULL /* no quoting function */
209 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
213 /* Search of files in a directory */
216 US"dsearch", /* lookup name */
217 lookup_absfile, /* uses absolute file name */
218 #ifdef LOOKUP_DSEARCH
219 dsearch_open, /* open function */
220 dsearch_check, /* check function */
221 dsearch_find, /* find function */
222 dsearch_close, /* close function */
223 NULL, /* no tidy function */
224 NULL /* no quoting function */
226 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
230 /* Interbase lookup */
233 US"ibase", /* lookup name */
234 lookup_querystyle, /* query-style lookup */
236 ibase_open, /* open function */
237 NULL, /* no check function */
238 ibase_find, /* find function */
239 NULL, /* no close function */
240 ibase_tidy, /* tidy function */
241 ibase_quote /* quoting function */
243 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
247 /* Linear search of single file with ip-addresses and networks; shares many
248 functions with lsearch. */
251 US"iplsearch", /* lookup name */
252 lookup_absfile, /* uses absolute file name */
253 #ifdef LOOKUP_LSEARCH
254 lsearch_open, /* open function */
255 lsearch_check, /* check function */
256 iplsearch_find, /* find function */
257 lsearch_close, /* close function */
258 NULL, /* no tidy function */
259 NULL /* no quoting function */
261 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
265 /* LDAP lookup, allowing data from only one entry to be returned */
268 US"ldap", /* lookup name */
269 lookup_querystyle, /* query-style lookup */
271 eldap_open, /* open function */
272 NULL, /* check function */
273 eldap_find, /* find function */
274 NULL, /* no close function */
275 eldap_tidy, /* tidy function */
276 eldap_quote /* quoting function */
278 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
282 /* LDAP lookup, allowing the DN from more one entry to be returned */
285 US"ldapdn", /* lookup name */
286 lookup_querystyle, /* query-style lookup */
288 eldap_open, /* sic */ /* open function */
289 NULL, /* check function */
290 eldapdn_find, /* find function */
291 NULL, /* no close function */
292 eldap_tidy, /* sic */ /* tidy function */
293 eldap_quote /* sic */ /* quoting function */
295 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
299 /* LDAP lookup, allowing data from more than one entry to be returned */
302 US"ldapm", /* lookup name */
303 lookup_querystyle, /* query-style lookup */
305 eldap_open, /* sic */ /* open function */
306 NULL, /* check function */
307 eldapm_find, /* find function */
308 NULL, /* no close function */
309 eldap_tidy, /* sic */ /* tidy function */
310 eldap_quote /* sic */ /* quoting function */
312 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
316 /* Linear search of single file */
319 US"lsearch", /* lookup name */
320 lookup_absfile, /* uses absolute file name */
321 #ifdef LOOKUP_LSEARCH
322 lsearch_open, /* open function */
323 lsearch_check, /* check function */
324 lsearch_find, /* find function */
325 lsearch_close, /* close function */
326 NULL, /* no tidy function */
327 NULL /* no quoting function */
329 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
336 US"mysql", /* lookup name */
337 lookup_querystyle, /* query-style lookup */
339 mysql_open, /* open function */
340 NULL, /* no check function */
341 mysql_find, /* find function */
342 NULL, /* no close function */
343 mysql_tidy, /* tidy function */
344 mysql_quote /* quoting function */
346 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
350 /* NIS lookup, excluding trailing 0 from key */
353 US"nis", /* lookup name */
354 0, /* not abs file, not query style*/
356 nis_open, /* open function */
357 NULL, /* check function */
358 nis_find, /* find function */
359 NULL, /* no close function */
360 NULL, /* no tidy function */
361 NULL /* no quoting function */
363 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
367 /* NIS lookup, including trailing 0 in key */
370 US"nis0", /* lookup name */
371 0, /* not absfile, not query style */
373 nis_open, /* sic */ /* open function */
374 NULL, /* check function */
375 nis0_find, /* find function */
376 NULL, /* no close function */
377 NULL, /* no tidy function */
378 NULL /* no quoting function */
380 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
387 US"nisplus", /* lookup name */
388 lookup_querystyle, /* query-style lookup */
389 #ifdef LOOKUP_NISPLUS
390 nisplus_open, /* open function */
391 NULL, /* check function */
392 nisplus_find, /* find function */
393 NULL, /* no close function */
394 NULL, /* no tidy function */
395 nisplus_quote /* quoting function */
397 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
401 /* Linear search of single file, with wildcarding but no pattern expansion.
402 Shares many functions with lsearch. */
405 US"nwildlsearch", /* lookup name */
406 lookup_absfile, /* uses absolute file name */
407 #ifdef LOOKUP_LSEARCH
408 lsearch_open, /* open function */
409 lsearch_check, /* check function */
410 nwildlsearch_find, /* find function */
411 lsearch_close, /* close function */
412 NULL, /* no tidy function */
413 NULL /* no quoting function */
415 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
422 US"oracle", /* lookup name */
423 lookup_querystyle, /* query-style lookup */
425 oracle_open, /* open function */
426 NULL, /* check function */
427 oracle_find, /* find function */
428 NULL, /* no close function */
429 oracle_tidy, /* tidy function */
430 oracle_quote /* quoting function */
432 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
439 US"passwd", /* lookup name */
440 lookup_querystyle, /* query-style lookup */
442 passwd_open, /* open function */
443 NULL, /* no check function */
444 passwd_find, /* find function */
445 NULL, /* no close function */
446 NULL, /* no tidy function */
447 NULL /* no quoting function */
449 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
456 US"pgsql", /* lookup name */
457 lookup_querystyle, /* query-style lookup */
459 pgsql_open, /* open function */
460 NULL, /* no check function */
461 pgsql_find, /* find function */
462 NULL, /* no close function */
463 pgsql_tidy, /* tidy function */
464 pgsql_quote /* quoting function */
466 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
473 US"spf", /* lookup name */
474 0, /* not absfile, not query style */
475 #ifdef EXPERIMENTAL_SPF
476 spf_open, /* open function */
477 NULL, /* no check function */
478 spf_find, /* find function */
479 spf_close, /* close function */
480 NULL, /* no tidy function */
481 NULL /* no quoting function */
483 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
490 US"sqlite", /* lookup name */
491 lookup_absfilequery, /* query-style lookup, starts with file name */
493 sqlite_open, /* open function */
494 NULL, /* no check function */
495 sqlite_find, /* find function */
496 sqlite_close, /* close function */
497 NULL, /* no tidy function */
498 sqlite_quote /* quoting function */
500 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
504 /* Testdb lookup is for testing Exim, not useful for normal running.
505 For that reason, we omit the entry entirely when not building it into
506 the binary, so that attempts to use it give "unknown lookup type" instead
507 of "lookup type not available". */
511 US"testdb", /* lookup name */
512 lookup_querystyle, /* query-style lookup */
513 testdb_open, /* open function */
514 NULL, /* check function */
515 testdb_find, /* find function */
516 NULL, /* no close function */
517 NULL, /* no tidy function */
518 NULL /* no quoting function */
522 /* "Whoson" lookup */
525 US"whoson", /* lookup name */
526 lookup_querystyle, /* query-style lookup */
528 whoson_open, /* open function */
529 NULL, /* check function */
530 whoson_find, /* find function */
531 NULL, /* no close function */
532 NULL, /* no tidy function */
533 NULL /* no quoting function */
535 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
539 /* Linear search of single file, with wildcarding and pattern expansion. Shares
540 many functions with lsearch. */
543 US"wildlsearch", /* lookup name */
544 lookup_absfile, /* uses absolute file name */
545 #ifdef LOOKUP_LSEARCH
546 lsearch_open, /* open function */
547 lsearch_check, /* check function */
548 wildlsearch_find, /* find function */
549 lsearch_close, /* close function */
550 NULL, /* no tidy function */
551 NULL /* no quoting function */
553 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
558 /* Number of entries in the list */
560 int lookup_list_count = sizeof(lookup_list)/sizeof(lookup_info);
564 /* Table of information about all possible authentication mechamisms. All
565 entries are always present if any mechanism is declared, but the functions are
566 set to NULL for those that are not compiled into the binary. */
569 #include "auths/cram_md5.h"
572 #ifdef AUTH_CYRUS_SASL
573 #include "auths/cyrus_sasl.h"
577 #include "auths/dovecot.h"
580 #ifdef AUTH_PLAINTEXT
581 #include "auths/plaintext.h"
585 #include "auths/spa.h"
588 auth_info auths_available[] = {
590 /* Checking by an expansion condition on plain text */
594 US"cram_md5", /* lookup name */
595 auth_cram_md5_options,
596 &auth_cram_md5_options_count,
597 &auth_cram_md5_option_defaults,
598 sizeof(auth_cram_md5_options_block),
599 auth_cram_md5_init, /* init function */
600 auth_cram_md5_server, /* server function */
601 auth_cram_md5_client /* client function */
605 #ifdef AUTH_CYRUS_SASL
607 US"cyrus_sasl", /* lookup name */
608 auth_cyrus_sasl_options,
609 &auth_cyrus_sasl_options_count,
610 &auth_cyrus_sasl_option_defaults,
611 sizeof(auth_cyrus_sasl_options_block),
612 auth_cyrus_sasl_init, /* init function */
613 auth_cyrus_sasl_server, /* server function */
614 NULL /* client function */
620 US"dovecot", /* lookup name */
621 auth_dovecot_options,
622 &auth_dovecot_options_count,
623 &auth_dovecot_option_defaults,
624 sizeof(auth_dovecot_options_block),
625 auth_dovecot_init, /* init function */
626 auth_dovecot_server, /* server function */
627 NULL /* client function */
631 #ifdef AUTH_PLAINTEXT
633 US"plaintext", /* lookup name */
634 auth_plaintext_options,
635 &auth_plaintext_options_count,
636 &auth_plaintext_option_defaults,
637 sizeof(auth_plaintext_options_block),
638 auth_plaintext_init, /* init function */
639 auth_plaintext_server, /* server function */
640 auth_plaintext_client /* client function */
646 US"spa", /* lookup name */
648 &auth_spa_options_count,
649 &auth_spa_option_defaults,
650 sizeof(auth_spa_options_block),
651 auth_spa_init, /* init function */
652 auth_spa_server, /* server function */
653 auth_spa_client /* client function */
657 { US"", NULL, NULL, NULL, 0, NULL, NULL, NULL }
661 /* Tables of information about which routers and transports are included in the
664 /* Pull in the necessary header files */
666 #include "routers/rf_functions.h"
669 #include "routers/accept.h"
672 #ifdef ROUTER_DNSLOOKUP
673 #include "routers/dnslookup.h"
676 #ifdef ROUTER_MANUALROUTE
677 #include "routers/manualroute.h"
680 #ifdef ROUTER_IPLITERAL
681 #include "routers/ipliteral.h"
684 #ifdef ROUTER_IPLOOKUP
685 #include "routers/iplookup.h"
688 #ifdef ROUTER_QUERYPROGRAM
689 #include "routers/queryprogram.h"
692 #ifdef ROUTER_REDIRECT
693 #include "routers/redirect.h"
696 #ifdef TRANSPORT_APPENDFILE
697 #include "transports/appendfile.h"
700 #ifdef TRANSPORT_AUTOREPLY
701 #include "transports/autoreply.h"
704 #ifdef TRANSPORT_LMTP
705 #include "transports/lmtp.h"
708 #ifdef TRANSPORT_PIPE
709 #include "transports/pipe.h"
712 #ifdef TRANSPORT_SMTP
713 #include "transports/smtp.h"
717 /* Now set up the structures, terminated by an entry with a null name. */
719 router_info routers_available[] = {
723 accept_router_options,
724 &accept_router_options_count,
725 &accept_router_option_defaults,
726 sizeof(accept_router_options_block),
729 NULL, /* no tidyup entry */
733 #ifdef ROUTER_DNSLOOKUP
736 dnslookup_router_options,
737 &dnslookup_router_options_count,
738 &dnslookup_router_option_defaults,
739 sizeof(dnslookup_router_options_block),
740 dnslookup_router_init,
741 dnslookup_router_entry,
742 NULL, /* no tidyup entry */
746 #ifdef ROUTER_IPLITERAL
749 ipliteral_router_options,
750 &ipliteral_router_options_count,
751 &ipliteral_router_option_defaults,
752 sizeof(ipliteral_router_options_block),
753 ipliteral_router_init,
754 ipliteral_router_entry,
755 NULL, /* no tidyup entry */
759 #ifdef ROUTER_IPLOOKUP
762 iplookup_router_options,
763 &iplookup_router_options_count,
764 &iplookup_router_option_defaults,
765 sizeof(iplookup_router_options_block),
766 iplookup_router_init,
767 iplookup_router_entry,
768 NULL, /* no tidyup entry */
772 #ifdef ROUTER_MANUALROUTE
775 manualroute_router_options,
776 &manualroute_router_options_count,
777 &manualroute_router_option_defaults,
778 sizeof(manualroute_router_options_block),
779 manualroute_router_init,
780 manualroute_router_entry,
781 NULL, /* no tidyup entry */
785 #ifdef ROUTER_QUERYPROGRAM
788 queryprogram_router_options,
789 &queryprogram_router_options_count,
790 &queryprogram_router_option_defaults,
791 sizeof(queryprogram_router_options_block),
792 queryprogram_router_init,
793 queryprogram_router_entry,
794 NULL, /* no tidyup entry */
798 #ifdef ROUTER_REDIRECT
801 redirect_router_options,
802 &redirect_router_options_count,
803 &redirect_router_option_defaults,
804 sizeof(redirect_router_options_block),
805 redirect_router_init,
806 redirect_router_entry,
807 NULL, /* no tidyup entry */
811 { US"", NULL, NULL, NULL, 0, NULL, NULL, NULL, 0 }
816 transport_info transports_available[] = {
817 #ifdef TRANSPORT_APPENDFILE
819 US"appendfile", /* driver name */
820 appendfile_transport_options, /* local options table */
821 &appendfile_transport_options_count, /* number of entries */
822 &appendfile_transport_option_defaults, /* private options defaults */
823 sizeof(appendfile_transport_options_block), /* size of private block */
824 appendfile_transport_init, /* init entry point */
825 appendfile_transport_entry, /* main entry point */
826 NULL, /* no tidyup entry */
827 NULL, /* no closedown entry */
828 TRUE, /* local flag */
831 #ifdef TRANSPORT_AUTOREPLY
833 US"autoreply", /* driver name */
834 autoreply_transport_options, /* local options table */
835 &autoreply_transport_options_count, /* number of entries */
836 &autoreply_transport_option_defaults, /* private options defaults */
837 sizeof(autoreply_transport_options_block), /* size of private block */
838 autoreply_transport_init, /* init entry point */
839 autoreply_transport_entry, /* main entry point */
840 NULL, /* no tidyup entry */
841 NULL, /* no closedown entry */
842 TRUE /* local flag */
845 #ifdef TRANSPORT_LMTP
847 US"lmtp", /* driver name */
848 lmtp_transport_options, /* local options table */
849 &lmtp_transport_options_count, /* number of entries */
850 &lmtp_transport_option_defaults, /* private options defaults */
851 sizeof(lmtp_transport_options_block), /* size of private block */
852 lmtp_transport_init, /* init entry point */
853 lmtp_transport_entry, /* main entry point */
854 NULL, /* no tidyup entry */
855 NULL, /* no closedown entry */
856 TRUE /* local flag */
859 #ifdef TRANSPORT_PIPE
861 US"pipe", /* driver name */
862 pipe_transport_options, /* local options table */
863 &pipe_transport_options_count, /* number of entries */
864 &pipe_transport_option_defaults, /* private options defaults */
865 sizeof(pipe_transport_options_block), /* size of private block */
866 pipe_transport_init, /* init entry point */
867 pipe_transport_entry, /* main entry point */
868 NULL, /* no tidyup entry */
869 NULL, /* no closedown entry */
870 TRUE /* local flag */
873 #ifdef TRANSPORT_SMTP
875 US"smtp", /* driver name */
876 smtp_transport_options, /* local options table */
877 &smtp_transport_options_count, /* number of entries */
878 &smtp_transport_option_defaults, /* private options defaults */
879 sizeof(smtp_transport_options_block), /* size of private block */
880 smtp_transport_init, /* init entry point */
881 smtp_transport_entry, /* main entry point */
882 NULL, /* no tidyup entry */
883 smtp_transport_closedown, /* close down passed channel */
884 FALSE /* local flag */
887 { US"", NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, FALSE }
890 /* End of drtables.c */