[PATCH] build fixes
by Jiri Moskovcak
There is the patch I promised you, it creates a new package for you abrt
http daemon called abrt-http (maybe you should consider renaming the
binary) and fixes a few build problems. Btw, I'm not sure if it
shouldn't be in /sbin rather then /bin does it make ever sense to run it
as non-root?
Jirka
13 years, 2 months
[PATCH 1/2] cleanup: get rid of GetPluginsInfo dbus call
by Nikola Pajkovsky
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
src/daemon/CommLayerServerDBus.cpp | 15 ---------
src/daemon/Daemon.cpp | 2 -
src/daemon/MiddleWare.cpp | 60 +----------------------------------
src/daemon/MiddleWare.h | 1 -
4 files changed, 2 insertions(+), 76 deletions(-)
diff --git a/src/daemon/CommLayerServerDBus.cpp b/src/daemon/CommLayerServerDBus.cpp
index 0f661f2..b0fd0ed 100644
--- a/src/daemon/CommLayerServerDBus.cpp
+++ b/src/daemon/CommLayerServerDBus.cpp
@@ -305,19 +305,6 @@ static int handle_DeleteDebugDump(DBusMessage* call, DBusMessage* reply)
return 0;
}
-static int handle_GetPluginsInfo(DBusMessage* call, DBusMessage* reply)
-{
- DBusMessageIter out_iter;
- dbus_message_iter_init_append(reply, &out_iter);
-
- map_map_string_t map_of_plugin_info;
- GetPluginsInfo(map_of_plugin_info);
- store_val(&out_iter, map_of_plugin_info);
-
- send_flush_and_unref(reply);
- return 0;
-}
-
static int handle_GetPluginSettings(DBusMessage* call, DBusMessage* reply)
{
int r;
@@ -402,8 +389,6 @@ static DBusHandlerResult message_received(DBusConnection* conn, DBusMessage* msg
r = handle_DeleteDebugDump(msg, reply);
else if (strcmp(member, "CreateReport") == 0)
r = handle_CreateReport(msg, reply);
- else if (strcmp(member, "GetPluginsInfo") == 0)
- r = handle_GetPluginsInfo(msg, reply);
else if (strcmp(member, "GetPluginSettings") == 0)
r = handle_GetPluginSettings(msg, reply);
else if (strcmp(member, "GetSettings") == 0)
diff --git a/src/daemon/Daemon.cpp b/src/daemon/Daemon.cpp
index 1d0467b..59a0726 100644
--- a/src/daemon/Daemon.cpp
+++ b/src/daemon/Daemon.cpp
@@ -65,8 +65,6 @@ using namespace std;
* Returns report_status_t (map_vector_string_t) - the status of each call.
* 2nd parameter is the contents of user's abrt.conf.
* - DeleteDebugDump(crash_id): delete it from DB and delete corresponding /var/spool/abrt/DIR
- * - GetPluginsInfo(): returns map_map_string_t
- * map["plugin"] = { "Name": "plugin", "Enabled": "yes" ... }
* - GetPluginSettings(PluginName): returns map_plugin_settings_t (map_string_t)
* - RegisterPlugin(PluginName): returns void
* - UnRegisterPlugin(PluginName): returns void
diff --git a/src/daemon/MiddleWare.cpp b/src/daemon/MiddleWare.cpp
index ffc2d63..051ffac 100644
--- a/src/daemon/MiddleWare.cpp
+++ b/src/daemon/MiddleWare.cpp
@@ -140,7 +140,8 @@ static mw_result_t CreateCrashReport(const char *dump_dir_name,
if (!uid_matches)
{
dd_close(dd);
- error_msg("Dump directory '%s' can't be accessed by user with uid %ld", dump_dir_name, caller_uid);
+ error_msg("Dump directory '%s' can't be accessed by user with uid %ld",
+ dump_dir_name, caller_uid);
r = MW_PERM_ERROR;
goto ret;
}
@@ -778,63 +779,6 @@ int DeleteDebugDump(const char *dump_dir_name, long caller_uid)
return 0; /* success */
}
-void GetPluginsInfo(map_map_string_t &map_of_plugin_info)
-{
- DIR *dir = opendir(PLUGINS_CONF_DIR);
- if (!dir)
- return;
-
- struct dirent *dent;
- while ((dent = readdir(dir)) != NULL)
- {
- char *ext = strrchr(dent->d_name, '.');
- if (!ext || strcmp(ext + 1, "conf") != 0)
- continue;
- if (!is_regular_file(dent, PLUGINS_CONF_DIR))
- continue;
- VERB3 log("Found %s", dent->d_name);
- *ext = '\0';
-
- char *glade_file = xasprintf(PLUGINS_LIB_DIR"/%s.glade", dent->d_name);
- if (access(glade_file, F_OK) == 0)
- {
- *ext = '.';
- char *conf_file = concat_path_file(PLUGINS_CONF_DIR, dent->d_name);
- *ext = '\0';
- FILE *fp = fopen(conf_file, "r");
- free(conf_file);
-
- char *descr = NULL;
- if (fp)
- {
- descr = xmalloc_fgetline(fp);
- fclose(fp);
- if (descr && strncmp("# Description:", descr, strlen("# Description:")) == 0)
- overlapping_strcpy(descr, skip_whitespace(descr + strlen("# Description:")));
- else
- {
- free(descr);
- descr = NULL;
- }
- }
- map_string_t plugin_info;
- plugin_info["Name"] = dent->d_name;
- plugin_info["Enabled"] = "yes";
- plugin_info["Type"] = "Reporter"; //was: plugin_type_str[module->GetType()]; field to be removed
- plugin_info["Version"] = VERSION; //was: module->GetVersion(); field to be removed?
- plugin_info["Description"] = descr ? descr : ""; //was: module->GetDescription();
- plugin_info["Email"] = ""; //was: module->GetEmail(); field to be removed
- plugin_info["WWW"] = ""; //was: module->GetWWW(); field to be removed
- plugin_info["GTKBuilder"] = glade_file; //was: module->GetGTKBuilder();
- free(descr);
- map_of_plugin_info[dent->d_name] = plugin_info;
- }
- free(glade_file);
-
- }
- closedir(dir);
-}
-
map_string_h *GetPluginSettings(const char *plugin_name)
{
char *conf_file = xasprintf(PLUGINS_CONF_DIR"/%s.conf", plugin_name);
diff --git a/src/daemon/MiddleWare.h b/src/daemon/MiddleWare.h
index fde2997..366a95d 100644
--- a/src/daemon/MiddleWare.h
+++ b/src/daemon/MiddleWare.h
@@ -78,7 +78,6 @@ int CreateReportThread(const char* dump_dir_name, long caller_uid, int force, c
void CreateReport(const char* dump_dir_name, long caller_uid, int force, crash_data_t **crash_data);
int DeleteDebugDump(const char *dump_dir_name, long caller_uid);
-void GetPluginsInfo(map_map_string_t &map_of_plugin_info);
map_string_h *GetPluginSettings(const char *plugin_name);
#endif /*MIDDLEWARE_H_*/
--
1.7.1
13 years, 2 months
[PATCH] Better duplicate hash
by Karel Klic
Currently the duplicate hash of a crash for Bugzilla is computed from
the package NVR (name, version, release), path of the executable, and
the backtrace hash.
This is very unfortunate because the package NVR is changed frequently
(it contains Fedora OS version), and path of the executable is not a
good differentiator. When multiple executables from a single component
crash with similar backtrace, it is better to assume that they share
code and have single Bugzilla bug report.
Please see the attached patches changing the code to compute the
duplicate hash from the component name and the backtrace hash.
Karel
13 years, 2 months
[PATCH 1/2] cli: remove last c++ism
by Nikola Pajkovsky
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
src/cli/report.cpp | 98 +++++++++++++++++++++++++--------------------------
1 files changed, 48 insertions(+), 50 deletions(-)
diff --git a/src/cli/report.cpp b/src/cli/report.cpp
index 172cb8f..f00310e 100644
--- a/src/cli/report.cpp
+++ b/src/cli/report.cpp
@@ -534,9 +534,8 @@ static char *do_log_and_save_line(char *log_line, void *param)
l_state->last_line = log_line;
return NULL;
}
-static int run_events(const char *dump_dir_name,
- const vector_string_t& events
-) {
+static int run_events(const char *dump_dir_name, GList *events)
+{
int error_cnt = 0;
GList *env_list = NULL;
@@ -546,28 +545,28 @@ static int run_events(const char *dump_dir_name,
struct run_event_state *run_state = new_run_event_state();
run_state->logging_callback = do_log_and_save_line;
run_state->logging_param = &l_state;
- for (unsigned i = 0; i < events.size(); i++)
+ for (GList *li = events; li; li = li->next)
{
- std::string event = events[i];
+ char *event = (char *) li->data;
// Export overridden settings as environment variables
- env_list = export_event_config(event.c_str());
+ env_list = export_event_config(event);
- int r = run_event_on_dir_name(run_state, dump_dir_name, event.c_str());
+ int r = run_event_on_dir_name(run_state, dump_dir_name, event);
if (r == 0 && run_state->children_count == 0)
{
l_state.last_line = xasprintf("Error: no processing is specified for event '%s'",
- event.c_str());
+ event);
r = -1;
}
if (r == 0)
{
- printf("%s: %s\n", event.c_str(), (l_state.last_line ? : "Reporting succeeded"));
+ printf("%s: %s\n", event, (l_state.last_line ? : "Reporting succeeded"));
}
else
{
error_msg("Reporting via '%s' was not successful%s%s",
- event.c_str(),
+ event,
l_state.last_line ? ": " : "",
l_state.last_line ? l_state.last_line : ""
);
@@ -741,23 +740,17 @@ int report(const char *dump_dir_name, int flags)
/* Get possible reporters associated with this particular crash */
/* TODO: npajkovs: remove this annoying c++ vector_string_t */
- vector_string_t report_events;
+ GList *report_events = NULL;
if (report_events_as_lines && *report_events_as_lines)
+ report_events = str_to_glist(report_events_as_lines, '\n');
+
+ free(report_events_as_lines);
+
+ if (!report_events)
{
- char *events = report_events_as_lines;
- while (*events)
- {
- char *end = strchrnul(events, '\n');
- char *tmp = xstrndup(events, end - events);
- report_events.push_back(tmp);
- free(tmp);
- events = end;
- if (!*events)
- break;
- events++;
- }
+ free_crash_data(crash_data);
+ error_msg_and_die(_("No reporters selected, program exiting..."));
}
- free(report_events_as_lines);
/* Get settings */
load_event_config_data();
@@ -768,7 +761,7 @@ int report(const char *dump_dir_name, int flags)
{
puts(_("Reporting..."));
errors += run_events(dump_dir_name, report_events);
- plugins += report_events.size();
+ plugins += g_list_length(report_events);
}
else
{
@@ -776,11 +769,11 @@ int report(const char *dump_dir_name, int flags)
unsigned rating = rating_str ? xatou(rating_str) : 4;
/* For every reporter, ask if user really wants to report using it. */
- vector_string_t::const_iterator it;
- for (it = report_events.begin(); it != report_events.end(); ++it)
+ for (GList *li = report_events; li; li = li->next)
{
+ char *reporter_name = (char *) li->data;
char question[255];
- snprintf(question, sizeof(question), _("Report using %s?"), it->c_str());
+ snprintf(question, sizeof(question), _("Report using %s?"), reporter_name);
if (!ask_yesno(question))
{
puts(_("Skipping..."));
@@ -788,39 +781,44 @@ int report(const char *dump_dir_name, int flags)
}
//TODO: rethink how we associate report events with configs
- if (prefixcmp(it->c_str(), "report_") == 0)
+ event_config_t *config = get_event_config(reporter_name);
+ if (config)
{
- event_config_t *config = get_event_config(it->c_str());
-
- if (config)
+ /* TODO: npajkovs; not implemented yet */
+ //const char *rating_required = get_map_string_item_or_NULL(single_plugin_settings, "RatingRequired");
+ //if (rating_required
+ // && string_to_bool(rating_required) == true
+ if (rating < 3)
{
- /* TODO: npajkovs; not implemented yet */
- //const char *rating_required = get_map_string_item_or_NULL(single_plugin_settings, "RatingRequired");
- //if (rating_required
- // && string_to_bool(rating_required) == true
- if (rating < 3)
- {
- puts(_("Reporting disabled because the backtrace is unusable"));
-
- const char *package = get_crash_item_content_or_NULL(crash_data, FILENAME_PACKAGE);
- if (package && package[0])
- printf(_("Please try to install debuginfo manually using the command: \"debuginfo-install %s\" and try again\n"), package);
-
- plugins++;
- errors++;
- continue;
- }
- ask_for_missing_settings(it->c_str());
+ puts(_("Reporting disabled because the backtrace is unusable"));
+
+ const char *package = get_crash_item_content_or_NULL(crash_data, FILENAME_PACKAGE);
+ if (package && package[0])
+ printf(_("Please try to install debuginfo manually using the command: \"debuginfo-install %s\" and try again\n"), package);
+
+ plugins++;
+ errors++;
+ continue;
}
+ ask_for_missing_settings(reporter_name);
}
- vector_string_t cur_event(1, *it);
+ /*
+ * to avoid creating list with one item, we probably should
+ * provide something like
+ * run_event(char*, char*)
+ */
+ GList *cur_event = NULL;
+ cur_event = g_list_append(cur_event, reporter_name);
errors += run_events(dump_dir_name, cur_event);
+ g_list_free(cur_event);
+
plugins++;
}
}
printf(_("Crash reported via %d report events (%d errors)\n"), plugins, errors);
free_crash_data(crash_data);
+ list_free_with_free(report_events);
return errors;
}
--
1.7.1
13 years, 2 months
debuginfo-install script problems
by Jiri Moskovcak
The python abrt-action-debuginfo-install script has a few problems:
1. it needs to be able to write to /var/cache/abrt-di
2. it needs to be able to read $HOME/.abrt/spool/
so far we're trying to achieve this by running the debuginfo-install
script under group ABRT (using SGID) and this approach has a few flaws:
1. it creates /var/cache/abrt-di/usr with owner <user>:abrt
- wher <user> is the user who actually ran it and it makes the directory
writeable for that user which is not good
2. if we use SUID instead it can't read the
$HOME/.abrt/spool/ccpp-*/coredump
solutions:
a) we can split the script into two parts:
- first part which will analyse the coredump a gets the build_ids and
feed the build_ids to the second part which will be the suided script
which donwloads and extracts the packages
b) we open the coredump and pass the file descriptor to the suided
install script
- I vote for the first solution as the second one will probably need a
selinux policy tweak, because selinux doesn't like leaking fds.
Any other ideas are more than welcome ;)
Thank you,
Jirka
13 years, 2 months
[PATCH] cli: show screen_name when abrt asks for reporters
by Nikola Pajkovsky
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
src/cli/report.c | 46 +++++++++++++++++++++++++---------------------
1 files changed, 25 insertions(+), 21 deletions(-)
diff --git a/src/cli/report.c b/src/cli/report.c
index f00310e..f7af970 100644
--- a/src/cli/report.c
+++ b/src/cli/report.c
@@ -772,36 +772,40 @@ int report(const char *dump_dir_name, int flags)
for (GList *li = report_events; li; li = li->next)
{
char *reporter_name = (char *) li->data;
+ event_config_t *config = get_event_config(reporter_name);
+ if (!config)
+ {
+ log(_("No configuration file found for '%s' reporter, skipping..."),
+ reporter_name);
+ continue;
+ }
+
char question[255];
- snprintf(question, sizeof(question), _("Report using %s?"), reporter_name);
+ snprintf(question, sizeof(question), _("Report using %s?"),
+ (config->screen_name) ? config->screen_name : reporter_name);
if (!ask_yesno(question))
{
puts(_("Skipping..."));
continue;
}
-//TODO: rethink how we associate report events with configs
- event_config_t *config = get_event_config(reporter_name);
- if (config)
+ /* TODO: npajkovs; not implemented yet */
+ //const char *rating_required = get_map_string_item_or_NULL(single_plugin_settings, "RatingRequired");
+ //if (rating_required
+ // && string_to_bool(rating_required) == true
+ if (rating < 3)
{
- /* TODO: npajkovs; not implemented yet */
- //const char *rating_required = get_map_string_item_or_NULL(single_plugin_settings, "RatingRequired");
- //if (rating_required
- // && string_to_bool(rating_required) == true
- if (rating < 3)
- {
- puts(_("Reporting disabled because the backtrace is unusable"));
-
- const char *package = get_crash_item_content_or_NULL(crash_data, FILENAME_PACKAGE);
- if (package && package[0])
- printf(_("Please try to install debuginfo manually using the command: \"debuginfo-install %s\" and try again\n"), package);
-
- plugins++;
- errors++;
- continue;
- }
- ask_for_missing_settings(reporter_name);
+ puts(_("Reporting disabled because the backtrace is unusable"));
+
+ const char *package = get_crash_item_content_or_NULL(crash_data, FILENAME_PACKAGE);
+ if (package && package[0])
+ printf(_("Please try to install debuginfo manually using the command: \"debuginfo-install %s\" and try again\n"), package);
+
+ plugins++;
+ errors++;
+ continue;
}
+ ask_for_missing_settings(reporter_name);
/*
* to avoid creating list with one item, we probably should
--
1.7.1
13 years, 2 months
[PATCH] make event xml description translatable
by Jiri Moskovcak
this patch makes following elements translatable:
event:
description - event description
option:
label -> screen_name
description -> event description (not used)
- the event xml files are now generated during make form the
corresponding *.xml.in files
the patch is run-tested, please review.
13 years, 2 months
[PATCH] rhbz#692465 - Blacklist doesn't work
by Nikola Pajkovsky
parse_value() doesn't trim the string.
Lest say BlackList = coreutils, mono
the parsed list looks like -> 'coreutils', ' mono'
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
src/cli/report.cpp | 27 ++-------------------------
src/daemon/Settings.cpp | 10 ++++++++--
src/include/abrtlib.h | 2 ++
src/lib/strbuf.c | 23 +++++++++++++++++++++++
4 files changed, 35 insertions(+), 27 deletions(-)
diff --git a/src/cli/report.cpp b/src/cli/report.cpp
index 172cb8f..e2873a2 100644
--- a/src/cli/report.cpp
+++ b/src/cli/report.cpp
@@ -23,29 +23,6 @@
#define FIELD_SEP "%----"
/*
- * Trims whitespace characters both from left and right side of a string.
- * Modifies the string in-place. Returns the trimmed string.
- */
-static char *trim(char *str)
-{
- if (!str)
- return NULL;
-
- // Remove leading spaces.
- overlapping_strcpy(str, skip_whitespace(str));
-
- // Remove trailing spaces.
- int i = strlen(str);
- while (--i >= 0)
- {
- if (!isspace(str[i]))
- break;
- }
- str[++i] = '\0';
- return str;
-}
-
-/*
* Escapes the field content string to avoid confusion with file comments.
* Returned field must be free()d by caller.
*/
@@ -226,11 +203,11 @@ static int read_crash_report_field(const char *text, crash_data_t *report,
char newvalue[length + 1];
strncpy(newvalue, textfield, length);
newvalue[length] = '\0';
- trim(newvalue);
+ strtrim(newvalue);
char oldvalue[strlen(value->content) + 1];
strcpy(oldvalue, value->content);
- trim(oldvalue);
+ strtrim(oldvalue);
// Return if no change in the contents detected.
if (strcmp(newvalue, oldvalue) == 0)
diff --git a/src/daemon/Settings.cpp b/src/daemon/Settings.cpp
index e25b795..b3d1ade 100644
--- a/src/daemon/Settings.cpp
+++ b/src/daemon/Settings.cpp
@@ -64,11 +64,14 @@ static GList *parse_list(const char* list)
struct strbuf *item = strbuf_new();
GList *l = NULL;
+ char *trim_item = NULL;
+
for (unsigned ii = 0; list[ii]; ii++)
{
if (list[ii] == ',')
{
- l = g_list_append(l, xstrdup(item->buf));
+ trim_item = strtrim(item->buf);
+ l = g_list_append(l, xstrdup(trim_item));
strbuf_clear(item);
}
else
@@ -76,7 +79,10 @@ static GList *parse_list(const char* list)
}
if (item->len > 0)
- l = g_list_append(l, xstrdup(item->buf));
+ {
+ trim_item = strtrim(item->buf);
+ l = g_list_append(l, xstrdup(trim_item));
+ }
strbuf_free(item);
return l;
diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h
index d936467..70dc300 100644
--- a/src/include/abrtlib.h
+++ b/src/include/abrtlib.h
@@ -94,6 +94,8 @@ extern "C" {
int prefixcmp(const char *str, const char *prefix);
#define suffixcmp abrt_suffixcmp
int suffixcmp(const char *str, const char *suffix);
+#define strtrim abrt_strtrim
+char *strtrim(char *str);
#define concat_path_file abrt_concat_path_file
char *concat_path_file(const char *path, const char *filename);
#define append_to_malloced_string abrt_append_to_malloced_string
diff --git a/src/lib/strbuf.c b/src/lib/strbuf.c
index f56815a..572f11c 100644
--- a/src/lib/strbuf.c
+++ b/src/lib/strbuf.c
@@ -37,6 +37,29 @@ int suffixcmp(const char *str, const char *suffix)
return strcmp(str + len_minus_suflen, suffix);
}
+/*
+ * Trims whitespace characters both from left and right side of a string.
+ * Modifies the string in-place. Returns the trimmed string.
+ */
+char *strtrim(char *str)
+{
+ if (!str)
+ return NULL;
+
+ // Remove leading spaces.
+ overlapping_strcpy(str, skip_whitespace(str));
+
+ // Remove trailing spaces.
+ int i = strlen(str);
+ while (--i >= 0)
+ {
+ if (!isspace(str[i]))
+ break;
+ }
+ str[++i] = '\0';
+ return str;
+}
+
struct strbuf *strbuf_new(void)
{
struct strbuf *buf = xzalloc(sizeof(*buf));
--
1.7.1
13 years, 2 months
[PATCH 1/2] abrt-cli: analyze on info command only when backtrace was requested
by Miroslav Lichvar
---
src/cli/cli.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/cli/cli.c b/src/cli/cli.c
index 8cace59..6e5d76b 100644
--- a/src/cli/cli.c
+++ b/src/cli/cli.c
@@ -413,16 +413,17 @@ int main(int argc, char** argv)
}
case OPT_INFO:
{
- /* Load crash_data from (possibly updated by analyze) dump dir */
+ /* Load crash_data from dump dir */
struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
if (!dd)
return -1;
char *analyze_events_as_lines = list_possible_events(dd, NULL, "analyze");
- dd_close(dd);
- if (analyze_events_as_lines && *analyze_events_as_lines)
+ if (backtrace && analyze_events_as_lines && *analyze_events_as_lines)
{
+ dd_close(dd);
+
GList *list_analyze_events = str_to_glist(analyze_events_as_lines, '\n');
free(analyze_events_as_lines);
@@ -434,12 +435,12 @@ int main(int argc, char** argv)
if (analyzer_result != 0)
return 1;
- }
- /* Load crash_data from (possibly updated by analyze) dump dir */
- dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
- if (!dd)
- return -1;
+ /* Load crash_data from (possibly updated by analyze) dump dir */
+ dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
+ if (!dd)
+ return -1;
+ }
crash_data_t *crash_data = create_crash_data_from_dump_dir(dd);
dd_close(dd);
--
1.7.4
13 years, 2 months