From 14be10f0582478983c69d567b416621783768c2d Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Wed, 9 Mar 2011 17:48:48 +0100 Subject: remove some not needed fields from event_config --- src/include/report/event_config.h | 16 ++++++++-------- src/lib/event_config.c | 17 +++++++++++------ src/lib/event_xml_parser.c | 10 +++++++--- 3 files changed, 26 insertions(+), 17 deletions(-) (limited to 'src') 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) -- cgit From bd148cd1dbb29052e7e3a49be3c0f60f714e82c7 Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Wed, 9 Mar 2011 17:53:43 +0100 Subject: wizard: minor build fix --- src/gui-wizard-gtk/wizard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') 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) { -- cgit From 62369b1a527e95c72bad4643728e0bed2fe422eb Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Wed, 9 Mar 2011 17:59:01 +0100 Subject: added loading/saving values to/from event config dialog --- src/gui-gtk/event_config_dialog.c | 67 +++++++++++++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gui-gtk/event_config_dialog.c b/src/gui-gtk/event_config_dialog.c index 50bdc4f8..960e4fca 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,6 +41,14 @@ 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; @@ -50,12 +65,14 @@ static void add_option_to_dialog(event_option_t *option) 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); @@ -64,6 +81,10 @@ static void add_option_to_dialog(event_option_t *option) 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); @@ -73,6 +94,8 @@ static void add_option_to_dialog(event_option_t *option) 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 +103,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 +165,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("%s\n%s", ec->name, ec->description); + if(ec->screen_name != NULL && ec->description != NULL) + event_label = xasprintf("%s\n%s", ec->screen_name, ec->description); else //if event has no xml description event_label = xasprintf("%s\nNo description available", key); @@ -155,10 +179,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 +235,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)); -- cgit From 0711539d8d6a13e67db9321d9f8295b6e816afbb Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 9 Mar 2011 18:06:42 +0100 Subject: rename Bugzilla.xml to report_Bugzilla.xml Signed-off-by: Denys Vlasenko --- src/plugins/Bugzilla.xml | 30 ------------------------------ src/plugins/Makefile.am | 2 +- src/plugins/report_Bugzilla.xml | 30 ++++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 31 deletions(-) delete mode 100644 src/plugins/Bugzilla.xml create mode 100644 src/plugins/report_Bugzilla.xml (limited to 'src') diff --git a/src/plugins/Bugzilla.xml b/src/plugins/Bugzilla.xml deleted file mode 100644 index bc8e8ecb..00000000 --- a/src/plugins/Bugzilla.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - Bugzilla - Report this problem to the Red Hat bug tracker - Reports selected problems to the Red Hat bug tracker - - - - - - - - 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/report_Bugzilla.xml b/src/plugins/report_Bugzilla.xml new file mode 100644 index 00000000..bc8e8ecb --- /dev/null +++ b/src/plugins/report_Bugzilla.xml @@ -0,0 +1,30 @@ + + + Bugzilla + Report this problem to the Red Hat bug tracker + Reports selected problems to the Red Hat bug tracker + + + + + + + + -- cgit From d817777ee21f2888bbe5f80fc8d7215583989b7e Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Wed, 9 Mar 2011 18:55:21 +0100 Subject: use variable name from conf file if xml description doesn't exist --- src/gui-gtk/event_config_dialog.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui-gtk/event_config_dialog.c b/src/gui-gtk/event_config_dialog.c index 960e4fca..156c9e22 100644 --- a/src/gui-gtk/event_config_dialog.c +++ b/src/gui-gtk/event_config_dialog.c @@ -54,11 +54,17 @@ 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, @@ -75,7 +81,7 @@ static void add_option_to_dialog(event_option_t *option) 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, @@ -87,7 +93,7 @@ static void add_option_to_dialog(event_option_t *option) 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, -- cgit From d67c6ee3d6b3067d8697ee5e4a131af906789583 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 10 Mar 2011 10:03:19 +0100 Subject: abrt-action-install-debuginfo: prevent $PATH attack Signed-off-by: Denys Vlasenko --- src/plugins/abrt-action-install-debuginfo.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') 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 #include -#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); } -- cgit