summaryrefslogtreecommitdiffstats
path: root/src/daemon
diff options
context:
space:
mode:
authorKarel Klic <kklic@redhat.com>2010-08-19 11:11:58 +0200
committerKarel Klic <kklic@redhat.com>2010-08-19 11:11:58 +0200
commitd6f6a7a98b83de0d0aa3792fb187b66d9d15953d (patch)
tree3f88861519c32e3180d506507f1de3f8e34dfe45 /src/daemon
parent8b22e91dc2ac3e73d628486c91f83da5a0e5ec44 (diff)
parent96071530ea85635cf87a6bf650b7f5ddbd219f44 (diff)
downloadabrt-d6f6a7a98b83de0d0aa3792fb187b66d9d15953d.tar.gz
abrt-d6f6a7a98b83de0d0aa3792fb187b66d9d15953d.tar.xz
abrt-d6f6a7a98b83de0d0aa3792fb187b66d9d15953d.zip
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/CommLayerServerDBus.cpp13
-rw-r--r--src/daemon/Daemon.cpp18
-rw-r--r--src/daemon/MiddleWare.cpp161
-rw-r--r--src/daemon/dumpsocket.cpp7
4 files changed, 103 insertions, 96 deletions
diff --git a/src/daemon/CommLayerServerDBus.cpp b/src/daemon/CommLayerServerDBus.cpp
index 4b11fc04..4a3c5add 100644
--- a/src/daemon/CommLayerServerDBus.cpp
+++ b/src/daemon/CommLayerServerDBus.cpp
@@ -16,6 +16,9 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
#include <dbus/dbus.h>
#include "abrtlib.h"
#include "abrt_dbus.h"
@@ -28,16 +31,6 @@
// 16kB message limit
#define LIMIT_MESSAGE 16384
-#if HAVE_CONFIG_H
- #include <config.h>
-#endif
-#if ENABLE_NLS
- #include <libintl.h>
- #define _(S) gettext(S)
-#else
- #define _(S) (S)
-#endif
-
/*
* DBus signal emitters
*/
diff --git a/src/daemon/Daemon.cpp b/src/daemon/Daemon.cpp
index 735da5af..a568b477 100644
--- a/src/daemon/Daemon.cpp
+++ b/src/daemon/Daemon.cpp
@@ -16,6 +16,12 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif
#include <syslog.h>
#include <pthread.h>
#include <resolv.h> /* res_init */
@@ -25,18 +31,6 @@
#include <xmlrpc-c/base.h>
#include <xmlrpc-c/client.h>
#include <glib.h>
-#if HAVE_CONFIG_H
- #include <config.h>
-#endif
-#if HAVE_LOCALE_H
- #include <locale.h>
-#endif
-#if ENABLE_NLS
- #include <libintl.h>
- #define _(S) gettext(S)
-#else
- #define _(S) (S)
-#endif
#include "abrtlib.h"
#include "abrt_exception.h"
#include "CrashWatcher.h"
diff --git a/src/daemon/MiddleWare.cpp b/src/daemon/MiddleWare.cpp
index c7ed4df5..a0c6b477 100644
--- a/src/daemon/MiddleWare.cpp
+++ b/src/daemon/MiddleWare.cpp
@@ -68,6 +68,19 @@ static char* is_text_file(const char *name, ssize_t *sz)
if (fd < 0)
return NULL; /* it's not text (because it does not exist! :) */
+ /* Maybe 64k limit is small. But _some_ limit is necessary:
+ * fields declared "text" may end up in editing fields and such.
+ * We don't want to accidentally end up with 100meg text in a textbox!
+ * So, don't remove this. If you really need to, raise the limit.
+ */
+ off_t size = lseek(fd, 0, SEEK_END);
+ if (size < 0 || size > 64*1024)
+ {
+ close(fd);
+ return NULL; /* it's not a SMALL text */
+ }
+ lseek(fd, 0, SEEK_SET);
+
char *buf = (char*)xmalloc(*sz);
ssize_t r = *sz = full_read(fd, buf, *sz);
close(fd);
@@ -167,24 +180,30 @@ static void load_crash_data_from_debug_dump(CDebugDump& dd, map_crash_data_t& da
* @param pDebugDumpDir A debugdump dir containing all necessary data.
* @param pCrashData A created crash report.
*/
-static void DebugDumpToCrashReport(const char *pDebugDumpDir, map_crash_data_t& pCrashData)
+static bool DebugDumpToCrashReport(const char *pDebugDumpDir, map_crash_data_t& pCrashData)
{
VERB3 log(" DebugDumpToCrashReport('%s')", pDebugDumpDir);
CDebugDump dd;
- dd.Open(pDebugDumpDir);
-
- const char *const *v = must_have_files;
- while (*v)
+ if (dd.Open(pDebugDumpDir))
{
- if (!dd.Exist(*v))
+ const char *const *v = must_have_files;
+ while (*v)
{
- throw CABRTException(EXCEP_ERROR, "DebugDumpToCrashReport(): important file '%s' is missing", *v);
+ if (!dd.Exist(*v))
+ {
+ throw CABRTException(EXCEP_ERROR, "DebugDumpToCrashReport(): important file '%s' is missing", *v);
+ }
+ v++;
}
- v++;
+
+ load_crash_data_from_debug_dump(dd, pCrashData);
+ dd.Close();
+
+ return true;
}
- load_crash_data_from_debug_dump(dd, pCrashData);
+ return false;
}
/**
@@ -273,11 +292,14 @@ mw_result_t CreateCrashReport(const char *crash_id,
mw_result_t r = MW_OK;
try
{
+ CDebugDump dd;
+ if (dd.Open(row.m_sDebugDumpDir.c_str()))
{
- CDebugDump dd;
- dd.Open(row.m_sDebugDumpDir.c_str());
load_crash_data_from_debug_dump(dd, pCrashData);
+ dd.Close();
}
+ else
+ return MW_ERROR;
std::string analyzer = get_crash_data_item_content(pCrashData, FILENAME_ANALYZER);
const char* package = get_crash_data_item_content_or_NULL(pCrashData, FILENAME_PACKAGE);
@@ -297,23 +319,22 @@ mw_result_t CreateCrashReport(const char *crash_id,
VERB3 log(" RunAnalyzerActions('%s','%s','%s',force=%d)", analyzer.c_str(), package_name, row.m_sDebugDumpDir.c_str(), force);
RunAnalyzerActions(analyzer.c_str(), package_name, row.m_sDebugDumpDir.c_str(), force);
free(package_name);
- DebugDumpToCrashReport(row.m_sDebugDumpDir.c_str(), pCrashData);
- add_to_crash_data_ext(pCrashData, CD_UUID , CD_SYS, CD_ISNOTEDITABLE, row.m_sUUID.c_str());
- add_to_crash_data_ext(pCrashData, CD_DUPHASH, CD_TXT, CD_ISNOTEDITABLE, dup_hash.c_str());
+ if (DebugDumpToCrashReport(row.m_sDebugDumpDir.c_str(), pCrashData))
+ {
+ add_to_crash_data_ext(pCrashData, CD_UUID , CD_SYS, CD_ISNOTEDITABLE, row.m_sUUID.c_str());
+ add_to_crash_data_ext(pCrashData, CD_DUPHASH, CD_TXT, CD_ISNOTEDITABLE, dup_hash.c_str());
+ }
+ else
+ {
+ error_msg("Error loading crash data");
+ return MW_ERROR;
+ }
}
catch (CABRTException& e)
{
r = MW_CORRUPTED;
error_msg("%s", e.what());
- if (e.type() == EXCEP_DD_OPEN)
- {
- r = MW_ERROR;
- }
- else if (e.type() == EXCEP_DD_LOAD)
- {
- r = MW_FILE_ERROR;
- }
- else if (e.type() == EXCEP_PLUGIN)
+ if (e.type() == EXCEP_PLUGIN)
{
r = MW_PLUGIN_ERROR;
}
@@ -358,9 +379,13 @@ void RunActionsAndReporters(const char *pDebugDumpDir)
{
CReporter* reporter = g_pPluginManager->GetReporter(plugin_name); /* can't be NULL */
map_crash_data_t crashReport;
- DebugDumpToCrashReport(pDebugDumpDir, crashReport);
- VERB2 log("%s.Report(...)", plugin_name);
- reporter->Report(crashReport, plugin_settings, it_ar->second.c_str());
+ if (DebugDumpToCrashReport(pDebugDumpDir, crashReport))
+ {
+ VERB2 log("%s.Report(...)", plugin_name);
+ reporter->Report(crashReport, plugin_settings, it_ar->second.c_str());
+ }
+ else
+ error_msg("Activation of plugin '%s' was not successful: Error converting crash data", plugin_name);
}
else if (tp == ACTION)
{
@@ -421,21 +446,25 @@ report_status_t Report(const map_crash_data_t& client_report,
if (comment || reproduce || backtrace)
{
CDebugDump dd;
- dd.Open(pDumpDir.c_str());
- if (comment)
- {
- dd.SaveText(FILENAME_COMMENT, comment);
- add_to_crash_data_ext(stored_report, FILENAME_COMMENT, CD_TXT, CD_ISEDITABLE, comment);
- }
- if (reproduce)
- {
- dd.SaveText(FILENAME_REPRODUCE, reproduce);
- add_to_crash_data_ext(stored_report, FILENAME_REPRODUCE, CD_TXT, CD_ISEDITABLE, reproduce);
- }
- if (backtrace)
+ if (dd.Open(pDumpDir.c_str()))
{
- dd.SaveText(FILENAME_BACKTRACE, backtrace);
- add_to_crash_data_ext(stored_report, FILENAME_BACKTRACE, CD_TXT, CD_ISEDITABLE, backtrace);
+ if (comment)
+ {
+ dd.SaveText(FILENAME_COMMENT, comment);
+ add_to_crash_data_ext(stored_report, FILENAME_COMMENT, CD_TXT, CD_ISEDITABLE, comment);
+ }
+ if (reproduce)
+ {
+ dd.SaveText(FILENAME_REPRODUCE, reproduce);
+ add_to_crash_data_ext(stored_report, FILENAME_REPRODUCE, CD_TXT, CD_ISEDITABLE, reproduce);
+ }
+ if (backtrace)
+ {
+ dd.SaveText(FILENAME_BACKTRACE, backtrace);
+ add_to_crash_data_ext(stored_report, FILENAME_BACKTRACE, CD_TXT, CD_ISEDITABLE, backtrace);
+ }
+
+ dd.Close();
}
}
@@ -690,20 +719,19 @@ static mw_result_t SavePackageDescriptionToDebugDump(
if (g_settings_bProcessUnpackaged || remote)
{
VERB2 log("Crash in unpackaged executable '%s', proceeding without packaging information", pExecutable);
- try
+
+ CDebugDump dd;
+ if (dd.Open(pDebugDumpDir))
{
- CDebugDump dd;
- dd.Open(pDebugDumpDir);
dd.SaveText(FILENAME_PACKAGE, "");
dd.SaveText(FILENAME_COMPONENT, "");
dd.SaveText(FILENAME_DESCRIPTION, "Crashed executable does not belong to any installed package");
+
+ dd.Close();
return MW_OK;
}
- catch (CABRTException& e)
- {
- error_msg("%s", e.what());
+ else
return MW_ERROR;
- }
}
else
{
@@ -816,10 +844,9 @@ static mw_result_t SavePackageDescriptionToDebugDump(
}
}
- try
+ CDebugDump dd;
+ if (dd.Open(pDebugDumpDir))
{
- CDebugDump dd;
- dd.Open(pDebugDumpDir);
if (rpm_pkg)
{
dd.SaveText(FILENAME_PACKAGE, rpm_pkg);
@@ -840,14 +867,11 @@ static mw_result_t SavePackageDescriptionToDebugDump(
if (!remote)
dd.SaveText(FILENAME_HOSTNAME, host);
- }
- catch (CABRTException& e)
- {
- error_msg("%s", e.what());
- return MW_ERROR;
+
+ return MW_OK;
}
- return MW_OK;
+ return MW_ERROR;
}
bool analyzer_has_InformAllUsers(const char *analyzer_name)
@@ -1008,10 +1032,10 @@ mw_result_t SaveDebugDump(const char *pDebugDumpDir,
std::string executable;
std::string cmdline;
bool remote = false;
- try
+
+ CDebugDump dd;
+ if (dd.Open(pDebugDumpDir))
{
- CDebugDump dd;
- dd.Open(pDebugDumpDir);
dd.LoadText(FILENAME_TIME, time);
dd.LoadText(CD_UID, UID);
dd.LoadText(FILENAME_ANALYZER, analyzer);
@@ -1023,12 +1047,11 @@ mw_result_t SaveDebugDump(const char *pDebugDumpDir,
dd.LoadText(FILENAME_REMOTE, remote_str);
remote = (remote_str.find('1') != std::string::npos);
}
+
+ dd.Close();
}
- catch (CABRTException& e)
- {
- error_msg("%s", e.what());
+ else
return MW_ERROR;
- }
/* Convert UID string to number uid_num. The UID string can be modified by user or
wrongly saved (empty or non-numeric), so xatou() cannot be used here,
@@ -1077,17 +1100,15 @@ mw_result_t FillCrashInfo(const char *crash_id,
std::string executable;
std::string description;
std::string analyzer;
- try
+
+ CDebugDump dd;
+ if (dd.Open(row.m_sDebugDumpDir.c_str()))
{
- CDebugDump dd;
- dd.Open(row.m_sDebugDumpDir.c_str());
load_crash_data_from_debug_dump(dd, pCrashData);
+ dd.Close();
}
- catch (CABRTException& e)
- {
- error_msg("%s", e.what());
+ else
return MW_ERROR;
- }
add_to_crash_data(pCrashData, CD_UID , row.m_sUID.c_str() );
add_to_crash_data(pCrashData, CD_UUID , row.m_sUUID.c_str() );
diff --git a/src/daemon/dumpsocket.cpp b/src/daemon/dumpsocket.cpp
index 699a0609..21421b81 100644
--- a/src/daemon/dumpsocket.cpp
+++ b/src/daemon/dumpsocket.cpp
@@ -177,12 +177,11 @@ static void create_debug_dump(struct client *client)
fails if the path is too long. */
CDebugDump dd;
- try {
- dd.Create(path, client->uid);
- } catch (CABRTException &e) {
+ if (!dd.Create(path, client->uid))
+ {
dd.Delete();
dd.Close();
- error_msg_and_die("dumpsocket: Error while creating crash dump %s: %s", path, e.what());
+ error_msg_and_die("dumpsocket: Error while creating crash dump %s", path);
}
dd.SaveText(FILENAME_ANALYZER, client->analyzer);