1 /* $Cambridge: exim/src/src/drtables.c,v 1.3 2005/05/24 08:15:02 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"
93 #include "lookups/testdb.h"
97 #include "lookups/whoson.h"
100 /* The second field in each item below is a set of bit flags:
102 lookup_querystyle => this is a query-style lookup,
103 else single-key (+ file) style
104 lookup_absfile => an absolute file name is required,
105 (for single-key style only)
107 This list must be in alphabetical order of lookup name because it is
108 searched by binary chop, having got rather large for the original linear
111 lookup_info lookup_list[] = {
113 /* cdb lookup in single file */
116 US"cdb", /* lookup name */
117 lookup_absfile, /* uses absolute file name */
119 cdb_open, /* open function */
120 cdb_check, /* check function */
121 cdb_find, /* find function */
122 cdb_close, /* close function */
123 NULL, /* no tidy function */
124 NULL /* no quoting function */
126 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
130 /* DBM file lookup; called "dbm" because that is the name in Exim,
131 but the code is called dbmdb to avoid name clashes. */
134 US"dbm", /* lookup name */
135 lookup_absfile, /* uses absolute file name */
137 dbmdb_open, /* open function */
138 dbmdb_check, /* check function */
139 dbmdb_find, /* find function */
140 dbmdb_close, /* close function */
141 NULL, /* no tidy function */
142 NULL /* no quoting function */
144 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
148 /* This variant of DBM does not include the binary zero on the end
149 of the key strings. */
152 US"dbmnz", /* lookup name */
153 lookup_absfile, /* uses absolute file name */
155 dbmdb_open, /* sic */ /* open function */
156 dbmdb_check, /* sic */ /* check function */
157 dbmnz_find, /* find function */
158 dbmdb_close, /* sic */ /* close function */
159 NULL, /* no tidy function */
160 NULL /* no quoting function */
162 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
166 /* Using DNS TXT records as a database */
169 US"dnsdb", /* lookup name */
170 lookup_querystyle, /* query style */
172 dnsdb_open, /* open function */
173 NULL, /* check function */
174 dnsdb_find, /* find function */
175 NULL, /* no close function */
176 NULL, /* no tidy function */
177 NULL /* no quoting function */
179 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
183 /* Search of files in a directory */
186 US"dsearch", /* lookup name */
187 lookup_absfile, /* uses absolute file name */
188 #ifdef LOOKUP_DSEARCH
189 dsearch_open, /* open function */
190 dsearch_check, /* check function */
191 dsearch_find, /* find function */
192 dsearch_close, /* close function */
193 NULL, /* no tidy function */
194 NULL /* no quoting function */
196 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
200 /* Interbase lookup */
203 US"ibase", /* lookup name */
204 lookup_querystyle, /* query-style lookup */
206 ibase_open, /* open function */
207 NULL, /* no check function */
208 ibase_find, /* find function */
209 NULL, /* no close function */
210 ibase_tidy, /* tidy function */
211 ibase_quote /* quoting function */
213 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
217 /* Linear search of single file with ip-addresses and networks; shares many
218 functions with lsearch. */
221 US"iplsearch", /* lookup name */
222 lookup_absfile, /* uses absolute file name */
223 #ifdef LOOKUP_LSEARCH
224 lsearch_open, /* open function */
225 lsearch_check, /* check function */
226 iplsearch_find, /* find function */
227 lsearch_close, /* close function */
228 NULL, /* no tidy function */
229 NULL /* no quoting function */
231 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
235 /* LDAP lookup, allowing data from only one entry to be returned */
238 US"ldap", /* lookup name */
239 lookup_querystyle, /* query-style lookup */
241 eldap_open, /* open function */
242 NULL, /* check function */
243 eldap_find, /* find function */
244 NULL, /* no close function */
245 eldap_tidy, /* tidy function */
246 eldap_quote /* quoting function */
248 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
252 /* LDAP lookup, allowing the DN from more one entry to be returned */
255 US"ldapdn", /* lookup name */
256 lookup_querystyle, /* query-style lookup */
258 eldap_open, /* sic */ /* open function */
259 NULL, /* check function */
260 eldapdn_find, /* find function */
261 NULL, /* no close function */
262 eldap_tidy, /* sic */ /* tidy function */
263 eldap_quote /* sic */ /* quoting function */
265 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
269 /* LDAP lookup, allowing data from more than one entry to be returned */
272 US"ldapm", /* lookup name */
273 lookup_querystyle, /* query-style lookup */
275 eldap_open, /* sic */ /* open function */
276 NULL, /* check function */
277 eldapm_find, /* find function */
278 NULL, /* no close function */
279 eldap_tidy, /* sic */ /* tidy function */
280 eldap_quote /* sic */ /* quoting function */
282 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
286 /* Linear search of single file */
289 US"lsearch", /* lookup name */
290 lookup_absfile, /* uses absolute file name */
291 #ifdef LOOKUP_LSEARCH
292 lsearch_open, /* open function */
293 lsearch_check, /* check function */
294 lsearch_find, /* find function */
295 lsearch_close, /* close function */
296 NULL, /* no tidy function */
297 NULL /* no quoting function */
299 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
306 US"mysql", /* lookup name */
307 lookup_querystyle, /* query-style lookup */
309 mysql_open, /* open function */
310 NULL, /* no check function */
311 mysql_find, /* find function */
312 NULL, /* no close function */
313 mysql_tidy, /* tidy function */
314 mysql_quote /* quoting function */
316 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
320 /* NIS lookup, excluding trailing 0 from key */
323 US"nis", /* lookup name */
324 0, /* not abs file, not query style*/
326 nis_open, /* open function */
327 NULL, /* check function */
328 nis_find, /* find function */
329 NULL, /* no close function */
330 NULL, /* no tidy function */
331 NULL /* no quoting function */
333 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
337 /* NIS lookup, including trailing 0 in key */
340 US"nis0", /* lookup name */
341 0, /* not absfile, not query style */
343 nis_open, /* sic */ /* open function */
344 NULL, /* check function */
345 nis0_find, /* find function */
346 NULL, /* no close function */
347 NULL, /* no tidy function */
348 NULL /* no quoting function */
350 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
357 US"nisplus", /* lookup name */
358 lookup_querystyle, /* query-style lookup */
359 #ifdef LOOKUP_NISPLUS
360 nisplus_open, /* open function */
361 NULL, /* check function */
362 nisplus_find, /* find function */
363 NULL, /* no close function */
364 NULL, /* no tidy function */
365 nisplus_quote /* quoting function */
367 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
371 /* Linear search of single file, with wildcarding but no pattern expansion.
372 Shares many functions with lsearch. */
375 US"nwildlsearch", /* lookup name */
376 lookup_absfile, /* uses absolute file name */
377 #ifdef LOOKUP_LSEARCH
378 lsearch_open, /* open function */
379 lsearch_check, /* check function */
380 nwildlsearch_find, /* find function */
381 lsearch_close, /* close function */
382 NULL, /* no tidy function */
383 NULL /* no quoting function */
385 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
392 US"oracle", /* lookup name */
393 lookup_querystyle, /* query-style lookup */
395 oracle_open, /* open function */
396 NULL, /* check function */
397 oracle_find, /* find function */
398 NULL, /* no close function */
399 oracle_tidy, /* tidy function */
400 oracle_quote /* quoting function */
402 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
409 US"passwd", /* lookup name */
410 lookup_querystyle, /* query-style lookup */
412 passwd_open, /* open function */
413 NULL, /* no check function */
414 passwd_find, /* find function */
415 NULL, /* no close function */
416 NULL, /* no tidy function */
417 NULL /* no quoting function */
419 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
426 US"pgsql", /* lookup name */
427 lookup_querystyle, /* query-style lookup */
429 pgsql_open, /* open function */
430 NULL, /* no check function */
431 pgsql_find, /* find function */
432 NULL, /* no close function */
433 pgsql_tidy, /* tidy function */
434 pgsql_quote /* quoting function */
436 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
440 /* Testdb lookup is for testing Exim, not useful for normal running.
441 For that reason, we omit the entry entirely when not building it into
442 the binary, so that attempts to use it give "unknown lookup type" instead
443 of "lookup type not available". */
447 US"testdb", /* lookup name */
448 lookup_querystyle, /* query-style lookup */
449 testdb_open, /* open function */
450 NULL, /* check function */
451 testdb_find, /* find function */
452 NULL, /* no close function */
453 NULL, /* no tidy function */
454 NULL /* no quoting function */
458 /* "Whoson" lookup */
461 US"whoson", /* lookup name */
462 lookup_querystyle, /* query-style lookup */
464 whoson_open, /* open function */
465 NULL, /* check function */
466 whoson_find, /* find function */
467 NULL, /* no close function */
468 NULL, /* no tidy function */
469 NULL /* no quoting function */
471 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
475 /* Linear search of single file, with wildcarding and pattern expansion. Shares
476 many functions with lsearch. */
479 US"wildlsearch", /* lookup name */
480 lookup_absfile, /* uses absolute file name */
481 #ifdef LOOKUP_LSEARCH
482 lsearch_open, /* open function */
483 lsearch_check, /* check function */
484 wildlsearch_find, /* find function */
485 lsearch_close, /* close function */
486 NULL, /* no tidy function */
487 NULL /* no quoting function */
489 NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
494 /* Number of entries in the list */
496 int lookup_list_count = sizeof(lookup_list)/sizeof(lookup_info);
500 /* Table of information about all possible authentication mechamisms. All
501 entries are always present if any mechanism is declared, but the functions are
502 set to NULL for those that are not compiled into the binary. */
505 #include "auths/cram_md5.h"
508 #ifdef AUTH_CYRUS_SASL
509 #include "auths/cyrus_sasl.h"
512 #ifdef AUTH_PLAINTEXT
513 #include "auths/plaintext.h"
517 #include "auths/spa.h"
520 auth_info auths_available[] = {
522 /* Checking by an expansion condition on plain text */
526 US"cram_md5", /* lookup name */
527 auth_cram_md5_options,
528 &auth_cram_md5_options_count,
529 &auth_cram_md5_option_defaults,
530 sizeof(auth_cram_md5_options_block),
531 auth_cram_md5_init, /* init function */
532 auth_cram_md5_server, /* server function */
533 auth_cram_md5_client /* client function */
537 #ifdef AUTH_CYRUS_SASL
539 US"cyrus_sasl", /* lookup name */
540 auth_cyrus_sasl_options,
541 &auth_cyrus_sasl_options_count,
542 &auth_cyrus_sasl_option_defaults,
543 sizeof(auth_cyrus_sasl_options_block),
544 auth_cyrus_sasl_init, /* init function */
545 auth_cyrus_sasl_server, /* server function */
546 NULL /* client function */
550 #ifdef AUTH_PLAINTEXT
552 US"plaintext", /* lookup name */
553 auth_plaintext_options,
554 &auth_plaintext_options_count,
555 &auth_plaintext_option_defaults,
556 sizeof(auth_plaintext_options_block),
557 auth_plaintext_init, /* init function */
558 auth_plaintext_server, /* server function */
559 auth_plaintext_client /* client function */
565 US"spa", /* lookup name */
567 &auth_spa_options_count,
568 &auth_spa_option_defaults,
569 sizeof(auth_spa_options_block),
570 auth_spa_init, /* init function */
571 auth_spa_server, /* server function */
572 auth_spa_client /* client function */
576 { US"", NULL, NULL, NULL, 0, NULL, NULL, NULL }
580 /* Tables of information about which routers and transports are included in the
583 /* Pull in the necessary header files */
585 #include "routers/rf_functions.h"
588 #include "routers/accept.h"
591 #ifdef ROUTER_DNSLOOKUP
592 #include "routers/dnslookup.h"
595 #ifdef ROUTER_MANUALROUTE
596 #include "routers/manualroute.h"
599 #ifdef ROUTER_IPLITERAL
600 #include "routers/ipliteral.h"
603 #ifdef ROUTER_IPLOOKUP
604 #include "routers/iplookup.h"
607 #ifdef ROUTER_QUERYPROGRAM
608 #include "routers/queryprogram.h"
611 #ifdef ROUTER_REDIRECT
612 #include "routers/redirect.h"
615 #ifdef TRANSPORT_APPENDFILE
616 #include "transports/appendfile.h"
619 #ifdef TRANSPORT_AUTOREPLY
620 #include "transports/autoreply.h"
623 #ifdef TRANSPORT_LMTP
624 #include "transports/lmtp.h"
627 #ifdef TRANSPORT_PIPE
628 #include "transports/pipe.h"
631 #ifdef TRANSPORT_SMTP
632 #include "transports/smtp.h"
636 /* Now set up the structures, terminated by an entry with a null name. */
638 router_info routers_available[] = {
642 accept_router_options,
643 &accept_router_options_count,
644 &accept_router_option_defaults,
645 sizeof(accept_router_options_block),
648 NULL, /* no tidyup entry */
652 #ifdef ROUTER_DNSLOOKUP
655 dnslookup_router_options,
656 &dnslookup_router_options_count,
657 &dnslookup_router_option_defaults,
658 sizeof(dnslookup_router_options_block),
659 dnslookup_router_init,
660 dnslookup_router_entry,
661 NULL, /* no tidyup entry */
665 #ifdef ROUTER_IPLITERAL
668 ipliteral_router_options,
669 &ipliteral_router_options_count,
670 &ipliteral_router_option_defaults,
671 sizeof(ipliteral_router_options_block),
672 ipliteral_router_init,
673 ipliteral_router_entry,
674 NULL, /* no tidyup entry */
678 #ifdef ROUTER_IPLOOKUP
681 iplookup_router_options,
682 &iplookup_router_options_count,
683 &iplookup_router_option_defaults,
684 sizeof(iplookup_router_options_block),
685 iplookup_router_init,
686 iplookup_router_entry,
687 NULL, /* no tidyup entry */
691 #ifdef ROUTER_MANUALROUTE
694 manualroute_router_options,
695 &manualroute_router_options_count,
696 &manualroute_router_option_defaults,
697 sizeof(manualroute_router_options_block),
698 manualroute_router_init,
699 manualroute_router_entry,
700 NULL, /* no tidyup entry */
704 #ifdef ROUTER_QUERYPROGRAM
707 queryprogram_router_options,
708 &queryprogram_router_options_count,
709 &queryprogram_router_option_defaults,
710 sizeof(queryprogram_router_options_block),
711 queryprogram_router_init,
712 queryprogram_router_entry,
713 NULL, /* no tidyup entry */
717 #ifdef ROUTER_REDIRECT
720 redirect_router_options,
721 &redirect_router_options_count,
722 &redirect_router_option_defaults,
723 sizeof(redirect_router_options_block),
724 redirect_router_init,
725 redirect_router_entry,
726 NULL, /* no tidyup entry */
730 { US"", NULL, NULL, NULL, 0, NULL, NULL, NULL, 0 }
735 transport_info transports_available[] = {
736 #ifdef TRANSPORT_APPENDFILE
738 US"appendfile", /* driver name */
739 appendfile_transport_options, /* local options table */
740 &appendfile_transport_options_count, /* number of entries */
741 &appendfile_transport_option_defaults, /* private options defaults */
742 sizeof(appendfile_transport_options_block), /* size of private block */
743 appendfile_transport_init, /* init entry point */
744 appendfile_transport_entry, /* main entry point */
745 NULL, /* no tidyup entry */
746 NULL, /* no closedown entry */
747 TRUE, /* local flag */
750 #ifdef TRANSPORT_AUTOREPLY
752 US"autoreply", /* driver name */
753 autoreply_transport_options, /* local options table */
754 &autoreply_transport_options_count, /* number of entries */
755 &autoreply_transport_option_defaults, /* private options defaults */
756 sizeof(autoreply_transport_options_block), /* size of private block */
757 autoreply_transport_init, /* init entry point */
758 autoreply_transport_entry, /* main entry point */
759 NULL, /* no tidyup entry */
760 NULL, /* no closedown entry */
761 TRUE /* local flag */
764 #ifdef TRANSPORT_LMTP
766 US"lmtp", /* driver name */
767 lmtp_transport_options, /* local options table */
768 &lmtp_transport_options_count, /* number of entries */
769 &lmtp_transport_option_defaults, /* private options defaults */
770 sizeof(lmtp_transport_options_block), /* size of private block */
771 lmtp_transport_init, /* init entry point */
772 lmtp_transport_entry, /* main entry point */
773 NULL, /* no tidyup entry */
774 NULL, /* no closedown entry */
775 TRUE /* local flag */
778 #ifdef TRANSPORT_PIPE
780 US"pipe", /* driver name */
781 pipe_transport_options, /* local options table */
782 &pipe_transport_options_count, /* number of entries */
783 &pipe_transport_option_defaults, /* private options defaults */
784 sizeof(pipe_transport_options_block), /* size of private block */
785 pipe_transport_init, /* init entry point */
786 pipe_transport_entry, /* main entry point */
787 NULL, /* no tidyup entry */
788 NULL, /* no closedown entry */
789 TRUE /* local flag */
792 #ifdef TRANSPORT_SMTP
794 US"smtp", /* driver name */
795 smtp_transport_options, /* local options table */
796 &smtp_transport_options_count, /* number of entries */
797 &smtp_transport_option_defaults, /* private options defaults */
798 sizeof(smtp_transport_options_block), /* size of private block */
799 smtp_transport_init, /* init entry point */
800 smtp_transport_entry, /* main entry point */
801 NULL, /* no tidyup entry */
802 smtp_transport_closedown, /* close down passed channel */
803 FALSE /* local flag */
806 { US"", NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, FALSE }
809 /* End of drtables.c */