|
|
562801 |
From 8d8919987929cc5eb27e45dfc58f18b78dd0e484 Mon Sep 17 00:00:00 2001
|
|
|
562801 |
From: Matej Habrnal <mhabrnal@redhat.com>
|
|
|
562801 |
Date: Tue, 22 Mar 2016 15:15:43 +0100
|
|
|
562801 |
Subject: [PATCH] lib: move CREATE_PRIVATE_TICKET to the global configuration
|
|
|
562801 |
|
|
|
562801 |
The plugins should not rely directly on the environment variables. This
|
|
|
562801 |
patch should ensure that every one uses the same logic to interpret the
|
|
|
562801 |
environment variables.
|
|
|
562801 |
|
|
|
562801 |
Related to rhbz#1279453
|
|
|
562801 |
|
|
|
562801 |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
562801 |
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
|
|
|
562801 |
---
|
|
|
562801 |
src/gui-wizard-gtk/main.c | 1 +
|
|
|
562801 |
src/gui-wizard-gtk/wizard.c | 9 +----
|
|
|
562801 |
src/include/global_configuration.h | 15 +++++++++
|
|
|
562801 |
src/lib/global_configuration.c | 22 +++++++++++++
|
|
|
562801 |
src/plugins/reporter-bugzilla.c | 4 +--
|
|
|
562801 |
tests/global_config.at | 67 ++++++++++++++++++++++++++++++++++++++
|
|
|
562801 |
6 files changed, 107 insertions(+), 11 deletions(-)
|
|
|
562801 |
|
|
|
562801 |
diff --git a/src/gui-wizard-gtk/main.c b/src/gui-wizard-gtk/main.c
|
|
|
562801 |
index 41a8089..1a10258 100644
|
|
|
562801 |
--- a/src/gui-wizard-gtk/main.c
|
|
|
562801 |
+++ b/src/gui-wizard-gtk/main.c
|
|
|
562801 |
@@ -186,6 +186,7 @@ int main(int argc, char **argv)
|
|
|
562801 |
|
|
|
562801 |
g_dump_dir_name = xstrdup(argv[0]);
|
|
|
562801 |
|
|
|
562801 |
+ load_global_configuration();
|
|
|
562801 |
/* load /etc/abrt/events/foo.{conf,xml} stuff
|
|
|
562801 |
and $XDG_CACHE_HOME/abrt/events/foo.conf */
|
|
|
562801 |
g_event_config_list = load_event_config_data();
|
|
|
562801 |
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
|
|
|
562801 |
index 17257ec..6a1bdc0 100644
|
|
|
562801 |
--- a/src/gui-wizard-gtk/wizard.c
|
|
|
562801 |
+++ b/src/gui-wizard-gtk/wizard.c
|
|
|
562801 |
@@ -2168,14 +2168,7 @@ static void add_warning(const char *warning)
|
|
|
562801 |
|
|
|
562801 |
static void on_sensitive_ticket_clicked_cb(GtkWidget *button, gpointer user_data)
|
|
|
562801 |
{
|
|
|
562801 |
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
|
|
|
562801 |
- {
|
|
|
562801 |
- xsetenv(CREATE_PRIVATE_TICKET, "1");
|
|
|
562801 |
- }
|
|
|
562801 |
- else
|
|
|
562801 |
- {
|
|
|
562801 |
- safe_unsetenv(CREATE_PRIVATE_TICKET);
|
|
|
562801 |
- }
|
|
|
562801 |
+ set_global_create_private_ticket(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)), /*transient*/0);
|
|
|
562801 |
}
|
|
|
562801 |
|
|
|
562801 |
static void on_privacy_info_btn(GtkWidget *button, gpointer user_data)
|
|
|
562801 |
diff --git a/src/include/global_configuration.h b/src/include/global_configuration.h
|
|
|
562801 |
index 9666796..bc5513d 100644
|
|
|
562801 |
--- a/src/include/global_configuration.h
|
|
|
562801 |
+++ b/src/include/global_configuration.h
|
|
|
562801 |
@@ -38,6 +38,21 @@ void free_global_configuration(void);
|
|
|
562801 |
#define get_global_always_excluded_elements libreport_get_global_always_excluded_elements
|
|
|
562801 |
string_vector_ptr_t get_global_always_excluded_elements(void);
|
|
|
562801 |
|
|
|
562801 |
+#define get_global_create_private_ticket libreport_get_global_create_private_ticket
|
|
|
562801 |
+bool get_global_create_private_ticket(void);
|
|
|
562801 |
+
|
|
|
562801 |
+/**
|
|
|
562801 |
+ * Configures the create private ticket global option
|
|
|
562801 |
+ *
|
|
|
562801 |
+ * The function changes the configuration only for the current process by
|
|
|
562801 |
+ * default.
|
|
|
562801 |
+ *
|
|
|
562801 |
+ * @param enabled The option's value
|
|
|
562801 |
+ * @param flags For future needs (enable persistent configuration)
|
|
|
562801 |
+ */
|
|
|
562801 |
+#define set_global_create_private_ticket libreport_set_global_create_private_ticket
|
|
|
562801 |
+void set_global_create_private_ticket(bool enabled, int flags);
|
|
|
562801 |
+
|
|
|
562801 |
#ifdef __cplusplus
|
|
|
562801 |
}
|
|
|
562801 |
#endif
|
|
|
562801 |
diff --git a/src/lib/global_configuration.c b/src/lib/global_configuration.c
|
|
|
562801 |
index 903a2fb..ef921e9 100644
|
|
|
562801 |
--- a/src/lib/global_configuration.c
|
|
|
562801 |
+++ b/src/lib/global_configuration.c
|
|
|
562801 |
@@ -141,3 +141,25 @@ string_vector_ptr_t get_global_always_excluded_elements(void)
|
|
|
562801 |
|
|
|
562801 |
return ret;
|
|
|
562801 |
}
|
|
|
562801 |
+
|
|
|
562801 |
+bool get_global_create_private_ticket(void)
|
|
|
562801 |
+{
|
|
|
562801 |
+ assert_global_configuration_initialized();
|
|
|
562801 |
+
|
|
|
562801 |
+ char *env_create_private = getenv(CREATE_PRIVATE_TICKET);
|
|
|
562801 |
+
|
|
|
562801 |
+ if (env_create_private == NULL)
|
|
|
562801 |
+ return false;
|
|
|
562801 |
+
|
|
|
562801 |
+ return string_to_bool(env_create_private);
|
|
|
562801 |
+}
|
|
|
562801 |
+
|
|
|
562801 |
+void set_global_create_private_ticket(bool enabled, int flags/*unused - persistent*/)
|
|
|
562801 |
+{
|
|
|
562801 |
+ assert_global_configuration_initialized();
|
|
|
562801 |
+
|
|
|
562801 |
+ if (enabled)
|
|
|
562801 |
+ xsetenv(CREATE_PRIVATE_TICKET, "1");
|
|
|
562801 |
+ else
|
|
|
562801 |
+ safe_unsetenv(CREATE_PRIVATE_TICKET);
|
|
|
562801 |
+}
|
|
|
562801 |
diff --git a/src/plugins/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c
|
|
|
562801 |
index d11fadf..941c91f 100644
|
|
|
562801 |
--- a/src/plugins/reporter-bugzilla.c
|
|
|
562801 |
+++ b/src/plugins/reporter-bugzilla.c
|
|
|
562801 |
@@ -740,9 +740,7 @@ static void set_settings(struct bugzilla_struct *b, map_string_t *settings)
|
|
|
562801 |
environ = getenv("Bugzilla_DontMatchComponents");
|
|
|
562801 |
b->b_DontMatchComponents = environ ? environ : get_map_string_item_or_empty(settings, "DontMatchComponents");
|
|
|
562801 |
|
|
|
562801 |
- environ = getenv(CREATE_PRIVATE_TICKET);
|
|
|
562801 |
- if (environ)
|
|
|
562801 |
- b->b_create_private = string_to_bool(environ);
|
|
|
562801 |
+ b->b_create_private = get_global_create_private_ticket();
|
|
|
562801 |
|
|
|
562801 |
if (!b->b_create_private)
|
|
|
562801 |
{
|
|
|
562801 |
diff --git a/tests/global_config.at b/tests/global_config.at
|
|
|
562801 |
index a6f5423..05a0ffa 100644
|
|
|
562801 |
--- a/tests/global_config.at
|
|
|
562801 |
+++ b/tests/global_config.at
|
|
|
562801 |
@@ -102,3 +102,70 @@ int main(int argc, char **argv)
|
|
|
562801 |
return EXIT_SUCCESS;
|
|
|
562801 |
}
|
|
|
562801 |
]])
|
|
|
562801 |
+
|
|
|
562801 |
+## --------------------- ##
|
|
|
562801 |
+## create_private_ticket ##
|
|
|
562801 |
+## --------------------- ##
|
|
|
562801 |
+
|
|
|
562801 |
+AT_TESTFUN([create_private_ticket],
|
|
|
562801 |
+[[
|
|
|
562801 |
+#include "testsuite.h"
|
|
|
562801 |
+
|
|
|
562801 |
+TS_MAIN
|
|
|
562801 |
+{
|
|
|
562801 |
+ char cwd_buf[PATH_MAX + 1];
|
|
|
562801 |
+ static const char *dirs[] = {
|
|
|
562801 |
+ NULL,
|
|
|
562801 |
+ NULL,
|
|
|
562801 |
+ };
|
|
|
562801 |
+ dirs[0] = getcwd(cwd_buf, sizeof(cwd_buf));
|
|
|
562801 |
+
|
|
|
562801 |
+ static int dir_flags[] = {
|
|
|
562801 |
+ CONF_DIR_FLAG_NONE,
|
|
|
562801 |
+ -1,
|
|
|
562801 |
+ };
|
|
|
562801 |
+
|
|
|
562801 |
+ unlink("libreport.conf");
|
|
|
562801 |
+ FILE *lrf = fopen("libreport.conf", "wx");
|
|
|
562801 |
+ assert(lrf != NULL);
|
|
|
562801 |
+ fclose(lrf);
|
|
|
562801 |
+
|
|
|
562801 |
+ assert(load_global_configuration_from_dirs(dirs, dir_flags));
|
|
|
562801 |
+
|
|
|
562801 |
+ TS_ASSERT_FALSE_MESSAGE(get_global_create_private_ticket(), "False by default");
|
|
|
562801 |
+
|
|
|
562801 |
+ set_global_create_private_ticket(false, 0);
|
|
|
562801 |
+
|
|
|
562801 |
+ TS_ASSERT_FALSE_MESSAGE(get_global_create_private_ticket(), "Still false");
|
|
|
562801 |
+
|
|
|
562801 |
+ set_global_create_private_ticket(true, 0);
|
|
|
562801 |
+
|
|
|
562801 |
+ TS_ASSERT_TRUE_MESSAGE(get_global_create_private_ticket(), "Configuration accepted");
|
|
|
562801 |
+ TS_ASSERT_STRING_EQ(getenv(CREATE_PRIVATE_TICKET), "1", "Correct ENVIRONMENT value");
|
|
|
562801 |
+
|
|
|
562801 |
+ set_global_create_private_ticket(true, 0);
|
|
|
562801 |
+
|
|
|
562801 |
+ TS_ASSERT_TRUE_MESSAGE(get_global_create_private_ticket(), "Configuration sanity");
|
|
|
562801 |
+ TS_ASSERT_STRING_EQ(getenv(CREATE_PRIVATE_TICKET), "1", "Correct ENVIRONMENT value");
|
|
|
562801 |
+
|
|
|
562801 |
+ set_global_create_private_ticket(false, 0);
|
|
|
562801 |
+
|
|
|
562801 |
+ TS_ASSERT_FALSE_MESSAGE(get_global_create_private_ticket(), "Reverted back to False");
|
|
|
562801 |
+ TS_ASSERT_STRING_NULL_OR_EMPTY(getenv(CREATE_PRIVATE_TICKET), "Correct ENVIRONMENT value");
|
|
|
562801 |
+
|
|
|
562801 |
+ xsetenv(CREATE_PRIVATE_TICKET, "1");
|
|
|
562801 |
+
|
|
|
562801 |
+ TS_ASSERT_TRUE_MESSAGE(get_global_create_private_ticket(), "Loaded from environment");
|
|
|
562801 |
+
|
|
|
562801 |
+ unsetenv(CREATE_PRIVATE_TICKET);
|
|
|
562801 |
+
|
|
|
562801 |
+ TS_ASSERT_FALSE_MESSAGE(get_global_create_private_ticket(), "Reflects environment");
|
|
|
562801 |
+
|
|
|
562801 |
+ xsetenv(CREATE_PRIVATE_TICKET, "0");
|
|
|
562801 |
+
|
|
|
562801 |
+ TS_ASSERT_FALSE_MESSAGE(get_global_create_private_ticket(), "Zero is false");
|
|
|
562801 |
+
|
|
|
562801 |
+ free_global_configuration();
|
|
|
562801 |
+}
|
|
|
562801 |
+TS_RETURN_MAIN
|
|
|
562801 |
+]])
|
|
|
562801 |
--
|
|
|
562801 |
1.8.3.1
|
|
|
562801 |
|