1 /* $Cambridge: exim/src/src/drtables.c,v 1.11 2009/11/16 19:50:36 nm4 Exp $ */
3 /*************************************************
4 * Exim - an Internet mail transport agent *
5 *************************************************/
7 /* Copyright (c) University of Cambridge 1995 - 2009 */
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"
555 #include "auths/dovecot.h"
558 #ifdef AUTH_PLAINTEXT
559 #include "auths/plaintext.h"
563 #include "auths/spa.h"
566 auth_info auths_available[] = {
568 /* Checking by an expansion condition on plain text */
572 US"cram_md5", /* lookup name */
573 auth_cram_md5_options,
574 &auth_cram_md5_options_count,
575 &auth_cram_md5_option_defaults,
576 sizeof(auth_cram_md5_options_block),
577 auth_cram_md5_init, /* init function */
578 auth_cram_md5_server, /* server function */
579 auth_cram_md5_client /* client function */
583 #ifdef AUTH_CYRUS_SASL
585 US"cyrus_sasl", /* lookup name */
586 auth_cyrus_sasl_options,
587 &auth_cyrus_sasl_options_count,
588 &auth_cyrus_sasl_option_defaults,
589 sizeof(auth_cyrus_sasl_options_block),
590 auth_cyrus_sasl_init, /* init function */
591 auth_cyrus_sasl_server, /* server function */
592 NULL /* client function */
598 US"dovecot", /* lookup name */
599 auth_dovecot_options,
600 &auth_dovecot_options_count,
601 &auth_dovecot_option_defaults,
602 sizeof(auth_dovecot_options_block),
603 auth_dovecot_init, /* init function */
604 auth_dovecot_server, /* server function */
605 NULL /* client function */
609 #ifdef AUTH_PLAINTEXT
611 US"plaintext", /* lookup name */
612 auth_plaintext_options,
613 &auth_plaintext_options_count,
614 &auth_plaintext_option_defaults,
615 sizeof(auth_plaintext_options_block),
616 auth_plaintext_init, /* init function */
617 auth_plaintext_server, /* server function */
618 auth_plaintext_client /* client function */
624 US"spa", /* lookup name */
626 &auth_spa_options_count,
627 &auth_spa_option_defaults,
628 sizeof(auth_spa_options_block),
629 auth_spa_init, /* init function */
630 auth_spa_server, /* server function */
631 auth_spa_client /* client function */
635 { US"", NULL, NULL, NULL, 0, NULL, NULL, NULL }
639 /* Tables of information about which routers and transports are included in the
642 /* Pull in the necessary header files */
644 #include "routers/rf_functions.h"
647 #include "routers/accept.h"
650 #ifdef ROUTER_DNSLOOKUP
651 #include "routers/dnslookup.h"
654 #ifdef ROUTER_MANUALROUTE
655 #include "routers/manualroute.h"
658 #ifdef ROUTER_IPLITERAL
659 #include "routers/ipliteral.h"
662 #ifdef ROUTER_IPLOOKUP
663 #include "routers/iplookup.h"
666 #ifdef ROUTER_QUERYPROGRAM
667 #include "routers/queryprogram.h"
670 #ifdef ROUTER_REDIRECT
671 #include "routers/redirect.h"
674 #ifdef TRANSPORT_APPENDFILE
675 #include "transports/appendfile.h"
678 #ifdef TRANSPORT_AUTOREPLY
679 #include "transports/autoreply.h"
682 #ifdef TRANSPORT_LMTP
683 #include "transports/lmtp.h"
686 #ifdef TRANSPORT_PIPE
687 #include "transports/pipe.h"
690 #ifdef TRANSPORT_SMTP
691 #include "transports/smtp.h"
695 /* Now set up the structures, terminated by an entry with a null name. */
697 router_info routers_available[] = {
701 accept_router_options,
702 &accept_router_options_count,
703 &accept_router_option_defaults,
704 sizeof(accept_router_options_block),
707 NULL, /* no tidyup entry */
711 #ifdef ROUTER_DNSLOOKUP
714 dnslookup_router_options,
715 &dnslookup_router_options_count,
716 &dnslookup_router_option_defaults,
717 sizeof(dnslookup_router_options_block),
718 dnslookup_router_init,
719 dnslookup_router_entry,
720 NULL, /* no tidyup entry */
724 #ifdef ROUTER_IPLITERAL
727 ipliteral_router_options,
728 &ipliteral_router_options_count,
729 &ipliteral_router_option_defaults,
730 sizeof(ipliteral_router_options_block),
731 ipliteral_router_init,
732 ipliteral_router_entry,
733 NULL, /* no tidyup entry */
737 #ifdef ROUTER_IPLOOKUP
740 iplookup_router_options,
741 &iplookup_router_options_count,
742 &iplookup_router_option_defaults,
743 sizeof(iplookup_router_options_block),
744 iplookup_router_init,
745 iplookup_router_entry,
746 NULL, /* no tidyup entry */
750 #ifdef ROUTER_MANUALROUTE
753 manualroute_router_options,
754 &manualroute_router_options_count,
755 &manualroute_router_option_defaults,
756 sizeof(manualroute_router_options_block),
757 manualroute_router_init,
758 manualroute_router_entry,
759 NULL, /* no tidyup entry */
763 #ifdef ROUTER_QUERYPROGRAM
766 queryprogram_router_options,
767 &queryprogram_router_options_count,
768 &queryprogram_router_option_defaults,
769 sizeof(queryprogram_router_options_block),
770 queryprogram_router_init,
771 queryprogram_router_entry,
772 NULL, /* no tidyup entry */
776 #ifdef ROUTER_REDIRECT
779 redirect_router_options,
780 &redirect_router_options_count,
781 &redirect_router_option_defaults,
782 sizeof(redirect_router_options_block),
783 redirect_router_init,
784 redirect_router_entry,
785 NULL, /* no tidyup entry */
789 { US"", NULL, NULL, NULL, 0, NULL, NULL, NULL, 0 }
794 transport_info transports_available[] = {
795 #ifdef TRANSPORT_APPENDFILE
797 US"appendfile", /* driver name */
798 appendfile_transport_options, /* local options table */
799 &appendfile_transport_options_count, /* number of entries */
800 &appendfile_transport_option_defaults, /* private options defaults */
801 sizeof(appendfile_transport_options_block), /* size of private block */
802 appendfile_transport_init, /* init entry point */
803 appendfile_transport_entry, /* main entry point */
804 NULL, /* no tidyup entry */
805 NULL, /* no closedown entry */
806 TRUE, /* local flag */
809 #ifdef TRANSPORT_AUTOREPLY
811 US"autoreply", /* driver name */
812 autoreply_transport_options, /* local options table */
813 &autoreply_transport_options_count, /* number of entries */
814 &autoreply_transport_option_defaults, /* private options defaults */
815 sizeof(autoreply_transport_options_block), /* size of private block */
816 autoreply_transport_init, /* init entry point */
817 autoreply_transport_entry, /* main entry point */
818 NULL, /* no tidyup entry */
819 NULL, /* no closedown entry */
820 TRUE /* local flag */
823 #ifdef TRANSPORT_LMTP
825 US"lmtp", /* driver name */
826 lmtp_transport_options, /* local options table */
827 &lmtp_transport_options_count, /* number of entries */
828 &lmtp_transport_option_defaults, /* private options defaults */
829 sizeof(lmtp_transport_options_block), /* size of private block */
830 lmtp_transport_init, /* init entry point */
831 lmtp_transport_entry, /* main entry point */
832 NULL, /* no tidyup entry */
833 NULL, /* no closedown entry */
834 TRUE /* local flag */
837 #ifdef TRANSPORT_PIPE
839 US"pipe", /* driver name */
840 pipe_transport_options, /* local options table */
841 &pipe_transport_options_count, /* number of entries */
842 &pipe_transport_option_defaults, /* private options defaults */
843 sizeof(pipe_transport_options_block), /* size of private block */
844 pipe_transport_init, /* init entry point */
845 pipe_transport_entry, /* main entry point */
846 NULL, /* no tidyup entry */
847 NULL, /* no closedown entry */
848 TRUE /* local flag */
851 #ifdef TRANSPORT_SMTP
853 US"smtp", /* driver name */
854 smtp_transport_options, /* local options table */
855 &smtp_transport_options_count, /* number of entries */
856 &smtp_transport_option_defaults, /* private options defaults */
857 sizeof(smtp_transport_options_block), /* size of private block */
858 smtp_transport_init, /* init entry point */
859 smtp_transport_entry, /* main entry point */
860 NULL, /* no tidyup entry */
861 smtp_transport_closedown, /* close down passed channel */
862 FALSE /* local flag */
865 { US"", NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, FALSE }
868 /* End of drtables.c */