diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-11-10 00:21:13 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-11-10 00:52:54 +0200 |
commit | 4926ea635ee23341615c351db3e4949553ca4dfb (patch) | |
tree | a1a8c4aede69cf55b5e27fa1dc1630aeeda70329 /src/main.c | |
parent | 7e4d54bd39368b36e8451d52975052c00e745f7a (diff) | |
download | mailfromd-4926ea635ee23341615c351db3e4949553ca4dfb.tar.gz mailfromd-4926ea635ee23341615c351db3e4949553ca4dfb.tar.bz2 |
Switch to libmu_dbm for DBM support.
* configure.ac (DEFAULT_DB_TYPE): New variable.
Use mu info to determine which DBM is supported.
* lib/Makefile.am (noinst_LIBRARIES): Remove libdbm.a
* lib/mf-dbm.c: remove.
* lib/mf-dbm.h: remove.
* lib/cache.c: Use libmu_dbm functions.
* lib/db.c: Likewise.
* lib/dbcfg.c: Likewise.
* lib/greylist.c: Likewise.
* lib/rate.c: Likewise.
* lib/tbf_rate.c: Likewise.
* src/builtin/db.bi: Likewise.
* src/savsrv.c: Likewise.
* src/srvcfg.c (srv_cfg_param) <database-type>: New statement.
* lib/libmf.h (config_cb_ignore): New proto.
* lib/mfdb.h (db_item_printer_t): Change signature.
* lib/utils.c (config_cb_ignore): New function.
* po/POTFILES.in: Update.
* src/Makefile.am (mailfromd_LDADD)
(calloutd_LDADD): Remove libdbm.a.
* src/calloutd.c: Update.
* src/main.c (mf_cfg_param): lock-retry-count and
lock-retry-timeout are no-op now.
* src/mfdbtool.c: Likewise.
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 52 |
1 files changed, 37 insertions, 15 deletions
@@ -16,56 +16,56 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H # include <config.h> #endif #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <stdarg.h> #include <syslog.h> #include <signal.h> #include <pwd.h> #include <grp.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <mailutils/mailutils.h> #include <mailutils/server.h> #include <mailutils/syslog.h> #include <mailutils/libargp.h> +#include <mailutils/dbm.h> #include "mailfromd.h" #include "callout.h" #include "srvman.h" #include "inttostr.h" #include "srvcfg.h" #include "filenames.h" -#include "mf-dbm.h" #include "builtin.h" #include "prog.h" /* Configurable options */ int mode = MAILFROMD_DAEMON; /* Default operation mode */ enum smtp_state test_state = smtp_state_envfrom; /* State for --test mode */ int need_script = 1; /* Set if the current mode requires reading the script file */ char *script_file = DEFAULT_SCRIPT_FILE; int script_check; /* Check config file syntax and exit */ extern int yy_flex_debug; /* Enable tracing the lexical analyzer */ int script_ydebug; /* Enable tracing the parser */ int script_dump_tree; /* Dump created config tree to stdout */ int script_dump_code; /* Dump disassembled code to stdout */ int script_dump_macros; /* Dump used Sendmail macros */ int script_dump_xref; /* Dump cross-reference */ int preprocess_option; /* Only preprocess the sources */ int location_column_option; /* Print column numbers in error locations */ char *ext_pp = DEF_EXT_PP; /* External preprocessor to use */ char *ext_pp_options; int ext_pp_options_given; @@ -897,53 +897,52 @@ struct mu_cfg_param mf_cfg_param[] = { { "include-path", mu_cfg_callback, NULL, 0, cb_include_path, N_("Add directories to the list of directories to be searched for " "header files. Argument is a list of directory names " "separated by colons."), N_("path") }, { "setvar", mu_cfg_callback, NULL, 0, cb_set_variable, N_("Initialize a mailfromd variable <var> to <value>."), N_("var: string> <value: string-or-number") }, { "script-file", mu_cfg_string, &script_file, 0, NULL, N_("Read filter script from <file>."), N_("file") }, { "trace-actions", mu_cfg_bool, &do_trace, 0, NULL, N_("Trace executed actions.") }, { "trace-program", mu_cfg_callback, NULL, 0, cb_trace_program, N_("Enable filter program tracing."), N_("modules: list") }, { "relayed-domain-file", mu_cfg_callback, NULL, 0, cb_relayed_domain_file, N_("Read relayed domain names from the file"), N_("file: string") }, { "database", mu_cfg_section, NULL }, - { "lock-retry-count", mu_cfg_size, &lock_retry_count_option, 0, NULL, - N_("Retry acquiring DBM file lock this number of times.") }, - { "lock-retry-timeout", mu_cfg_callback, &lock_retry_timeout_option, 0, - config_cb_time_t, - N_("Set the time span between the two DBM locking attempts."), + { "lock-retry-count", mu_cfg_callback, 0, 0, config_cb_ignore, + N_("Ignored for backward compatibility.") }, + { "lock-retry-timeout", mu_cfg_callback, 0,0, config_cb_ignore, + N_("Ignored for backward compatibility."), N_("time") }, { "max-match-mx", mu_cfg_size, &max_match_mx, 0, NULL, N_("Maximum number of MXs used by MFL \"mx match\" operation.") }, { "runtime", mu_cfg_section, NULL }, { NULL } }; static struct mu_cfg_param *runtime_param; static size_t runtime_param_cnt; static size_t runtime_param_max; static void _add_runtime_param_entry(struct mu_cfg_param *p) { if (runtime_param_cnt == runtime_param_max) { if (runtime_param_max == 0) runtime_param_max = 16; runtime_param = x2nrealloc(runtime_param, &runtime_param_max, sizeof(runtime_param[0])); @@ -982,73 +981,97 @@ mf_runtime_param_finish() } } } } /* Auxiliary functions */ static int db_format_enumerator(struct db_format *fmt, void *data) { printf("%s database: %s\n", fmt->name, fmt->dbname); if (strcmp(fmt->name, "cache") == 0) { printf("%s positive expiration: %lu\n", fmt->name, fmt->expire_interval); printf("%s negative expiration: %lu\n", fmt->name, negative_expire_interval); } else printf("%s expiration: %lu\n", fmt->name, fmt->expire_interval); return 0; } +static void +list_db_formats(const char *pfx) +{ + mu_iterator_t itr; + int rc; + const char *defdb = DEFAULT_DB_TYPE; + printf("%s", pfx); + + rc = mu_dbm_impl_iterator(&itr); + if (rc) { + printf("%s\n", _("unknown")); + mu_error("%s", mu_strerror(rc)); + } else { + int i; + for (mu_iterator_first(itr), i = 0; !mu_iterator_is_done(itr); + mu_iterator_next(itr), i++) { + struct mu_dbm_impl *impl; + + mu_iterator_current(itr, (void**)&impl); + if (i) + printf(", "); + else if (!defdb) + defdb = impl->_dbm_name; + printf("%s", impl->_dbm_name); + } + putchar('\n'); + mu_iterator_destroy(&itr); + } + printf("default database type: %s\n", defdb); +} + void mailfromd_show_defaults() { printf("version: %s\n", VERSION); printf("script file: %s\n", script_file); printf("preprocessor: %s\n", ext_pp ? ext_pp : "none"); printf("user: %s\n", mf_server_user); printf("statedir: %s\n", mailfromd_state_dir); printf("socket: %s\n", DEFAULT_SOCKET); printf("pidfile: %s\n", pidfile); #ifdef USE_SYSLOG_ASYNC #if DEFAULT_SYSLOG_ASYNC == 1 printf("default syslog: non-blocking\n"); #else printf("default syslog: blocking\n"); #endif #endif - printf("database format: "); -#if defined WITH_GDBM - printf("GDBM"); -#elif defined WITH_BDB - printf("Berkeley DB %d.x", WITH_BDB); -#endif - printf("\n"); - + list_db_formats("supported databases: "); printf("Optional features: "); #if defined WITH_GEOIP printf(" GeoIP"); #endif #if defined WITH_DSPAM printf(" DSPAM"); #endif printf("\n"); db_format_enumerate(db_format_enumerator, NULL); } static void version(FILE *stream, struct argp_state *state) { mailfromd_version("mailfromd", stream); } static int argpflag(int argc, char **argv) { int i; int flag = 0; for (i = 0; i < argc; i++) { @@ -1172,49 +1195,48 @@ main(int argc, char **argv) mf_init_nls(); mf_proctitle_init(argc, argv, environ); MU_AUTH_REGISTER_ALL_MODULES(); mu_register_all_formats(); mu_register_all_mailer_formats(); if (!program_invocation_short_name) program_invocation_short_name = argv[0]; argp_program_version_hook = version; yy_flex_debug = 0; /* Set default logging */ mu_set_program_name(argv[0]); mu_log_tag = (char*)mu_program_name; mu_log_facility = DEFAULT_LOG_FACILITY; mu_stdstream_setup(MU_STDSTREAM_RESET_NONE); mf_srvcfg_log_setup(stderr_is_closed ? "syslog" : "stderr"); debug_init(modnames); libcallout_init(); init_string_space(); init_symbols(); builtin_setup(); mf_runtime_param_finish(); - libdbm_init(); db_format_setup(); include_path_setup(); pragma_setup(); mf_optcache_add(option_cache, 0, MF_OCF_NULL|MF_OCF_STATIC); mf_server_save_cmdline(argc, argv); dnsbase_init(); mu_acl_cfg_init(); database_cfg_init(); srvman_init(); mf_srvcfg_init(argv[0], N_("(milter | callout)")); mu_argp_init(program_version, "<" PACKAGE_BUGREPORT ">"); mu_site_rcfile = DEFAULT_CONFIG_FILE; init_arguments(&args); rc = mu_app_init(&argp, capa, mf_cfg_param, argc, argv, argpflag(argc, argv), &index, &args); if (rc) exit(EX_CONFIG); flush_arguments(&args); mf_srvcfg_flush(); alloc_ext_pp(); |