void test_load_paths (void) { const gchar *config_dir; config_dir = g_getenv("MILTER_MANAGER_CONFIG_DIR"); if (config_dir) expected_load_paths = g_list_append(expected_load_paths, g_strdup(config_dir)); expected_load_paths = g_list_append(expected_load_paths, g_strdup(CONFIG_DIR)); gcut_assert_equal_list_string( expected_load_paths, milter_manager_configuration_get_load_paths(config)); expected_load_paths = g_list_append(expected_load_paths, g_strdup("append/XXX")); milter_manager_configuration_append_load_path(config, "append/XXX"); gcut_assert_equal_list_string( expected_load_paths, milter_manager_configuration_get_load_paths(config)); expected_load_paths = g_list_prepend(expected_load_paths, g_strdup("prepend/XXX")); milter_manager_configuration_prepend_load_path(config, "prepend/XXX"); gcut_assert_equal_list_string( expected_load_paths, milter_manager_configuration_get_load_paths(config)); milter_manager_configuration_clear_load_paths(config); gcut_assert_equal_list_string( NULL, milter_manager_configuration_get_load_paths(config)); }
static void append_custom_configuration_directory (MilterManagerConfiguration *config) { struct passwd *password; const gchar *effective_user; gchar *custom_config_directory; effective_user = milter_manager_configuration_get_effective_user(config); if (!effective_user) return; password = find_password(effective_user); if (!password) return; custom_config_directory = g_strdup(milter_manager_configuration_get_custom_configuration_directory(config)); if (!custom_config_directory) custom_config_directory = g_build_filename(password->pw_dir, ".milter-manager", NULL); if (!g_file_test(custom_config_directory, G_FILE_TEST_EXISTS)) { if (g_mkdir(custom_config_directory, 0700) == -1) { milter_manager_error("failed to create custom " "configuration directory: <%s>: %s", custom_config_directory, g_strerror(errno)); return; } if (chown(custom_config_directory, password->pw_uid, password->pw_gid) == -1) { milter_manager_error("failed to change owner and group of " "configuration directory: <%s>: <%u:%u>: %s", custom_config_directory, password->pw_uid, password->pw_gid, g_strerror(errno)); return; } } milter_manager_configuration_append_load_path(config, custom_config_directory); g_free(custom_config_directory); }