1 /* $Cambridge: exim/src/src/drtables.c,v 1.4 2005/05/25 20:07:55 tom 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/testdb.h"
101 #include "lookups/whoson.h"
104 /* The second field in each item below is a set of bit flags:
106 lookup_querystyle => this is a query-style lookup,
107 else single-key (+ file) style
108 lookup_absfile => an absolute file name is required,
109 (for single-key style only)
111 This list must be in alphabetical order of lookup name because it is
112 searched by binary chop, having got rather large for the original linear
115 lookup_info lookup_list[] = {
117 /* cdb lookup in single file */
120 US"cdb", /* lookup name */
121 lookup_absfile, /* uses absolute file name */
123 cdb_open, /* open function */
124 cdb_check, /* check function */
125 cdb_find, /* find function */
126 cdb_close, /* close function */
127 NULL, /* no tidy function */
128 NULL /* no quoting function */
130 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
134 /* DBM file lookup; called "dbm" because that is the name in Exim,
135 but the code is called dbmdb to avoid name clashes. */
138 US"dbm", /* lookup name */
139 lookup_absfile, /* uses absolute file name */
141 dbmdb_open, /* open function */
142 dbmdb_check, /* check function */
143 dbmdb_find, /* find function */
144 dbmdb_close, /* close function */
145 NULL, /* no tidy function */
146 NULL /* no quoting function */
148 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
152 /* This variant of DBM does not include the binary zero on the end
153 of the key strings. */
156 US"dbmnz", /* lookup name */
157 lookup_absfile, /* uses absolute file name */
159 dbmdb_open, /* sic */ /* open function */
160 dbmdb_check, /* sic */ /* check function */
161 dbmnz_find, /* find function */
162 dbmdb_close, /* sic */ /* close function */
163 NULL, /* no tidy function */
164 NULL /* no quoting function */
166 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
170 /* Using DNS TXT records as a database */
173 US"dnsdb", /* lookup name */
174 lookup_querystyle, /* query style */
176 dnsdb_open, /* open function */
177 NULL, /* check function */
178 dnsdb_find, /* find function */
179 NULL, /* no close function */
180 NULL, /* no tidy function */
181 NULL /* no quoting function */
183 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
187 /* Search of files in a directory */
190 US"dsearch", /* lookup name */
191 lookup_absfile, /* uses absolute file name */
192 #ifdef LOOKUP_DSEARCH
193 dsearch_open, /* open function */
194 dsearch_check, /* check function */
195 dsearch_find, /* find function */
196 dsearch_close, /* close function */
197 NULL, /* no tidy function */
198 NULL /* no quoting function */
200 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
204 /* Interbase lookup */
207 US"ibase", /* lookup name */
208 lookup_querystyle, /* query-style lookup */
210 ibase_open, /* open function */
211 NULL, /* no check function */
212 ibase_find, /* find function */
213 NULL, /* no close function */
214 ibase_tidy, /* tidy function */
215 ibase_quote /* quoting function */
217 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
221 /* Linear search of single file with ip-addresses and networks; shares many
222 functions with lsearch. */
225 US"iplsearch", /* lookup name */
226 lookup_absfile, /* uses absolute file name */
227 #ifdef LOOKUP_LSEARCH
228 lsearch_open, /* open function */
229 lsearch_check, /* check function */
230 iplsearch_find, /* find function */
231 lsearch_close, /* close function */
232 NULL, /* no tidy function */
233 NULL /* no quoting function */
235 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
239 /* LDAP lookup, allowing data from only one entry to be returned */
242 US"ldap", /* lookup name */
243 lookup_querystyle, /* query-style lookup */
245 eldap_open, /* open function */
246 NULL, /* check function */
247 eldap_find, /* find function */
248 NULL, /* no close function */
249 eldap_tidy, /* tidy function */
250 eldap_quote /* quoting function */
252 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
256 /* LDAP lookup, allowing the DN from more one entry to be returned */
259 US"ldapdn", /* lookup name */
260 lookup_querystyle, /* query-style lookup */
262 eldap_open, /* sic */ /* open function */
263 NULL, /* check function */
264 eldapdn_find, /* find function */
265 NULL, /* no close function */
266 eldap_tidy, /* sic */ /* tidy function */
267 eldap_quote /* sic */ /* quoting function */
269 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
273 /* LDAP lookup, allowing data from more than one entry to be returned */
276 US"ldapm", /* lookup name */
277 lookup_querystyle, /* query-style lookup */
279 eldap_open, /* sic */ /* open function */
280 NULL, /* check function */
281 eldapm_find, /* find function */
282 NULL, /* no close function */
283 eldap_tidy, /* sic */ /* tidy function */
284 eldap_quote /* sic */ /* quoting function */
286 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
290 /* Linear search of single file */
293 US"lsearch", /* lookup name */
294 lookup_absfile, /* uses absolute file name */
295 #ifdef LOOKUP_LSEARCH
296 lsearch_open, /* open function */
297 lsearch_check, /* check function */
298 lsearch_find, /* find function */
299 lsearch_close, /* close function */
300 NULL, /* no tidy function */
301 NULL /* no quoting function */
303 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
310 US"mysql", /* lookup name */
311 lookup_querystyle, /* query-style lookup */
313 mysql_open, /* open function */
314 NULL, /* no check function */
315 mysql_find, /* find function */
316 NULL, /* no close function */
317 mysql_tidy, /* tidy function */
318 mysql_quote /* quoting function */
320 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
324 /* NIS lookup, excluding trailing 0 from key */
327 US"nis", /* lookup name */
328 0, /* not abs file, not query style*/
330 nis_open, /* open function */
331 NULL, /* check function */
332 nis_find, /* find function */
333 NULL, /* no close function */
334 NULL, /* no tidy function */
335 NULL /* no quoting function */
337 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
341 /* NIS lookup, including trailing 0 in key */
344 US"nis0", /* lookup name */
345 0, /* not absfile, not query style */
347 nis_open, /* sic */ /* open function */
348 NULL, /* check function */
349 nis0_find, /* find function */
350 NULL, /* no close function */
351 NULL, /* no tidy function */
352 NULL /* no quoting function */
354 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
361 US"nisplus", /* lookup name */
362 lookup_querystyle, /* query-style lookup */
363 #ifdef LOOKUP_NISPLUS
364 nisplus_open, /* open function */
365 NULL, /* check function */
366 nisplus_find, /* find function */
367 NULL, /* no close function */
368 NULL, /* no tidy function */
369 nisplus_quote /* quoting function */
371 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
375 /* Linear search of single file, with wildcarding but no pattern expansion.
376 Shares many functions with lsearch. */
379 US"nwildlsearch", /* lookup name */
380 lookup_absfile, /* uses absolute file name */
381 #ifdef LOOKUP_LSEARCH
382 lsearch_open, /* open function */
383 lsearch_check, /* check function */
384 nwildlsearch_find, /* find function */
385 lsearch_close, /* close function */
386 NULL, /* no tidy function */
387 NULL /* no quoting function */
389 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
396 US"oracle", /* lookup name */
397 lookup_querystyle, /* query-style lookup */
399 oracle_open, /* open function */
400 NULL, /* check function */
401 oracle_find, /* find function */
402 NULL, /* no close function */
403 oracle_tidy, /* tidy function */
404 oracle_quote /* quoting function */
406 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
413 US"passwd", /* lookup name */
414 lookup_querystyle, /* query-style lookup */
416 passwd_open, /* open function */
417 NULL, /* no check function */
418 passwd_find, /* find function */
419 NULL, /* no close function */
420 NULL, /* no tidy function */
421 NULL /* no quoting function */
423 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
430 US"pgsql", /* lookup name */
431 lookup_querystyle, /* query-style lookup */
433 pgsql_open, /* open function */
434 NULL, /* no check function */
435 pgsql_find, /* find function */
436 NULL, /* no close function */
437 pgsql_tidy, /* tidy function */
438 pgsql_quote /* quoting function */
440 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
447 US"spf", /* lookup name */
448 0, /* not absfile, not query style */
449 #ifdef EXPERIMENTAL_SPF
450 spf_open, /* open function */
451 NULL, /* no check function */
452 spf_find, /* find function */
453 spf_close, /* close function */
454 NULL, /* no tidy function */
455 NULL /* no quoting function */
457 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
461 /* Testdb lookup is for testing Exim, not useful for normal running.
462 For that reason, we omit the entry entirely when not building it into
463 the binary, so that attempts to use it give "unknown lookup type" instead
464 of "lookup type not available". */
468 US"testdb", /* lookup name */
469 lookup_querystyle, /* query-style lookup */
470 testdb_open, /* open function */
471 NULL, /* check function */
472 testdb_find, /* find function */
473 NULL, /* no close function */
474 NULL, /* no tidy function */
475 NULL /* no quoting function */
479 /* "Whoson" lookup */
482 US"whoson", /* lookup name */
483 lookup_querystyle, /* query-style lookup */
485 whoson_open, /* open function */
486 NULL, /* check function */
487 whoson_find, /* find function */
488 NULL, /* no close function */
489 NULL, /* no tidy function */
490 NULL /* no quoting function */
492 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
496 /* Linear search of single file, with wildcarding and pattern expansion. Shares
497 many functions with lsearch. */
500 US"wildlsearch", /* lookup name */
501 lookup_absfile, /* uses absolute file name */
502 #ifdef LOOKUP_LSEARCH
503 lsearch_open, /* open function */
504 lsearch_check, /* check function */
505 wildlsearch_find, /* find function */
506 lsearch_close, /* close function */
507 NULL, /* no tidy function */
508 NULL /* no quoting function */
510 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
515 /* Number of entries in the list */
517 int lookup_list_count = sizeof(lookup_list)/sizeof(lookup_info);
521 /* Table of information about all possible authentication mechamisms. All
522 entries are always present if any mechanism is declared, but the functions are
523 set to NULL for those that are not compiled into the binary. */
526 #include "auths/cram_md5.h"
529 #ifdef AUTH_CYRUS_SASL
530 #include "auths/cyrus_sasl.h"
533 #ifdef AUTH_PLAINTEXT
534 #include "auths/plaintext.h"
538 #include "auths/spa.h"
541 auth_info auths_available[] = {
543 /* Checking by an expansion condition on plain text */
547 US"cram_md5", /* lookup name */
548 auth_cram_md5_options,
549 &auth_cram_md5_options_count,
550 &auth_cram_md5_option_defaults,
551 sizeof(auth_cram_md5_options_block),
552 auth_cram_md5_init, /* init function */
553 auth_cram_md5_server, /* server function */
554 auth_cram_md5_client /* client function */
558 #ifdef AUTH_CYRUS_SASL
560 US"cyrus_sasl", /* lookup name */
561 auth_cyrus_sasl_options,
562 &auth_cyrus_sasl_options_count,
563 &auth_cyrus_sasl_option_defaults,
564 sizeof(auth_cyrus_sasl_options_block),
565 auth_cyrus_sasl_init, /* init function */
566 auth_cyrus_sasl_server, /* server function */
567 NULL /* client function */
571 #ifdef AUTH_PLAINTEXT
573 US"plaintext", /* lookup name */
574 auth_plaintext_options,
575 &auth_plaintext_options_count,
576 &auth_plaintext_option_defaults,
577 sizeof(auth_plaintext_options_block),
578 auth_plaintext_init, /* init function */
579 auth_plaintext_server, /* server function */
580 auth_plaintext_client /* client function */
586 US"spa", /* lookup name */
588 &auth_spa_options_count,
589 &auth_spa_option_defaults,
590 sizeof(auth_spa_options_block),
591 auth_spa_init, /* init function */
592 auth_spa_server, /* server function */
593 auth_spa_client /* client function */
597 { US"", NULL, NULL, NULL, 0, NULL, NULL, NULL }
601 /* Tables of information about which routers and transports are included in the
604 /* Pull in the necessary header files */
606 #include "routers/rf_functions.h"
609 #include "routers/accept.h"
612 #ifdef ROUTER_DNSLOOKUP
613 #include "routers/dnslookup.h"
616 #ifdef ROUTER_MANUALROUTE
617 #include "routers/manualroute.h"
620 #ifdef ROUTER_IPLITERAL
621 #include "routers/ipliteral.h"
624 #ifdef ROUTER_IPLOOKUP
625 #include "routers/iplookup.h"
628 #ifdef ROUTER_QUERYPROGRAM
629 #include "routers/queryprogram.h"
632 #ifdef ROUTER_REDIRECT
633 #include "routers/redirect.h"
636 #ifdef TRANSPORT_APPENDFILE
637 #include "transports/appendfile.h"
640 #ifdef TRANSPORT_AUTOREPLY
641 #include "transports/autoreply.h"
644 #ifdef TRANSPORT_LMTP
645 #include "transports/lmtp.h"
648 #ifdef TRANSPORT_PIPE
649 #include "transports/pipe.h"
652 #ifdef TRANSPORT_SMTP
653 #include "transports/smtp.h"
657 /* Now set up the structures, terminated by an entry with a null name. */
659 router_info routers_available[] = {
663 accept_router_options,
664 &accept_router_options_count,
665 &accept_router_option_defaults,
666 sizeof(accept_router_options_block),
669 NULL, /* no tidyup entry */
673 #ifdef ROUTER_DNSLOOKUP
676 dnslookup_router_options,
677 &dnslookup_router_options_count,
678 &dnslookup_router_option_defaults,
679 sizeof(dnslookup_router_options_block),
680 dnslookup_router_init,
681 dnslookup_router_entry,
682 NULL, /* no tidyup entry */
686 #ifdef ROUTER_IPLITERAL
689 ipliteral_router_options,
690 &ipliteral_router_options_count,
691 &ipliteral_router_option_defaults,
692 sizeof(ipliteral_router_options_block),
693 ipliteral_router_init,
694 ipliteral_router_entry,
695 NULL, /* no tidyup entry */
699 #ifdef ROUTER_IPLOOKUP
702 iplookup_router_options,
703 &iplookup_router_options_count,
704 &iplookup_router_option_defaults,
705 sizeof(iplookup_router_options_block),
706 iplookup_router_init,
707 iplookup_router_entry,
708 NULL, /* no tidyup entry */
712 #ifdef ROUTER_MANUALROUTE
715 manualroute_router_options,
716 &manualroute_router_options_count,
717 &manualroute_router_option_defaults,
718 sizeof(manualroute_router_options_block),
719 manualroute_router_init,
720 manualroute_router_entry,
721 NULL, /* no tidyup entry */
725 #ifdef ROUTER_QUERYPROGRAM
728 queryprogram_router_options,
729 &queryprogram_router_options_count,
730 &queryprogram_router_option_defaults,
731 sizeof(queryprogram_router_options_block),
732 queryprogram_router_init,
733 queryprogram_router_entry,
734 NULL, /* no tidyup entry */
738 #ifdef ROUTER_REDIRECT
741 redirect_router_options,
742 &redirect_router_options_count,
743 &redirect_router_option_defaults,
744 sizeof(redirect_router_options_block),
745 redirect_router_init,
746 redirect_router_entry,
747 NULL, /* no tidyup entry */
751 { US"", NULL, NULL, NULL, 0, NULL, NULL, NULL, 0 }
756 transport_info transports_available[] = {
757 #ifdef TRANSPORT_APPENDFILE
759 US"appendfile", /* driver name */
760 appendfile_transport_options, /* local options table */
761 &appendfile_transport_options_count, /* number of entries */
762 &appendfile_transport_option_defaults, /* private options defaults */
763 sizeof(appendfile_transport_options_block), /* size of private block */
764 appendfile_transport_init, /* init entry point */
765 appendfile_transport_entry, /* main entry point */
766 NULL, /* no tidyup entry */
767 NULL, /* no closedown entry */
768 TRUE, /* local flag */
771 #ifdef TRANSPORT_AUTOREPLY
773 US"autoreply", /* driver name */
774 autoreply_transport_options, /* local options table */
775 &autoreply_transport_options_count, /* number of entries */
776 &autoreply_transport_option_defaults, /* private options defaults */
777 sizeof(autoreply_transport_options_block), /* size of private block */
778 autoreply_transport_init, /* init entry point */
779 autoreply_transport_entry, /* main entry point */
780 NULL, /* no tidyup entry */
781 NULL, /* no closedown entry */
782 TRUE /* local flag */
785 #ifdef TRANSPORT_LMTP
787 US"lmtp", /* driver name */
788 lmtp_transport_options, /* local options table */
789 &lmtp_transport_options_count, /* number of entries */
790 &lmtp_transport_option_defaults, /* private options defaults */
791 sizeof(lmtp_transport_options_block), /* size of private block */
792 lmtp_transport_init, /* init entry point */
793 lmtp_transport_entry, /* main entry point */
794 NULL, /* no tidyup entry */
795 NULL, /* no closedown entry */
796 TRUE /* local flag */
799 #ifdef TRANSPORT_PIPE
801 US"pipe", /* driver name */
802 pipe_transport_options, /* local options table */
803 &pipe_transport_options_count, /* number of entries */
804 &pipe_transport_option_defaults, /* private options defaults */
805 sizeof(pipe_transport_options_block), /* size of private block */
806 pipe_transport_init, /* init entry point */
807 pipe_transport_entry, /* main entry point */
808 NULL, /* no tidyup entry */
809 NULL, /* no closedown entry */
810 TRUE /* local flag */
813 #ifdef TRANSPORT_SMTP
815 US"smtp", /* driver name */
816 smtp_transport_options, /* local options table */
817 &smtp_transport_options_count, /* number of entries */
818 &smtp_transport_option_defaults, /* private options defaults */
819 sizeof(smtp_transport_options_block), /* size of private block */
820 smtp_transport_init, /* init entry point */
821 smtp_transport_entry, /* main entry point */
822 NULL, /* no tidyup entry */
823 smtp_transport_closedown, /* close down passed channel */
824 FALSE /* local flag */
827 { US"", NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, FALSE }
830 /* End of drtables.c */