summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Moskovcak <jmoskovc@redhat.com>2011-03-15 20:34:14 +0100
committerJiri Moskovcak <jmoskovc@redhat.com>2011-03-15 20:34:14 +0100
commit8862ed2cc130b922c2ac7af3df5eeeef36bf5ef1 (patch)
tree89614f3932f517c3643f5c3393d0ed065456f253
parentd4a9561ce1005486fa4d5f63ad4fca43c2c736fd (diff)
parent694c033eaaf1fef39667ca4503bb15a4b9e4ec6d (diff)
downloadabrt-8862ed2cc130b922c2ac7af3df5eeeef36bf5ef1.tar.gz
abrt-8862ed2cc130b922c2ac7af3df5eeeef36bf5ef1.tar.xz
abrt-8862ed2cc130b922c2ac7af3df5eeeef36bf5ef1.zip
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
-rw-r--r--src/gui-wizard-gtk/wizard.c2
-rw-r--r--src/lib/event_config.c42
2 files changed, 42 insertions, 2 deletions
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
index 9a642f59..458fba29 100644
--- a/src/gui-wizard-gtk/wizard.c
+++ b/src/gui-wizard-gtk/wizard.c
@@ -423,7 +423,7 @@ VERB2 log("removing all buttons from box %p", box);
else
event_screen_name = event_name;
const char *event_description = NULL;
- event_config_t *cfg = g_hash_table_lookup(g_event_config_list, event_name);
+ event_config_t *cfg = get_event_config(event_name);
if (cfg)
{
/* .xml has (presumably) prettier description, use it: */
diff --git a/src/lib/event_config.c b/src/lib/event_config.c
index e38041b8..6207f721 100644
--- a/src/lib/event_config.c
+++ b/src/lib/event_config.c
@@ -19,6 +19,7 @@
#include "abrtlib.h"
GHashTable *g_event_config_list;
+static GHashTable *g_event_config_symlinks;
event_option_t *new_event_option(void)
{
@@ -82,6 +83,13 @@ void load_event_config_data(void)
/*key_destroy_func:*/ free,
/*value_destroy_func:*/ (GDestroyNotify) free_event_config
);
+ if (!g_event_config_symlinks)
+ g_event_config_symlinks = g_hash_table_new_full(
+ /*hash_func*/ g_str_hash,
+ /*key_equal_func:*/ g_str_equal,
+ /*key_destroy_func:*/ free,
+ /*value_destroy_func:*/ free
+ );
DIR *dir;
struct dirent *dent;
@@ -99,8 +107,29 @@ void load_event_config_data(void)
continue;
char *fullname = concat_path_file(EVENTS_DIR, dent->d_name);
-
*ext = '\0';
+
+ struct stat buf;
+ if (0 != lstat(fullname, &buf))
+ continue;
+ if (S_ISLNK(buf.st_mode))
+ {
+ GError *error = NULL;
+ gchar *link = g_file_read_link(fullname, &error);
+ if (error != NULL)
+ error_msg_and_die("Error reading symlink '%s': %s", fullname, error->message);
+
+ gchar *target = g_path_get_basename(link);
+ char *ext = strrchr(target, '.');
+ if (!ext || 0 != strcmp(ext + 1, "xml"))
+ error_msg_and_die("Invalid event symlink '%s': expected it to point to another xml file", fullname);
+ *ext = '\0';
+ g_hash_table_replace(g_event_config_symlinks, xstrdup(dent->d_name), target);
+ g_free(link);
+ /* don't free target, it is owned by the hash table now */
+ continue;
+ }
+
event_config_t *event_config = get_event_config(dent->d_name);
bool new_config = (!event_config);
if (new_config)
@@ -181,11 +210,22 @@ void free_event_config_data(void)
g_hash_table_destroy(g_event_config_list);
g_event_config_list = NULL;
}
+ if (g_event_config_symlinks)
+ {
+ g_hash_table_destroy(g_event_config_symlinks);
+ g_event_config_symlinks = NULL;
+ }
}
event_config_t *get_event_config(const char *name)
{
if (!g_event_config_list)
return NULL;
+ if (g_event_config_symlinks)
+ {
+ char *link = g_hash_table_lookup(g_event_config_symlinks, name);
+ if (link)
+ name = link;
+ }
return g_hash_table_lookup(g_event_config_list, name);
}