diff options
-rw-r--r-- | abrt.spec | 2 | ||||
-rw-r--r-- | src/gui-gtk/event_config_dialog.c | 79 | ||||
-rw-r--r-- | src/gui-wizard-gtk/wizard.c | 2 | ||||
-rw-r--r-- | src/include/report/event_config.h | 16 | ||||
-rw-r--r-- | src/lib/event_config.c | 17 | ||||
-rw-r--r-- | src/lib/event_xml_parser.c | 10 | ||||
-rw-r--r-- | src/plugins/Makefile.am | 2 | ||||
-rw-r--r-- | src/plugins/abrt-action-install-debuginfo.c | 9 | ||||
-rw-r--r-- | src/plugins/report_Bugzilla.xml (renamed from src/plugins/Bugzilla.xml) | 0 |
9 files changed, 106 insertions, 31 deletions
@@ -510,7 +510,7 @@ fi %files plugin-bugzilla %defattr(-,root,root,-) %config(noreplace) %{_sysconfdir}/%{name}/plugins/Bugzilla.conf -%{_sysconfdir}/%{name}/events/Bugzilla.xml +%{_sysconfdir}/%{name}/events/report_Bugzilla.xml %{_libdir}/%{name}/Bugzilla.glade %{_mandir}/man7/abrt-Bugzilla.7.gz %{_bindir}/abrt-action-bugzilla diff --git a/src/gui-gtk/event_config_dialog.c b/src/gui-gtk/event_config_dialog.c index 50bdc4f8..156c9e22 100644 --- a/src/gui-gtk/event_config_dialog.c +++ b/src/gui-gtk/event_config_dialog.c @@ -3,6 +3,7 @@ static GtkWidget *option_table; static GtkWidget *parent_dialog; +static GList *option_widget_list; static int last_row = 0; enum @@ -12,6 +13,12 @@ enum NUM_COLUMNS }; +typedef struct +{ + event_option_t *option; + GtkWidget *widget; +} option_widget_t; + static void show_event_config_dialog(event_config_t* event); static void show_error_message(const char* message) @@ -34,45 +41,67 @@ GtkWidget *gtk_label_new_justify_left(const gchar *label_str) return label; } +static void add_option_widget(GtkWidget *widget, event_option_t *option) +{ + option_widget_t *ow = (option_widget_t *)xmalloc(sizeof(option_widget_t)); + ow->widget = widget; + ow->option = option; + option_widget_list = g_list_prepend(option_widget_list, ow); +} + static void add_option_to_dialog(event_option_t *option) { GtkWidget *label; GtkWidget *option_input; GtkWidget *option_hbox = gtk_hbox_new(FALSE, 0); + char *option_label; + if(option->label != NULL) + option_label = option->label; + else + option_label = option->name; + switch(option->type) { case OPTION_TYPE_TEXT: case OPTION_TYPE_NUMBER: - label = gtk_label_new_justify_left(option->label); + label = gtk_label_new_justify_left(option_label); gtk_table_attach(GTK_TABLE(option_table), label, 0, 1, last_row, last_row+1, GTK_FILL, GTK_FILL, 0,0); option_input = gtk_entry_new(); + if(option->value != NULL) + gtk_entry_set_text(GTK_ENTRY(option_input), option->value); gtk_table_attach(GTK_TABLE(option_table), option_input, 1, 2, last_row, last_row+1, GTK_FILL, GTK_FILL, 0,0); - + add_option_widget(option_input, option); break; case OPTION_TYPE_BOOL: - option_input = gtk_check_button_new_with_label(option->label); + option_input = gtk_check_button_new_with_label(option_label); gtk_table_attach(GTK_TABLE(option_table), option_input, 0, 2, last_row, last_row+1, GTK_FILL, GTK_FILL, 0,0); + if(option->value != NULL) + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(option_input), + (strcmp("yes",option->value)==0)); + add_option_widget(option_input, option); break; case OPTION_TYPE_PASSWORD: - label = gtk_label_new_justify_left(option->label); + label = gtk_label_new_justify_left(option_label); gtk_table_attach(GTK_TABLE(option_table), label, 0, 1, last_row, last_row+1, GTK_FILL, GTK_FILL, 0,0); option_input = gtk_entry_new(); + if(option->value != NULL) + gtk_entry_set_text(GTK_ENTRY(option_input), option->value); gtk_table_attach(GTK_TABLE(option_table), option_input, 1, 2, last_row, last_row+1, @@ -80,9 +109,10 @@ static void add_option_to_dialog(event_option_t *option) 0,0); gtk_entry_set_visibility(GTK_ENTRY(option_input), 0); + add_option_widget(option_input, option); break; default: - option_input = gtk_label_new_justify_left("WTF?"); + //option_input = gtk_label_new_justify_left("WTF?"); g_print("unsupported option type\n"); } last_row++; @@ -141,8 +171,8 @@ static void add_event_to_liststore(gpointer key, gpointer value, gpointer user_d GtkListStore *events_list_store = (GtkListStore *)user_data; event_config_t *ec = (event_config_t *)value; char *event_label = NULL; - if(ec->name != NULL && ec->description != NULL) - event_label = xasprintf("<b>%s</b>\n%s", ec->name, ec->description); + if(ec->screen_name != NULL && ec->description != NULL) + event_label = xasprintf("<b>%s</b>\n%s", ec->screen_name, ec->description); else //if event has no xml description event_label = xasprintf("<b>%s</b>\nNo description available", key); @@ -155,10 +185,41 @@ static void add_event_to_liststore(gpointer key, gpointer value, gpointer user_d -1); } +static void save_value_from_widget(gpointer data, gpointer user_data) +{ + option_widget_t *ow = (option_widget_t *)data; + switch(ow->option->type) + { + case OPTION_TYPE_TEXT: + case OPTION_TYPE_NUMBER: + case OPTION_TYPE_PASSWORD: + ow->option->value = (char *)gtk_entry_get_text(GTK_ENTRY(ow->widget)); + break; + case OPTION_TYPE_BOOL: + ow->option->value = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ow->widget)) ? xstrdup("yes") : xstrdup("no"); + break; + default: + g_print("unsupported option type\n"); + } + VERB1 log("saved: %s:%s", ow->option->name, ow->option->value); +} + +static void dehydrate_config_dialog() +{ + if(option_widget_list != NULL) + g_list_foreach(option_widget_list, &save_value_from_widget, NULL); +} + static void show_event_config_dialog(event_config_t* event) { + if(option_widget_list != NULL) + { + g_list_free(option_widget_list); + option_widget_list = NULL; + } + GtkWidget *dialog = gtk_dialog_new_with_buttons( - event->name, + event->screen_name, GTK_WINDOW(parent_dialog), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, @@ -180,7 +241,7 @@ static void show_event_config_dialog(event_config_t* event) gtk_widget_show_all(option_table); int result = gtk_dialog_run(GTK_DIALOG(dialog)); if(result == GTK_RESPONSE_APPLY) - g_print("apply\n"); + dehydrate_config_dialog(); else if(result == GTK_RESPONSE_CANCEL) g_print("cancel\n"); gtk_widget_destroy(GTK_WIDGET(dialog)); diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c index 156d05f0..d261d4ce 100644 --- a/src/gui-wizard-gtk/wizard.c +++ b/src/gui-wizard-gtk/wizard.c @@ -525,7 +525,7 @@ static GList *export_event_config(const char *event_name) g_hash_table_iter_init(&iter, g_event_config_list); while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&cfg)) { - if (strcmp(cfg->name, event_name) != 0) + if (strcmp(name, event_name) != 0) continue; for (GList *lopt = cfg->options; lopt; lopt = lopt->next) { diff --git a/src/include/report/event_config.h b/src/include/report/event_config.h index e2310885..75fb0c78 100644 --- a/src/include/report/event_config.h +++ b/src/include/report/event_config.h @@ -47,9 +47,9 @@ typedef struct char *value; char *label; option_type_t type; - char *description; //can be used as tooltip in gtk app - char *allowed_value; - int required; + //char *description; //can be used as tooltip in gtk app + //char *allowed_value; + //int required; } event_option_t; event_option_t *new_event_option(void); @@ -58,10 +58,10 @@ void free_event_option(event_option_t *p); //structure to hold the option data typedef struct { - char *name; //name of the event "Bugzilla" "RedHat Support Uploader" - char *title; //window title - not used right now, maybe the "name" is enough? - char *action;//action description to show in gui like: Upload report to the Red Hat bugzilla" - char *description; + char *screen_name; //name of the event "Bugzilla" "RedHat Support Uploader" + //char *title; //window title - not used right now, maybe the "name" is enough? + //char *action;//action description to show in gui like: Upload report to the Red Hat bugzilla" + char *description; // "Report to ...."/"Save to file" GList *options; } event_config_t; @@ -75,7 +75,7 @@ void load_event_description_from_file(event_config_t *event_config, const char* void load_event_config_data(void); /* Frees all loaded data */ void free_event_config_data(void); -event_config_t *get_event_config(const char *name); +event_config_t *get_event_config(const char *event_name); extern GHashTable *g_event_config_list; // for iterating through entire list of all loaded configs diff --git a/src/lib/event_config.c b/src/lib/event_config.c index a79ee40c..02df048f 100644 --- a/src/lib/event_config.c +++ b/src/lib/event_config.c @@ -19,8 +19,8 @@ void free_event_option(event_option_t *p) free(p->name); free(p->value); free(p->label); - free(p->description); - free(p->allowed_value); + //free(p->description); + //free(p->allowed_value); free(p); } @@ -28,9 +28,9 @@ void free_event_config(event_config_t *p) { if (!p) return; - free(p->name); - free(p->title); - free(p->action); + free(p->screen_name); + //free(p->title); + //free(p->action); free(p->description); for (GList *opt = p->options; opt; opt = opt->next) free_event_option(opt->data); @@ -39,6 +39,11 @@ void free_event_config(event_config_t *p) } +static int mystrcmp(gconstpointer a, gconstpointer b) +{ + return strcmp( ((event_option_t *)a)->name, (char *)b); +} + // (Re)loads data from /etc/abrt/events/*.{conf,xml} void load_event_config_data(void) { @@ -91,7 +96,7 @@ void load_event_config_data(void) while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value)) { event_option_t *opt; - GList *elem = g_list_find(event_config->options, name); + GList *elem = g_list_find_custom(event_config->options, name, &mystrcmp); if (elem) { opt = elem->data; diff --git a/src/lib/event_xml_parser.c b/src/lib/event_xml_parser.c index be4a9e09..c1f200ec 100644 --- a/src/lib/event_xml_parser.c +++ b/src/lib/event_xml_parser.c @@ -6,7 +6,7 @@ #define DESCRIPTION_ELEMENT "description" #define ALLOW_EMPTY_ELEMENT "allow-empty" #define OPTION_ELEMENT "option" -#define ACTION_ELEMENT "action" +//#define ACTION_ELEMENT "action" #define NAME_ELEMENT "name" static int in_option = 0; //FIXME @@ -110,6 +110,7 @@ static void text(GMarkupParseContext *context, option->label = _text; return; } + /* if (strcmp(inner_element, DESCRIPTION_ELEMENT) == 0) { VERB2 log("tooltip:'%s'", _text); @@ -117,10 +118,12 @@ static void text(GMarkupParseContext *context, option->description = _text; return; } + */ } else { /* we're not in option, so the description is for the event */ + /* if (strcmp(inner_element, ACTION_ELEMENT) == 0) { VERB2 log("action description:'%s'", _text); @@ -128,11 +131,12 @@ static void text(GMarkupParseContext *context, ui->action = _text; return; } + */ if (strcmp(inner_element, NAME_ELEMENT) == 0) { VERB2 log("event name:'%s'", _text); - free(ui->name); - ui->name = _text; + free(ui->screen_name); + ui->screen_name = _text; return; } if (strcmp(inner_element, DESCRIPTION_ELEMENT) == 0) diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index 3c4b37cf..4548c67c 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -41,7 +41,7 @@ dist_pluginsconf_DATA = \ eventsdir = $(EVENTS_DIR) dist_events_DATA = \ - Bugzilla.xml + report_Bugzilla.xml eventsconfdir = $(EVENTS_CONF_DIR) diff --git a/src/plugins/abrt-action-install-debuginfo.c b/src/plugins/abrt-action-install-debuginfo.c index 39915e59..77cd370b 100644 --- a/src/plugins/abrt-action-install-debuginfo.c +++ b/src/plugins/abrt-action-install-debuginfo.c @@ -1,7 +1,8 @@ #include <unistd.h> #include <string.h> -#define EXECUTABLE "abrt-action-install-debuginfo.py" +// TODO: honor configure --prefix here: +#define EXECUTABLE "/usr/bin/abrt-action-install-debuginfo.py" static void error_msg_and_die(const char *msg, const char *arg) { @@ -38,6 +39,10 @@ int main(int argc, char **argv) error_msg_and_die("bad option", arg); } - execvp(EXECUTABLE, argv); + /* We use full path, and execv instead of execvp in order to + * disallow user to execute his own abrt-action-install-debuginfo.py + * in his dir by setting up corresponding malicious $PATH. + */ + execv(EXECUTABLE, argv); error_msg_and_die("Can't execute", EXECUTABLE); } diff --git a/src/plugins/Bugzilla.xml b/src/plugins/report_Bugzilla.xml index bc8e8ecb..bc8e8ecb 100644 --- a/src/plugins/Bugzilla.xml +++ b/src/plugins/report_Bugzilla.xml |