struct sieve_extprograms_config *sieve_extprograms_config_init (const struct sieve_extension *ext) { struct sieve_instance *svinst = ext->svinst; struct sieve_extprograms_config *ext_config; const char *extname = sieve_extension_name(ext); const char *bin_dir, *socket_dir, *input_eol; sieve_number_t execute_timeout; extname = strrchr(extname, '.'); i_assert(extname != NULL); extname++; bin_dir = sieve_setting_get (svinst, t_strdup_printf("sieve_%s_bin_dir", extname)); socket_dir = sieve_setting_get (svinst, t_strdup_printf("sieve_%s_socket_dir", extname)); input_eol = sieve_setting_get (svinst, t_strdup_printf("sieve_%s_input_eol", extname)); ext_config = i_new(struct sieve_extprograms_config, 1); ext_config->execute_timeout = SIEVE_EXTPROGRAMS_DEFAULT_EXEC_TIMEOUT_SECS; if ( bin_dir == NULL && socket_dir == NULL ) { if ( svinst->debug ) { sieve_sys_debug(svinst, "%s extension: " "no bin or socket directory specified; extension is unconfigured " "(both sieve_%s_bin_dir and sieve_%s_socket_dir are not set)", sieve_extension_name(ext), extname, extname); } } else { ext_config->bin_dir = i_strdup(bin_dir); ext_config->socket_dir = i_strdup(socket_dir); if (sieve_setting_get_duration_value (svinst, t_strdup_printf("sieve_%s_exec_timeout", extname), &execute_timeout)) { ext_config->execute_timeout = execute_timeout; } ext_config->default_input_eol = SIEVE_EXTPROGRAMS_EOL_CRLF; if (input_eol != NULL && strcasecmp(input_eol, "lf") == 0) ext_config->default_input_eol = SIEVE_EXTPROGRAMS_EOL_LF; } if ( sieve_extension_is(ext, vnd_pipe_extension) ) ext_config->copy_ext = sieve_ext_copy_get_extension(ext->svinst); if ( sieve_extension_is(ext, vnd_execute_extension) ) ext_config->var_ext = sieve_ext_variables_get_extension(ext->svinst); return ext_config; }
void sieve_extensions_configure(struct sieve_instance *svinst) { const char *extensions; /* Apply sieve_extensions configuration */ if ( (extensions=sieve_setting_get(svinst, "sieve_extensions")) != NULL ) sieve_extensions_set_string(svinst, extensions, FALSE); /* Apply sieve_global_extensions configuration */ if ( (extensions=sieve_setting_get(svinst, "sieve_global_extensions")) != NULL ) sieve_extensions_set_string(svinst, extensions, TRUE); }
const char *sieve_user_get_log_path (struct sieve_instance *svinst, struct sieve_script *user_script) { const char *log_path = NULL; /* Determine user log file path */ if ( (log_path=sieve_setting_get (svinst, "sieve_user_log")) == NULL ) { const char *path; if ( user_script == NULL || (path=sieve_file_script_get_path(user_script)) == NULL ) { /* Default */ if ( svinst->home_dir != NULL ) { log_path = t_strconcat (svinst->home_dir, "/.dovecot.sieve.log", NULL); } } else { /* Use script file as a base (legacy behavior) */ log_path = t_strconcat(path, ".log", NULL); } } else if ( svinst->home_dir != NULL ) { /* Expand home dir if necessary */ if ( log_path[0] == '~' ) { log_path = home_expand_tilde(log_path, svinst->home_dir); } else if ( log_path[0] != '/' ) { log_path = t_strconcat(svinst->home_dir, "/", log_path, NULL); } } return log_path; }
static void ext_editheader_config_headers (struct sieve_instance *svinst, struct ext_editheader_config *ext_config, const char *setting, bool forbid_add, bool forbid_delete) { const char *setval; setval = sieve_setting_get(svinst, setting); if ( setval != NULL ) { const char **headers = t_strsplit_spaces(setval, " \t"); while ( *headers != NULL ) { struct ext_editheader_header *header; if ( !rfc2822_header_field_name_verify (*headers, strlen(*headers)) ) { sieve_sys_warning(svinst, "editheader: " "setting %s contains invalid header field name " "`%s' (ignored)", setting, *headers); continue; } header=ext_editheader_config_header_find(ext_config, *headers); if ( header == NULL ) { header = array_append_space(&ext_config->headers); header->name = p_strdup(ext_config->pool, *headers); } if (forbid_add) header->forbid_add = TRUE; if (forbid_delete) header->forbid_delete = TRUE; headers++; } } }
void sieve_plugins_load (struct sieve_instance *svinst, const char *path, const char *plugins) { struct module *module; struct module_dir_load_settings mod_set; const char **module_names; unsigned int i; /* Determine what to load */ if ( path == NULL && plugins == NULL ) { path = sieve_setting_get(svinst, "sieve_plugin_dir"); plugins = sieve_setting_get(svinst, "sieve_plugins"); } if ( plugins == NULL || *plugins == '\0' ) return; if ( path == NULL || *path == '\0' ) path = MODULEDIR"/sieve"; memset(&mod_set, 0, sizeof(mod_set)); mod_set.abi_version = PIGEONHOLE_ABI_VERSION; mod_set.require_init_funcs = TRUE; mod_set.debug = FALSE; /* Load missing plugin modules */ sieve_modules = module_dir_load_missing (sieve_modules, path, plugins, &mod_set); /* Call plugin load functions for this Sieve instance */ if ( svinst->plugins == NULL ) { sieve_modules_refcount++; } module_names = t_strsplit_spaces(plugins, ", "); for (i = 0; module_names[i] != NULL; i++) { /* Allow giving the module names also in non-base form. */ module_names[i] = module_file_get_name(module_names[i]); } for (i = 0; module_names[i] != NULL; i++) { struct sieve_plugin *plugin; const char *name = module_names[i]; sieve_plugin_load_func_t load_func; /* Find the module */ module = sieve_plugin_module_find(name); i_assert(module != NULL); /* Check whether the plugin is already loaded in this instance */ plugin = svinst->plugins; while ( plugin != NULL ) { if ( plugin->module == module ) break; plugin = plugin->next; } /* Skip it if it is loaded already */ if ( plugin != NULL ) continue; /* Create plugin list item */ plugin = p_new(svinst->pool, struct sieve_plugin, 1); plugin->module = module; /* Call load function */ load_func = (sieve_plugin_load_func_t) module_get_symbol (module, t_strdup_printf("%s_load", module->name)); if ( load_func != NULL ) { load_func(svinst, &plugin->context); } /* Add plugin to the instance */ if ( svinst->plugins == NULL ) svinst->plugins = plugin; else { struct sieve_plugin *plugin_last; plugin_last = svinst->plugins; while ( plugin_last->next != NULL ) plugin_last = plugin_last->next; plugin_last->next = plugin; } } }