summaryrefslogtreecommitdiffabout
path: root/src/main.c
authorSergey Poznyakoff <gray@gnu.org.ua>2011-11-09 22:21:13 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2011-11-09 22:52:54 (GMT)
commit4926ea635ee23341615c351db3e4949553ca4dfb (patch) (side-by-side diff)
treea1a8c4aede69cf55b5e27fa1dc1630aeeda70329 /src/main.c
parent7e4d54bd39368b36e8451d52975052c00e745f7a (diff)
downloadmailfromd-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') (more/less context) (ignore whitespace changes)
-rw-r--r--src/main.c52
1 files changed, 37 insertions, 15 deletions
diff --git a/src/main.c b/src/main.c
index c277aa4..ba0c0f5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -28,32 +28,32 @@
#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 */
@@ -909,29 +909,28 @@ struct mu_cfg_param mf_cfg_param[] = {
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;
@@ -994,49 +993,73 @@ 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);
}
@@ -1184,25 +1207,24 @@ main(int argc, char **argv)
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)"));

Return to:

Send suggestions and report system problems to the System administrator.