static void main_init(void) { struct module_dir_load_settings mod_set; void **sets; sets = master_service_settings_get_others(master_service); dict_settings = sets[0]; if (*dict_settings->dict_db_config != '\0') { /* for berkeley db library */ env_put(t_strconcat("DB_CONFIG=", dict_settings->dict_db_config, NULL)); } memset(&mod_set, 0, sizeof(mod_set)); mod_set.version = master_service_get_version_string(master_service); mod_set.require_init_funcs = TRUE; modules = module_dir_load(DICT_MODULE_DIR, NULL, &mod_set); module_dir_init(modules); /* Register only after loading modules. They may contain SQL drivers, which we'll need to register. */ dict_drivers_register_all(); }
struct mail_storage_service_ctx * mail_storage_service_init(struct master_service *service, const struct setting_parser_info *set_roots[], enum mail_storage_service_flags flags) { struct mail_storage_service_ctx *ctx; const char *version; pool_t pool; unsigned int count; version = master_service_get_version_string(service); if (version != NULL && strcmp(version, PACKAGE_VERSION) != 0) { i_fatal("Version mismatch: libdovecot-storage.so is '%s', " "while the running Dovecot binary is '%s'", PACKAGE_VERSION, version); } if ((flags & MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP) != 0 && getuid() != 0) { /* service { user } isn't root. the permission drop can't be temporary. */ flags &= ~MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP; } (void)umask(0077); io_loop_set_time_moved_callback(current_ioloop, mail_storage_service_time_moved); mail_storage_init(); mail_storage_register_all(); mailbox_list_register_all(); pool = pool_alloconly_create("mail storage service", 2048); ctx = p_new(pool, struct mail_storage_service_ctx, 1); ctx->pool = pool; ctx->service = service; ctx->flags = flags; /* @UNSAFE */ if (set_roots == NULL) count = 0; else for (count = 0; set_roots[count] != NULL; count++) ; ctx->set_roots = p_new(pool, const struct setting_parser_info *, count + 2); ctx->set_roots[0] = &mail_user_setting_parser_info; if (set_roots != NULL) { memcpy(ctx->set_roots + 1, set_roots, sizeof(*ctx->set_roots) * count); } /* do all the global initialization. delay initializing plugins until we drop privileges the first time. */ if ((flags & MAIL_STORAGE_SERVICE_FLAG_NO_LOG_INIT) == 0) { /* note: we may not have read any settings yet, so this logging may still be going to wrong location */ ctx->default_log_prefix = p_strconcat(pool, service->name, ": ", NULL); master_service_init_log(service, ctx->default_log_prefix); } dict_drivers_register_builtin(); return ctx; }