summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKarel Klic <kklic@redhat.com>2009-11-20 12:22:36 +0100
committerKarel Klic <kklic@redhat.com>2009-11-20 12:22:36 +0100
commit18363807e6ffa8dab5a76f40bacac3695985147a (patch)
tree8195336c29136a4761db501160c9f4620b16aa70 /src
parentbd60681c8227bc31ef0991e98a9a3e849032c924 (diff)
parent6ec2390e40ba4b0f6e10a2c8ce858d3431b34964 (diff)
downloadabrt-18363807e6ffa8dab5a76f40bacac3695985147a.tar.gz
abrt-18363807e6ffa8dab5a76f40bacac3695985147a.tar.xz
abrt-18363807e6ffa8dab5a76f40bacac3695985147a.zip
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'src')
-rw-r--r--src/Daemon/MiddleWare.cpp160
-rw-r--r--src/Daemon/PluginManager.cpp11
-rw-r--r--src/Gui/CCMainWindow.py4
-rw-r--r--src/Gui/CCReporterDialog.py44
-rw-r--r--src/Gui/ConfBackend.py2
-rw-r--r--src/Gui/PluginsSettingsDialog.py4
-rw-r--r--src/Gui/report.glade8
-rw-r--r--src/Hooks/dumpoops.cpp7
8 files changed, 162 insertions, 78 deletions
diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp
index 66bdea67..f3c6bdf4 100644
--- a/src/Daemon/MiddleWare.cpp
+++ b/src/Daemon/MiddleWare.cpp
@@ -64,6 +64,62 @@ static vector_pair_string_string_t s_vectorActionsAndReporters;
static void RunAnalyzerActions(const char *pAnalyzer, const char *pDebugDumpDir);
+static char* is_text_file(const char *name, ssize_t *sz)
+{
+ /* We were using magic.h API to check for file being text, but it thinks
+ * that file containing just "0" is not text (!!)
+ * So, we do it ourself.
+ */
+
+ int fd = open(name, O_RDONLY);
+ if (fd < 0)
+ return NULL; /* it's not text (because it does not exist! :) */
+
+ char *buf = (char*)xmalloc(*sz);
+ ssize_t r = *sz = full_read(fd, buf, *sz);
+ close(fd);
+ if (r < 0)
+ {
+ free(buf);
+ return NULL; /* it's not text (because we can't read it) */
+ }
+
+ /* Some files in our dump directories are known to always be textual */
+ if (strcmp(name, "backtrace") == 0
+ || strcmp(name, "cmdline") == 0
+ ) {
+ return buf;
+ }
+
+ /* Every once in a while, even a text file contains a few garbled
+ * or unexpected non-ASCII chars. We should not declare it "binary".
+ */
+ const unsigned RATIO = 50;
+ unsigned total_chars = r + RATIO;
+ unsigned bad_chars = 1; /* 1 prevents division by 0 later */
+ while (--r >= 0)
+ {
+ if (buf[r] >= 0x7f
+ /* among control chars, only '\t','\n' etc are allowed */
+ || (buf[r] < ' ' && !isspace(buf[r]))
+ ) {
+ if (buf[r] == '\0')
+ {
+ /* We don't like NULs very much. Not text for sure! */
+ free(buf);
+ return NULL;
+ }
+ bad_chars++;
+ }
+ }
+
+ if ((total_chars / bad_chars) >= RATIO)
+ return buf; /* looks like text to me */
+
+ free(buf);
+ return NULL; /* it's binary */
+}
+
/**
* Transforms a debugdump direcortry to inner crash
* report form. This form is used for later reporting.
@@ -72,63 +128,69 @@ static void RunAnalyzerActions(const char *pAnalyzer, const char *pDebugDumpDir)
*/
static void DebugDumpToCrashReport(const char *pDebugDumpDir, map_crash_report_t& pCrashReport)
{
- std::string fileName;
- std::string content;
- bool isTextFile;
CDebugDump dd;
dd.Open(pDebugDumpDir);
-
- if (!dd.Exist(FILENAME_ARCHITECTURE) ||
- !dd.Exist(FILENAME_KERNEL) ||
- !dd.Exist(FILENAME_PACKAGE) ||
- !dd.Exist(FILENAME_COMPONENT) ||
- !dd.Exist(FILENAME_RELEASE) ||
- !dd.Exist(FILENAME_EXECUTABLE))
- {
- throw CABRTException(EXCEP_ERROR, "DebugDumpToCrashReport(): One or more of important file(s)'re missing");
+ if (!dd.Exist(FILENAME_ARCHITECTURE)
+ || !dd.Exist(FILENAME_KERNEL)
+ || !dd.Exist(FILENAME_PACKAGE)
+ || !dd.Exist(FILENAME_COMPONENT)
+ || !dd.Exist(FILENAME_RELEASE)
+ || !dd.Exist(FILENAME_EXECUTABLE)
+ ) {
+ throw CABRTException(EXCEP_ERROR, "DebugDumpToCrashReport(): One or more of important file(s) are missing");
}
+ std::string short_name;
+ std::string full_name;
pCrashReport.clear();
dd.InitGetNextFile();
- while (dd.GetNextFile(fileName, content, isTextFile))
+ while (dd.GetNextFile(&short_name, &full_name))
{
- //VERB3 log(" file:'%s' text:%d", fileName.c_str(), isTextFile);
- if (!isTextFile)
+ ssize_t sz = 4*1024;
+ char *text = is_text_file(full_name.c_str(), &sz);
+ if (!text)
{
add_crash_data_to_crash_report(pCrashReport,
- fileName,
+ short_name,
CD_BIN,
CD_ISNOTEDITABLE,
- concat_path_file(pDebugDumpDir, fileName.c_str())
+ full_name
);
+ continue;
}
- else
- {
- if (fileName == FILENAME_ARCHITECTURE ||
- fileName == FILENAME_KERNEL ||
- fileName == FILENAME_PACKAGE ||
- fileName == FILENAME_COMPONENT ||
- fileName == FILENAME_RELEASE ||
- fileName == FILENAME_EXECUTABLE)
- {
- add_crash_data_to_crash_report(pCrashReport, fileName, CD_TXT, CD_ISNOTEDITABLE, content);
- }
- else if (fileName != FILENAME_UID &&
- fileName != FILENAME_ANALYZER &&
- fileName != FILENAME_TIME &&
- fileName != FILENAME_DESCRIPTION &&
- fileName != FILENAME_REPRODUCE &&
- fileName != FILENAME_COMMENT)
- {
- if (content.length() < CD_ATT_SIZE)
- {
- add_crash_data_to_crash_report(pCrashReport, fileName, CD_TXT, CD_ISEDITABLE, content);
- }
- else
- {
- add_crash_data_to_crash_report(pCrashReport, fileName, CD_ATT, CD_ISEDITABLE, content);
- }
- }
+
+ std::string content;
+ if (sz < 4*1024) /* is_text_file did read entire file */
+ content.assign(text, sz);
+ else /* no, need to read it all */
+ dd.LoadText(short_name.c_str(), content);
+ free(text);
+
+ if (short_name == FILENAME_ARCHITECTURE
+ || short_name == FILENAME_KERNEL
+ || short_name == FILENAME_PACKAGE
+ || short_name == FILENAME_COMPONENT
+ || short_name == FILENAME_RELEASE
+ || short_name == FILENAME_EXECUTABLE
+ ) {
+ add_crash_data_to_crash_report(pCrashReport, short_name, CD_TXT, CD_ISNOTEDITABLE, content);
+ continue;
+ }
+
+ if (short_name != FILENAME_UID
+ && short_name != FILENAME_ANALYZER
+ && short_name != FILENAME_TIME
+ && short_name != FILENAME_DESCRIPTION
+ && short_name != FILENAME_REPRODUCE
+ && short_name != FILENAME_COMMENT
+ ) {
+ add_crash_data_to_crash_report(
+ pCrashReport,
+ short_name,
+ (content.length() < CD_ATT_SIZE ? CD_TXT : CD_ATT),
+ CD_ISEDITABLE,
+ content
+ );
}
}
}
@@ -139,8 +201,7 @@ static void DebugDumpToCrashReport(const char *pDebugDumpDir, map_crash_report_t
* @param pDebugDumpDir A debugdump dir containing all necessary data.
* @return A local UUID.
*/
-static std::string GetLocalUUID(const char *pAnalyzer,
- const char *pDebugDumpDir)
+static std::string GetLocalUUID(const char *pAnalyzer, const char *pDebugDumpDir)
{
CAnalyzer* analyzer = g_pPluginManager->GetAnalyzer(pAnalyzer);
return analyzer->GetLocalUUID(pDebugDumpDir);
@@ -319,12 +380,17 @@ static bool CheckReport(const map_crash_report_t& pCrashReport)
map_crash_report_t::const_iterator end = pCrashReport.end();
+ if (it_package == end)
+ {
+ return false;
+ }
+
// FIXME: bypass the test if it's kerneloops
if (it_package->second[CD_CONTENT] == "kernel")
return true;
if (it_analyzer == end || it_mwuid == end ||
- it_mwuuid == end || it_package == end ||
+ it_mwuuid == end || /* it_package == end || */
it_architecture == end || it_kernel == end ||
it_component == end || it_release == end ||
it_executable == end)
diff --git a/src/Daemon/PluginManager.cpp b/src/Daemon/PluginManager.cpp
index 3867ec9b..2f4d8750 100644
--- a/src/Daemon/PluginManager.cpp
+++ b/src/Daemon/PluginManager.cpp
@@ -58,9 +58,9 @@ bool LoadPluginSettings(const char *pPath, map_plugin_settings_t& pSettings)
std::string value;
for (ii = 0; ii < line.length(); ii++)
{
- if (line[ii] == '\"')
+ if (line[ii] == '"')
{
- in_quote = in_quote == true ? false : true;
+ in_quote = !in_quote;
}
if (isspace(line[ii]) && !in_quote)
{
@@ -166,9 +166,10 @@ void CPluginManager::LoadPlugin(const char *pName)
{
std::string libPath = ssprintf(PLUGINS_LIB_DIR"/"PLUGINS_LIB_PREFIX"%s."PLUGINS_LIB_EXTENSION, pName);
abrtPlugin = new CABRTPlugin(libPath.c_str());
- if (abrtPlugin->GetMagicNumber() != PLUGINS_MAGIC_NUMBER ||
- (abrtPlugin->GetType() < ANALYZER && abrtPlugin->GetType() > DATABASE))
- {
+ if (abrtPlugin->GetMagicNumber() != PLUGINS_MAGIC_NUMBER
+ || abrtPlugin->GetType() < 0
+ || abrtPlugin->GetType() > MAX_PLUGIN_TYPE
+ ) {
throw CABRTException(EXCEP_PLUGIN, "CPluginManager::LoadPlugin(): non-compatible plugin");
}
log("Plugin %s (%s) succesfully loaded", pName, abrtPlugin->GetVersion());
diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py
index 3ada6f25..ee802a88 100644
--- a/src/Gui/CCMainWindow.py
+++ b/src/Gui/CCMainWindow.py
@@ -305,7 +305,9 @@ class MainWindow():
self.pBarWindow.show_all()
self.timer = gobject.timeout_add(100, self.progress_update_cb)
reporters_settings = {}
- self.pluginlist = getPluginInfoList(self.ccdaemon, refresh=True)
+ # self.pluginlist = getPluginInfoList(self.ccdaemon, refresh=True)
+ # don't force refresh!
+ self.pluginlist = getPluginInfoList(self.ccdaemon)
for plugin in self.pluginlist.getReporterPlugins():
reporters_settings[str(plugin)] = plugin.Settings
self.ccdaemon.Report(result, reporters_settings)
diff --git a/src/Gui/CCReporterDialog.py b/src/Gui/CCReporterDialog.py
index 5db06963..16f5843f 100644
--- a/src/Gui/CCReporterDialog.py
+++ b/src/Gui/CCReporterDialog.py
@@ -15,9 +15,15 @@ from PluginList import getPluginInfoList
from abrt_utils import _
# FIXME - create method or smth that returns type|editable|content
-TYPE = 0
-EDITABLE = 1
-CONTENT = 2
+CD_TYPE = 0
+CD_EDITABLE = 1
+CD_CONTENT = 2
+
+CD_SYS = "s"
+CD_BIN = "b"
+CD_TXT = "t"
+CD_ATT = "a"
+
# response
REFRESH = -50
@@ -175,8 +181,8 @@ class ReporterDialog():
buff = gtk.TextBuffer()
comment = _("Brief description how to reproduce this or what you did...")
try:
- if self.report[item][CONTENT]:
- comment = self.report[item][CONTENT]
+ if self.report[item][CD_CONTENT]:
+ comment = self.report[item][CD_CONTENT]
self.comment_changed = True
except Exception, e:
pass
@@ -189,8 +195,8 @@ class ReporterDialog():
buff = gtk.TextBuffer()
how_to_reproduce = _("")
try:
- if self.report[item][CONTENT]:
- how_to_reproduce = self.report[item][CONTENT]
+ if self.report[item][CD_CONTENT]:
+ how_to_reproduce = self.report[item][CD_CONTENT]
self.how_to_changed = True
except Exception, e:
pass
@@ -202,7 +208,7 @@ class ReporterDialog():
# if an backtrace has rating use it
if item == "rating":
try:
- package = self.report["package"][CONTENT]
+ package = self.report["package"][CD_CONTENT]
# if we don't have package for some reason
except:
package = None
@@ -210,7 +216,7 @@ class ReporterDialog():
lErrors = self.wTree.get_widget("lErrors")
bSend = self.wTree.get_widget("bSend")
# not usable report
- if int(self.report[item][CONTENT]) < 3:
+ if int(self.report[item][CD_CONTENT]) < 3:
ebErrors.show()
ebErrors.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("red"))
if package:
@@ -220,7 +226,7 @@ class ReporterDialog():
lErrors.set_markup("<span color=\"white\">%s</span>" % _("The bactrace is unusable, you can't report this!"))
bSend.set_sensitive(False)
# probably usable 3
- elif int(self.report[item][CONTENT]) < 4:
+ elif int(self.report[item][CD_CONTENT]) < 4:
ebErrors.show()
ebErrors.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("yellow"))
lErrors.set_markup("<span color=\"black\">%s</span>" % _("The bactrace is incomplete, please make sure you provide good steps to reproduce."))
@@ -229,36 +235,36 @@ class ReporterDialog():
ebErrors.hide()
bSend.set_sensitive(True)
- if self.report[item][TYPE] != 's':
+ if self.report[item][CD_TYPE] != CD_SYS:
# item name 0| value 1| editable? 2| toggled? 3| visible?(attachment)4
- if self.report[item][EDITABLE] == 'y':
+ if self.report[item][CD_EDITABLE] == 'y':
self.editable.append(item)
- self.row_dict[item] = self.reportListStore.append([item, self.report[item][CONTENT],
+ self.row_dict[item] = self.reportListStore.append([item, self.report[item][CD_CONTENT],
item in self.editable, True,
- self.report[item][TYPE] in ['a','b']])
+ self.report[item][CD_TYPE] in [CD_ATT,CD_BIN]])
def dehydrate(self):
attributes = ["item", "content", "editable", "send", "attachment"]
for row in self.reportListStore:
rowe = dict(zip(attributes, row))
if not rowe["editable"] and not rowe["attachment"]:
- self.report[rowe["item"]][CONTENT] = rowe["content"]
+ self.report[rowe["item"]][CD_CONTENT] = rowe["content"]
elif rowe["editable"] and not rowe["attachment"]:
- self.report[rowe["item"]][CONTENT] = rowe["content"]
+ self.report[rowe["item"]][CD_CONTENT] = rowe["content"]
elif (rowe["attachment"] or (rowe["editable"] and rowe["attachment"])) and rowe["send"]:
- self.report[rowe["item"]][CONTENT] = rowe["content"]
+ self.report[rowe["item"]][CD_CONTENT] = rowe["content"]
else:
del self.report[rowe["item"]]
# handle comment
if self.comment_changed:
buff = self.tvComment.get_buffer()
- self.report["Comment"] = ['t', 'y', buff.get_text(buff.get_start_iter(),buff.get_end_iter())]
+ self.report["Comment"] = [CD_TXT, 'y', buff.get_text(buff.get_start_iter(),buff.get_end_iter())]
else:
del self.report["Comment"]
# handle how to reproduce
if self.how_to_changed:
buff = self.tevHowToReproduce.get_buffer()
- self.report["How to reproduce"] = ['t', 'y', buff.get_text(buff.get_start_iter(),buff.get_end_iter())]
+ self.report["How to reproduce"] = [CD_TXT, 'y', buff.get_text(buff.get_start_iter(),buff.get_end_iter())]
else:
del self.report["How to reproduce"]
diff --git a/src/Gui/ConfBackend.py b/src/Gui/ConfBackend.py
index c7b0450d..c5ec597f 100644
--- a/src/Gui/ConfBackend.py
+++ b/src/Gui/ConfBackend.py
@@ -52,6 +52,8 @@ class ConfBackendGnomeKeyring(ConfBackend):
except gkey.NoMatchError:
# nothing found
pass
+ except gkey.DeniedError:
+ print _("Acces to gnome-keyring has been denied, plugins settings won't be saved.")
# delete all items containg "AbrtPluginInfo":<plugin_name>, so we always have only 1 item per plugin
for item in item_list:
diff --git a/src/Gui/PluginsSettingsDialog.py b/src/Gui/PluginsSettingsDialog.py
index d8eac71e..48e55bf0 100644
--- a/src/Gui/PluginsSettingsDialog.py
+++ b/src/Gui/PluginsSettingsDialog.py
@@ -90,7 +90,9 @@ class PluginsSettingsDialog:
#print "settings hydrate"
self.pluginsListStore.clear()
try:
- pluginlist = getPluginInfoList(self.ccdaemon, refresh=True)
+ #pluginlist = getPluginInfoList(self.ccdaemon, refresh=True)
+ # don't force refresh as it will overwrite settings if g-k is not available
+ pluginlist = getPluginInfoList(self.ccdaemon)
except Exception, e:
print e
#gui_error_message("Error while loading plugins info, please check if abrt daemon is running\n %s" % e)
diff --git a/src/Gui/report.glade b/src/Gui/report.glade
index 428c4ec7..29c5c288 100644
--- a/src/Gui/report.glade
+++ b/src/Gui/report.glade
@@ -93,13 +93,13 @@
<widget class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="hscrollbar_policy">never</property>
+ <property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<child>
<widget class="GtkTextView" id="tevHowToReproduce">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="wrap_mode">word</property>
+ <property name="wrap_mode">word-char</property>
</widget>
</child>
</widget>
@@ -139,13 +139,13 @@
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="hscrollbar_policy">never</property>
+ <property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<child>
<widget class="GtkTextView" id="tvComment">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="wrap_mode">word</property>
+ <property name="wrap_mode">word-char</property>
</widget>
</child>
</widget>
diff --git a/src/Hooks/dumpoops.cpp b/src/Hooks/dumpoops.cpp
index b031d39c..4b6778d0 100644
--- a/src/Hooks/dumpoops.cpp
+++ b/src/Hooks/dumpoops.cpp
@@ -45,7 +45,7 @@ int main(int argc, char **argv)
/* Parse options */
bool opt_d = 0, opt_s = 0;
int opt;
- while ((opt = getopt(argc, argv, "ds")) != -1) {
+ while ((opt = getopt(argc, argv, "dsv")) != -1) {
switch (opt) {
case 'd':
opt_d = 1;
@@ -53,6 +53,10 @@ int main(int argc, char **argv)
case 's':
opt_s = 1;
break;
+ case 'v':
+ /* Kerneloops code uses VERB3, thus: */
+ g_verbose = 3;
+ break;
default:
usage:
error_msg_and_die(
@@ -60,6 +64,7 @@ int main(int argc, char **argv)
"Options:\n"
"\t-d\tCreate ABRT dump for every oops found\n"
"\t-s\tPrint found oopses on standard output\n"
+ "\t-v\tVerbose\n"
, program_name
);
}