1 /* $Cambridge: exim/src/src/drtables.c,v 1.5 2005/08/01 13:20:28 ph10 Exp $ */
3 /*************************************************
4 * Exim - an Internet mail transport agent *
5 *************************************************/
7 /* Copyright (c) University of Cambridge 1995 - 2005 */
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 /* The second field in each item below is a set of bit flags:
110 lookup_querystyle => this is a query-style lookup,
111 else single-key (+ file) style
112 lookup_absfile => an absolute file name is required,
113 (for single-key style only)
115 This list must be in alphabetical order of lookup name because it is
116 searched by binary chop, having got rather large for the original linear
119 lookup_info lookup_list[] = {
121 /* cdb lookup in single file */
124 US"cdb", /* lookup name */
125 lookup_absfile, /* uses absolute file name */
127 cdb_open, /* open function */
128 cdb_check, /* check function */
129 cdb_find, /* find function */
130 cdb_close, /* close function */
131 NULL, /* no tidy function */
132 NULL /* no quoting function */
134 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
138 /* DBM file lookup; called "dbm" because that is the name in Exim,
139 but the code is called dbmdb to avoid name clashes. */
142 US"dbm", /* lookup name */
143 lookup_absfile, /* uses absolute file name */
145 dbmdb_open, /* open function */
146 dbmdb_check, /* check function */
147 dbmdb_find, /* find function */
148 dbmdb_close, /* close function */
149 NULL, /* no tidy function */
150 NULL /* no quoting function */
152 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
156 /* This variant of DBM does not include the binary zero on the end
157 of the key strings. */
160 US"dbmnz", /* lookup name */
161 lookup_absfile, /* uses absolute file name */
163 dbmdb_open, /* sic */ /* open function */
164 dbmdb_check, /* sic */ /* check function */
165 dbmnz_find, /* find function */
166 dbmdb_close, /* sic */ /* close function */
167 NULL, /* no tidy function */
168 NULL /* no quoting function */
170 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
174 /* Using DNS TXT records as a database */
177 US"dnsdb", /* lookup name */
178 lookup_querystyle, /* query style */
180 dnsdb_open, /* open function */
181 NULL, /* check function */
182 dnsdb_find, /* find function */
183 NULL, /* no close function */
184 NULL, /* no tidy function */
185 NULL /* no quoting function */
187 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
191 /* Search of files in a directory */
194 US"dsearch", /* lookup name */
195 lookup_absfile, /* uses absolute file name */
196 #ifdef LOOKUP_DSEARCH
197 dsearch_open, /* open function */
198 dsearch_check, /* check function */
199 dsearch_find, /* find function */
200 dsearch_close, /* close function */
201 NULL, /* no tidy function */
202 NULL /* no quoting function */
204 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
208 /* Interbase lookup */
211 US"ibase", /* lookup name */
212 lookup_querystyle, /* query-style lookup */
214 ibase_open, /* open function */
215 NULL, /* no check function */
216 ibase_find, /* find function */
217 NULL, /* no close function */
218 ibase_tidy, /* tidy function */
219 ibase_quote /* quoting function */
221 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
225 /* Linear search of single file with ip-addresses and networks; shares many
226 functions with lsearch. */
229 US"iplsearch", /* lookup name */
230 lookup_absfile, /* uses absolute file name */
231 #ifdef LOOKUP_LSEARCH
232 lsearch_open, /* open function */
233 lsearch_check, /* check function */
234 iplsearch_find, /* find function */
235 lsearch_close, /* close function */
236 NULL, /* no tidy function */
237 NULL /* no quoting function */
239 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
243 /* LDAP lookup, allowing data from only one entry to be returned */
246 US"ldap", /* lookup name */
247 lookup_querystyle, /* query-style lookup */
249 eldap_open, /* open function */
250 NULL, /* check function */
251 eldap_find, /* find function */
252 NULL, /* no close function */
253 eldap_tidy, /* tidy function */
254 eldap_quote /* quoting function */
256 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
260 /* LDAP lookup, allowing the DN from more one entry to be returned */
263 US"ldapdn", /* lookup name */
264 lookup_querystyle, /* query-style lookup */
266 eldap_open, /* sic */ /* open function */
267 NULL, /* check function */
268 eldapdn_find, /* find function */
269 NULL, /* no close function */
270 eldap_tidy, /* sic */ /* tidy function */
271 eldap_quote /* sic */ /* quoting function */
273 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
277 /* LDAP lookup, allowing data from more than one entry to be returned */
280 US"ldapm", /* lookup name */
281 lookup_querystyle, /* query-style lookup */
283 eldap_open, /* sic */ /* open function */
284 NULL, /* check function */
285 eldapm_find, /* find function */
286 NULL, /* no close function */
287 eldap_tidy, /* sic */ /* tidy function */
288 eldap_quote /* sic */ /* quoting function */
290 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
294 /* Linear search of single file */
297 US"lsearch", /* lookup name */
298 lookup_absfile, /* uses absolute file name */
299 #ifdef LOOKUP_LSEARCH
300 lsearch_open, /* open function */
301 lsearch_check, /* check function */
302 lsearch_find, /* find function */
303 lsearch_close, /* close function */
304 NULL, /* no tidy function */
305 NULL /* no quoting function */
307 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
314 US"mysql", /* lookup name */
315 lookup_querystyle, /* query-style lookup */
317 mysql_open, /* open function */
318 NULL, /* no check function */
319 mysql_find, /* find function */
320 NULL, /* no close function */
321 mysql_tidy, /* tidy function */
322 mysql_quote /* quoting function */
324 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
328 /* NIS lookup, excluding trailing 0 from key */
331 US"nis", /* lookup name */
332 0, /* not abs file, not query style*/
334 nis_open, /* open function */
335 NULL, /* check function */
336 nis_find, /* find function */
337 NULL, /* no close function */
338 NULL, /* no tidy function */
339 NULL /* no quoting function */
341 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
345 /* NIS lookup, including trailing 0 in key */
348 US"nis0", /* lookup name */
349 0, /* not absfile, not query style */
351 nis_open, /* sic */ /* open function */
352 NULL, /* check function */
353 nis0_find, /* find function */
354 NULL, /* no close function */
355 NULL, /* no tidy function */
356 NULL /* no quoting function */
358 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
365 US"nisplus", /* lookup name */
366 lookup_querystyle, /* query-style lookup */
367 #ifdef LOOKUP_NISPLUS
368 nisplus_open, /* open function */
369 NULL, /* check function */
370 nisplus_find, /* find function */
371 NULL, /* no close function */
372 NULL, /* no tidy function */
373 nisplus_quote /* quoting function */
375 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
379 /* Linear search of single file, with wildcarding but no pattern expansion.
380 Shares many functions with lsearch. */
383 US"nwildlsearch", /* lookup name */
384 lookup_absfile, /* uses absolute file name */
385 #ifdef LOOKUP_LSEARCH
386 lsearch_open, /* open function */
387 lsearch_check, /* check function */
388 nwildlsearch_find, /* find function */
389 lsearch_close, /* close function */
390 NULL, /* no tidy function */
391 NULL /* no quoting function */
393 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
400 US"oracle", /* lookup name */
401 lookup_querystyle, /* query-style lookup */
403 oracle_open, /* open function */
404 NULL, /* check function */
405 oracle_find, /* find function */
406 NULL, /* no close function */
407 oracle_tidy, /* tidy function */
408 oracle_quote /* quoting function */
410 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
417 US"passwd", /* lookup name */
418 lookup_querystyle, /* query-style lookup */
420 passwd_open, /* open function */
421 NULL, /* no check function */
422 passwd_find, /* find function */
423 NULL, /* no close function */
424 NULL, /* no tidy function */
425 NULL /* no quoting function */
427 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
434 US"pgsql", /* lookup name */
435 lookup_querystyle, /* query-style lookup */
437 pgsql_open, /* open function */
438 NULL, /* no check function */
439 pgsql_find, /* find function */
440 NULL, /* no close function */
441 pgsql_tidy, /* tidy function */
442 pgsql_quote /* quoting function */
444 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
451 US"spf", /* lookup name */
452 0, /* not absfile, not query style */
453 #ifdef EXPERIMENTAL_SPF
454 spf_open, /* open function */
455 NULL, /* no check function */
456 spf_find, /* find function */
457 spf_close, /* close function */
458 NULL, /* no tidy function */
459 NULL /* no quoting function */
461 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
468 US"sqlite", /* lookup name */
469 lookup_absfilequery, /* query-style lookup, starts with file name */
471 sqlite_open, /* open function */
472 NULL, /* no check function */
473 sqlite_find, /* find function */
474 sqlite_close, /* close function */
475 NULL, /* no tidy function */
476 sqlite_quote /* quoting function */
478 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
482 /* Testdb lookup is for testing Exim, not useful for normal running.
483 For that reason, we omit the entry entirely when not building it into
484 the binary, so that attempts to use it give "unknown lookup type" instead
485 of "lookup type not available". */
489 US"testdb", /* lookup name */
490 lookup_querystyle, /* query-style lookup */
491 testdb_open, /* open function */
492 NULL, /* check function */
493 testdb_find, /* find function */
494 NULL, /* no close function */
495 NULL, /* no tidy function */
496 NULL /* no quoting function */
500 /* "Whoson" lookup */
503 US"whoson", /* lookup name */
504 lookup_querystyle, /* query-style lookup */
506 whoson_open, /* open function */
507 NULL, /* check function */
508 whoson_find, /* find function */
509 NULL, /* no close function */
510 NULL, /* no tidy function */
511 NULL /* no quoting function */
513 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
517 /* Linear search of single file, with wildcarding and pattern expansion. Shares
518 many functions with lsearch. */
521 US"wildlsearch", /* lookup name */
522 lookup_absfile, /* uses absolute file name */
523 #ifdef LOOKUP_LSEARCH
524 lsearch_open, /* open function */
525 lsearch_check, /* check function */
526 wildlsearch_find, /* find function */
527 lsearch_close, /* close function */
528 NULL, /* no tidy function */
529 NULL /* no quoting function */
531 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
536 /* Number of entries in the list */
538 int lookup_list_count = sizeof(lookup_list)/sizeof(lookup_info);
542 /* Table of information about all possible authentication mechamisms. All
543 entries are always present if any mechanism is declared, but the functions are
544 set to NULL for those that are not compiled into the binary. */
547 #include "auths/cram_md5.h"
550 #ifdef AUTH_CYRUS_SASL
551 #include "auths/cyrus_sasl.h"
554 #ifdef AUTH_PLAINTEXT
555 #include "auths/plaintext.h"
559 #include "auths/spa.h"
562 auth_info auths_available[] = {
564 /* Checking by an expansion condition on plain text */
568 US"cram_md5", /* lookup name */
569 auth_cram_md5_options,
570 &auth_cram_md5_options_count,
571 &auth_cram_md5_option_defaults,
572 sizeof(auth_cram_md5_options_block),
573 auth_cram_md5_init, /* init function */
574 auth_cram_md5_server, /* server function */
575 auth_cram_md5_client /* client function */
579 #ifdef AUTH_CYRUS_SASL
581 US"cyrus_sasl", /* lookup name */
582 auth_cyrus_sasl_options,
583 &auth_cyrus_sasl_options_count,
584 &auth_cyrus_sasl_option_defaults,
585 sizeof(auth_cyrus_sasl_options_block),
586 auth_cyrus_sasl_init, /* init function */
587 auth_cyrus_sasl_server, /* server function */
588 NULL /* client function */
592 #ifdef AUTH_PLAINTEXT
594 US"plaintext", /* lookup name */
595 auth_plaintext_options,
596 &auth_plaintext_options_count,
597 &auth_plaintext_option_defaults,
598 sizeof(auth_plaintext_options_block),
599 auth_plaintext_init, /* init function */
600 auth_plaintext_server, /* server function */
601 auth_plaintext_client /* client function */
607 US"spa", /* lookup name */
609 &auth_spa_options_count,
610 &auth_spa_option_defaults,
611 sizeof(auth_spa_options_block),
612 auth_spa_init, /* init function */
613 auth_spa_server, /* server function */
614 auth_spa_client /* client function */
618 { US"", NULL, NULL, NULL, 0, NULL, NULL, NULL }
622 /* Tables of information about which routers and transports are included in the
625 /* Pull in the necessary header files */
627 #include "routers/rf_functions.h"
630 #include "routers/accept.h"
633 #ifdef ROUTER_DNSLOOKUP
634 #include "routers/dnslookup.h"
637 #ifdef ROUTER_MANUALROUTE
638 #include "routers/manualroute.h"
641 #ifdef ROUTER_IPLITERAL
642 #include "routers/ipliteral.h"
645 #ifdef ROUTER_IPLOOKUP
646 #include "routers/iplookup.h"
649 #ifdef ROUTER_QUERYPROGRAM
650 #include "routers/queryprogram.h"
653 #ifdef ROUTER_REDIRECT
654 #include "routers/redirect.h"
657 #ifdef TRANSPORT_APPENDFILE
658 #include "transports/appendfile.h"
661 #ifdef TRANSPORT_AUTOREPLY
662 #include "transports/autoreply.h"
665 #ifdef TRANSPORT_LMTP
666 #include "transports/lmtp.h"
669 #ifdef TRANSPORT_PIPE
670 #include "transports/pipe.h"
673 #ifdef TRANSPORT_SMTP
674 #include "transports/smtp.h"
678 /* Now set up the structures, terminated by an entry with a null name. */
680 router_info routers_available[] = {
684 accept_router_options,
685 &accept_router_options_count,
686 &accept_router_option_defaults,
687 sizeof(accept_router_options_block),
690 NULL, /* no tidyup entry */
694 #ifdef ROUTER_DNSLOOKUP
697 dnslookup_router_options,
698 &dnslookup_router_options_count,
699 &dnslookup_router_option_defaults,
700 sizeof(dnslookup_router_options_block),
701 dnslookup_router_init,
702 dnslookup_router_entry,
703 NULL, /* no tidyup entry */
707 #ifdef ROUTER_IPLITERAL
710 ipliteral_router_options,
711 &ipliteral_router_options_count,
712 &ipliteral_router_option_defaults,
713 sizeof(ipliteral_router_options_block),
714 ipliteral_router_init,
715 ipliteral_router_entry,
716 NULL, /* no tidyup entry */
720 #ifdef ROUTER_IPLOOKUP
723 iplookup_router_options,
724 &iplookup_router_options_count,
725 &iplookup_router_option_defaults,
726 sizeof(iplookup_router_options_block),
727 iplookup_router_init,
728 iplookup_router_entry,
729 NULL, /* no tidyup entry */
733 #ifdef ROUTER_MANUALROUTE
736 manualroute_router_options,
737 &manualroute_router_options_count,
738 &manualroute_router_option_defaults,
739 sizeof(manualroute_router_options_block),
740 manualroute_router_init,
741 manualroute_router_entry,
742 NULL, /* no tidyup entry */
746 #ifdef ROUTER_QUERYPROGRAM
749 queryprogram_router_options,
750 &queryprogram_router_options_count,
751 &queryprogram_router_option_defaults,
752 sizeof(queryprogram_router_options_block),
753 queryprogram_router_init,
754 queryprogram_router_entry,
755 NULL, /* no tidyup entry */
759 #ifdef ROUTER_REDIRECT
762 redirect_router_options,
763 &redirect_router_options_count,
764 &redirect_router_option_defaults,
765 sizeof(redirect_router_options_block),
766 redirect_router_init,
767 redirect_router_entry,
768 NULL, /* no tidyup entry */
772 { US"", NULL, NULL, NULL, 0, NULL, NULL, NULL, 0 }
777 transport_info transports_available[] = {
778 #ifdef TRANSPORT_APPENDFILE
780 US"appendfile", /* driver name */
781 appendfile_transport_options, /* local options table */
782 &appendfile_transport_options_count, /* number of entries */
783 &appendfile_transport_option_defaults, /* private options defaults */
784 sizeof(appendfile_transport_options_block), /* size of private block */
785 appendfile_transport_init, /* init entry point */
786 appendfile_transport_entry, /* main entry point */
787 NULL, /* no tidyup entry */
788 NULL, /* no closedown entry */
789 TRUE, /* local flag */
792 #ifdef TRANSPORT_AUTOREPLY
794 US"autoreply", /* driver name */
795 autoreply_transport_options, /* local options table */
796 &autoreply_transport_options_count, /* number of entries */
797 &autoreply_transport_option_defaults, /* private options defaults */
798 sizeof(autoreply_transport_options_block), /* size of private block */
799 autoreply_transport_init, /* init entry point */
800 autoreply_transport_entry, /* main entry point */
801 NULL, /* no tidyup entry */
802 NULL, /* no closedown entry */
803 TRUE /* local flag */
806 #ifdef TRANSPORT_LMTP
808 US"lmtp", /* driver name */
809 lmtp_transport_options, /* local options table */
810 &lmtp_transport_options_count, /* number of entries */
811 &lmtp_transport_option_defaults, /* private options defaults */
812 sizeof(lmtp_transport_options_block), /* size of private block */
813 lmtp_transport_init, /* init entry point */
814 lmtp_transport_entry, /* main entry point */
815 NULL, /* no tidyup entry */
816 NULL, /* no closedown entry */
817 TRUE /* local flag */
820 #ifdef TRANSPORT_PIPE
822 US"pipe", /* driver name */
823 pipe_transport_options, /* local options table */
824 &pipe_transport_options_count, /* number of entries */
825 &pipe_transport_option_defaults, /* private options defaults */
826 sizeof(pipe_transport_options_block), /* size of private block */
827 pipe_transport_init, /* init entry point */
828 pipe_transport_entry, /* main entry point */
829 NULL, /* no tidyup entry */
830 NULL, /* no closedown entry */
831 TRUE /* local flag */
834 #ifdef TRANSPORT_SMTP
836 US"smtp", /* driver name */
837 smtp_transport_options, /* local options table */
838 &smtp_transport_options_count, /* number of entries */
839 &smtp_transport_option_defaults, /* private options defaults */
840 sizeof(smtp_transport_options_block), /* size of private block */
841 smtp_transport_init, /* init entry point */
842 smtp_transport_entry, /* main entry point */
843 NULL, /* no tidyup entry */
844 smtp_transport_closedown, /* close down passed channel */
845 FALSE /* local flag */
848 { US"", NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, FALSE }
851 /* End of drtables.c */