summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--inc/abrtlib.h16
-rw-r--r--inc/debug_dump.h6
-rw-r--r--inc/plugin.h10
-rw-r--r--lib/plugins/Bugzilla.cpp8
-rw-r--r--lib/plugins/CCpp.cpp60
-rw-r--r--lib/plugins/Kerneloops.cpp9
-rw-r--r--lib/plugins/KerneloopsScanner.cpp40
-rw-r--r--lib/plugins/Python.cpp8
-rw-r--r--lib/plugins/RHTSupport.cpp15
-rw-r--r--lib/plugins/RunApp.cpp8
-rw-r--r--lib/plugins/SOSreport.cpp14
-rw-r--r--lib/utils/DebugDump.cpp104
-rw-r--r--lib/utils/abrt_curl.cpp58
-rw-r--r--lib/utils/make_descr.cpp12
-rw-r--r--lib/utils/parse_release.cpp2
-rw-r--r--po/POTFILES.in1
-rw-r--r--src/applet/Applet.cpp12
-rw-r--r--src/applet/CCApplet.cpp6
-rw-r--r--src/cli/CLI.cpp18
-rw-r--r--src/cli/report.cpp18
-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
-rw-r--r--src/hooks/abrt-hook-ccpp.cpp178
-rw-r--r--src/hooks/dumpoops.cpp11
26 files changed, 461 insertions, 352 deletions
diff --git a/inc/abrtlib.h b/inc/abrtlib.h
index 57097ece..713694b8 100644
--- a/inc/abrtlib.h
+++ b/inc/abrtlib.h
@@ -40,24 +40,30 @@
/* C++ bits */
#include <string>
-#include "abrt_types.h"
-#include "xfuncs.h"
-
/* Some libc's forget to declare these, do it ourself */
extern char **environ;
#if defined(__GLIBC__) && __GLIBC__ < 2
int vdprintf(int d, const char *format, va_list ap);
#endif
-
#define NORETURN __attribute__ ((noreturn))
-
#undef ARRAY_SIZE
#define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0])))
+#if ENABLE_NLS
+# include <libintl.h>
+# define _(S) gettext(S)
+#else
+# define _(S) (S)
+#endif
+
+
+#include "abrt_types.h"
+#include "xfuncs.h"
#include "logging.h"
+
char* skip_whitespace(const char *s);
char* skip_non_whitespace(const char *s);
diff --git a/inc/debug_dump.h b/inc/debug_dump.h
index f8487a65..869cd7d0 100644
--- a/inc/debug_dump.h
+++ b/inc/debug_dump.h
@@ -41,8 +41,8 @@ class CDebugDump
CDebugDump();
~CDebugDump();
- void Open(const char *pDir);
- void Create(const char *pDir, uid_t uid);
+ bool Open(const char *pDir);
+ bool Create(const char *pDir, uid_t uid);
void Delete();
void Close();
@@ -53,7 +53,7 @@ class CDebugDump
void SaveText(const char* pName, const char *pData);
void SaveBinary(const char* pName, const char* pData, unsigned pSize);
- void InitGetNextFile();
+ bool InitGetNextFile();
/* Pointers may be NULL */
bool GetNextFile(std::string *short_name, std::string *full_name);
};
diff --git a/inc/plugin.h b/inc/plugin.h
index ebad0866..420a7cd8 100644
--- a/inc/plugin.h
+++ b/inc/plugin.h
@@ -22,17 +22,11 @@
#ifndef PLUGIN_H_
#define PLUGIN_H_
-#include "abrt_types.h"
-#include "crash_types.h"
#if HAVE_CONFIG_H
# include <config.h>
#endif
-#if ENABLE_NLS
-# include <libintl.h>
-# define _(S) gettext(S)
-#else
-# define _(S) (S)
-#endif
+#include "abrt_types.h"
+#include "crash_types.h"
#define PLUGINS_MAGIC_NUMBER 6
diff --git a/lib/plugins/Bugzilla.cpp b/lib/plugins/Bugzilla.cpp
index 55a957be..815abffa 100644
--- a/lib/plugins/Bugzilla.cpp
+++ b/lib/plugins/Bugzilla.cpp
@@ -17,6 +17,9 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
#include "abrtlib.h"
#include "abrt_xmlrpc.h"
#include "Bugzilla.h"
@@ -25,9 +28,6 @@
#include "abrt_exception.h"
#include "comm_layer_inner.h"
#include "strbuf.h"
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
#define XML_RPC_SUFFIX "/xmlrpc.cgi"
#define MAX_HOPS 5
@@ -979,7 +979,7 @@ void CReporterBugzilla::SetSettings(const map_plugin_settings_t& pSettings)
/* Should not be deleted (why?) */
const map_plugin_settings_t& CReporterBugzilla::GetSettings()
{
- m_pSettings["BugzillaURL"] = m_bugzilla_url;
+ m_pSettings["BugzillaURL"] = (m_bugzilla_url)? m_bugzilla_url: "";
m_pSettings["Login"] = (m_login)? m_login: "";
m_pSettings["Password"] = (m_password)? m_password: "";
m_pSettings["SSLVerify"] = m_ssl_verify ? "yes" : "no";
diff --git a/lib/plugins/CCpp.cpp b/lib/plugins/CCpp.cpp
index 629da665..2e8b9177 100644
--- a/lib/plugins/CCpp.cpp
+++ b/lib/plugins/CCpp.cpp
@@ -178,7 +178,7 @@ static int ExecVP(char **pArgs, uid_t uid, int redirect_stderr, string& pOutput)
return status;
}
-static void GetBacktrace(const char *pDebugDumpDir,
+static bool GetBacktrace(const char *pDebugDumpDir,
const char *pDebugInfoDirs,
string& pBacktrace)
{
@@ -186,13 +186,17 @@ static void GetBacktrace(const char *pDebugDumpDir,
string UID;
string executable;
+ CDebugDump dd;
+ if (!dd.Open(pDebugDumpDir))
{
- CDebugDump dd;
- dd.Open(pDebugDumpDir);
- dd.LoadText(FILENAME_EXECUTABLE, executable);
- dd.LoadText(CD_UID, UID);
+ VERB1 log(_("Unable to open debug dump '%s'"), pDebugDumpDir);
+ return false;
}
+ dd.LoadText(FILENAME_EXECUTABLE, executable);
+ dd.LoadText(CD_UID, UID);
+ dd.Close();
+
// Workaround for
// http://sourceware.org/bugzilla/show_bug.cgi?id=9622
unsetenv("TERM");
@@ -276,7 +280,7 @@ static void GetBacktrace(const char *pDebugDumpDir,
pBacktrace = "";
ExecVP(args, xatoi_u(UID.c_str()), /*redirect_stderr:*/ 1, pBacktrace);
if (bt_depth <= 64 || pBacktrace.size() < 256*1024)
- return;
+ return true;
bt_depth /= 2;
if (bt_depth <= 64 && thread_apply_all[0] != '\0')
{
@@ -323,12 +327,16 @@ static void GetIndependentBuildIdPC(const char *unstrip_n_output,
static string run_unstrip_n(const char *pDebugDumpDir)
{
string UID;
+ CDebugDump dd;
+ if (!dd.Open(pDebugDumpDir))
{
- CDebugDump dd;
- dd.Open(pDebugDumpDir);
- dd.LoadText(CD_UID, UID);
+ VERB1 log(_("Unable to open debug dump '%s'"), pDebugDumpDir);
+ return string("");
}
+ dd.LoadText(CD_UID, UID);
+ dd.Close();
+
char* args[4];
args[0] = (char*)"eu-unstrip";
args[1] = xasprintf("--core=%s/"FILENAME_COREDUMP, pDebugDumpDir);
@@ -506,13 +514,17 @@ string CAnalyzerCCpp::GetLocalUUID(const char *pDebugDumpDir)
{
string executable;
string package;
+ CDebugDump dd;
+ if (!dd.Open(pDebugDumpDir))
{
- CDebugDump dd;
- dd.Open(pDebugDumpDir);
- dd.LoadText(FILENAME_EXECUTABLE, executable);
- dd.LoadText(FILENAME_PACKAGE, package);
+ VERB1 log(_("Unable to open debug dump '%s'"), pDebugDumpDir);
+ return string("");
}
+ dd.LoadText(FILENAME_EXECUTABLE, executable);
+ dd.LoadText(FILENAME_PACKAGE, package);
+ dd.Close();
+
string unstrip_n_output = run_unstrip_n(pDebugDumpDir);
string independentBuildIdPC;
GetIndependentBuildIdPC(unstrip_n_output.c_str(), independentBuildIdPC);
@@ -552,11 +564,17 @@ string CAnalyzerCCpp::GetLocalUUID(const char *pDebugDumpDir)
string CAnalyzerCCpp::GetGlobalUUID(const char *pDebugDumpDir)
{
CDebugDump dd;
- dd.Open(pDebugDumpDir);
+ if (!dd.Open(pDebugDumpDir))
+ {
+ VERB1 log(_("Unable to open debug dump '%s'"), pDebugDumpDir);
+ return string("");
+ }
+
if (dd.Exist(FILENAME_GLOBAL_UUID))
{
string uuid;
dd.LoadText(FILENAME_GLOBAL_UUID, uuid);
+ dd.Close();
return uuid;
}
else
@@ -670,6 +688,7 @@ string CAnalyzerCCpp::GetGlobalUUID(const char *pDebugDumpDir)
{
dd.SaveText(FILENAME_RATING, "0");
}
+ dd.Close();
string hash_base = package + executable + independent_backtrace;
return create_hash(hash_base.c_str());
@@ -710,7 +729,11 @@ void CAnalyzerCCpp::CreateReport(const char *pDebugDumpDir, int force)
string package, executable, UID;
CDebugDump dd;
- dd.Open(pDebugDumpDir);
+ if (!dd.Open(pDebugDumpDir))
+ {
+ VERB1 log(_("Unable to open debug dump '%s'"), pDebugDumpDir);
+ return;
+ }
/* Skip remote crashes. */
if (dd.Exist(FILENAME_REMOTE))
@@ -750,7 +773,12 @@ void CAnalyzerCCpp::CreateReport(const char *pDebugDumpDir, int force)
/* Create and store backtrace. */
string backtrace_str;
GetBacktrace(pDebugDumpDir, m_sDebugInfoDirs.c_str(), backtrace_str);
- dd.Open(pDebugDumpDir);
+ if (!dd.Open(pDebugDumpDir))
+ {
+ VERB1 log(_("Unable to open debug dump '%s'"), pDebugDumpDir);
+ return;
+ }
+
dd.SaveText(FILENAME_BACKTRACE, (backtrace_str + build_ids).c_str());
if (m_bMemoryMap)
diff --git a/lib/plugins/Kerneloops.cpp b/lib/plugins/Kerneloops.cpp
index 1a2532e8..379197b2 100644
--- a/lib/plugins/Kerneloops.cpp
+++ b/lib/plugins/Kerneloops.cpp
@@ -118,12 +118,15 @@ std::string CAnalyzerKerneloops::GetLocalUUID(const char *pDebugDumpDir)
VERB3 log("Getting local universal unique identification");
std::string oops;
+ CDebugDump dd;
+ if (!dd.Open(pDebugDumpDir))
{
- CDebugDump dd;
- dd.Open(pDebugDumpDir);
- dd.LoadText(FILENAME_BACKTRACE, oops);
+ VERB1 log(_("Unable to open debug dump '%s'"), pDebugDumpDir);
+ return std::string("");
}
+ dd.LoadText(FILENAME_BACKTRACE, oops);
+
unsigned hash = hash_oops_str(oops.c_str());
hash &= 0x7FFFFFFF;
diff --git a/lib/plugins/KerneloopsScanner.cpp b/lib/plugins/KerneloopsScanner.cpp
index dc1f6d0a..7e0e8e74 100644
--- a/lib/plugins/KerneloopsScanner.cpp
+++ b/lib/plugins/KerneloopsScanner.cpp
@@ -113,7 +113,8 @@ int scan_syslog_file(vector_string_t& oopsList, const char *filename, time_t *la
return cnt_FoundOopses;
}
-void save_oops_to_debug_dump(const vector_string_t& oopsList)
+/* returns number of errors */
+int save_oops_to_debug_dump(const vector_string_t& oopsList)
{
unsigned countdown = 16; /* do not report hundreds of oopses */
unsigned idx = oopsList.size();
@@ -122,19 +123,21 @@ void save_oops_to_debug_dump(const vector_string_t& oopsList)
VERB1 log("Saving %u oopses as crash dump dirs", idx >= countdown ? countdown-1 : idx);
+ int errors = 0;
+
while (idx != 0 && --countdown != 0)
{
char path[sizeof(DEBUG_DUMPS_DIR"/kerneloops-%lu-%lu-%lu") + 3 * sizeof(long)*3];
sprintf(path, DEBUG_DUMPS_DIR"/kerneloops-%lu-%lu-%lu", (long)t, (long)my_pid, (long)idx);
- try
- {
- std::string oops = oopsList.at(--idx);
- const char *first_line = oops.c_str();
- char *second_line = (char*)strchr(first_line, '\n'); /* never NULL */
- *second_line++ = '\0';
- CDebugDump dd;
- dd.Create(path, /*uid:*/ 0);
+ std::string oops = oopsList.at(--idx);
+ const char *first_line = oops.c_str();
+ char *second_line = (char*)strchr(first_line, '\n'); /* never NULL */
+ *second_line++ = '\0';
+
+ CDebugDump dd;
+ if (dd.Create(path, /*uid:*/ 0))
+ {
dd.SaveText(FILENAME_ANALYZER, "Kerneloops");
dd.SaveText(FILENAME_EXECUTABLE, "kernel");
dd.SaveText(FILENAME_KERNEL, first_line);
@@ -143,12 +146,13 @@ void save_oops_to_debug_dump(const vector_string_t& oopsList)
/* Optional, makes generated bz more informative */
strchrnul(second_line, '\n')[0] = '\0';
dd.SaveText(FILENAME_REASON, second_line);
+ dd.Close();
}
- catch (CABRTException& e)
- {
- throw CABRTException(EXCEP_PLUGIN, "%s: %s", __func__, e.what());
- }
+ else
+ errors++;
}
+
+ return errors;
}
} /* extern "C" */
@@ -163,7 +167,11 @@ CKerneloopsScanner::CKerneloopsScanner()
vector_string_t oopsList;
cnt_FoundOopses = scan_dmesg(oopsList);
if (cnt_FoundOopses > 0)
- save_oops_to_debug_dump(oopsList);
+ {
+ int errors = save_oops_to_debug_dump(oopsList);
+ if (errors > 0)
+ log("%d errors while dumping oopses", errors);
+ }
}
void CKerneloopsScanner::Run(const char *pActionDir, const char *pArgs, int force)
@@ -177,7 +185,9 @@ void CKerneloopsScanner::Run(const char *pActionDir, const char *pArgs, int forc
int cnt_FoundOopses = scan_syslog_file(oopsList, syslog_file, &m_syslog_last_change);
if (cnt_FoundOopses > 0)
{
- save_oops_to_debug_dump(oopsList);
+ int errors = save_oops_to_debug_dump(oopsList);
+ if (errors > 0)
+ log("%d errors while dumping oopses", errors);
/*
* This marker in syslog file prevents us from
* re-parsing old oopses (any oops before it is
diff --git a/lib/plugins/Python.cpp b/lib/plugins/Python.cpp
index 5f2f6e17..b4d6cefc 100644
--- a/lib/plugins/Python.cpp
+++ b/lib/plugins/Python.cpp
@@ -27,9 +27,15 @@ using namespace std;
string CAnalyzerPython::GetLocalUUID(const char *pDebugDumpDir)
{
CDebugDump dd;
- dd.Open(pDebugDumpDir);
+ if (!dd.Open(pDebugDumpDir))
+ {
+ VERB1 log(_("Unable to open debug dump '%s'"), pDebugDumpDir);
+ return string("");
+ }
+
string bt;
dd.LoadText(FILENAME_BACKTRACE, bt);
+ dd.Close();
const char *bt_str = bt.c_str();
const char *bt_end = strchrnul(bt_str, '\n');
diff --git a/lib/plugins/RHTSupport.cpp b/lib/plugins/RHTSupport.cpp
index f056056d..d13ff467 100644
--- a/lib/plugins/RHTSupport.cpp
+++ b/lib/plugins/RHTSupport.cpp
@@ -18,6 +18,9 @@
*/
#define _GNU_SOURCE 1 /* for stpcpy */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
#include <libtar.h>
#include "abrtlib.h"
#include "abrt_curl.h"
@@ -28,9 +31,6 @@
#include "comm_layer_inner.h"
#include "RHTSupport.h"
#include "strbuf.h"
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
using namespace std;
@@ -110,6 +110,9 @@ string CReporterRHticket::Report(const map_crash_data_t& pCrashData,
const map_plugin_settings_t& pSettings,
const char *pArgs)
{
+ /* Gzipping e.g. 0.5gig coredump takes a while. Let client know what we are doing */
+ update_client(_("Compressing data"));
+
string retval;
map_plugin_settings_t::const_iterator end = pSettings.end();
@@ -311,9 +314,9 @@ void CReporterRHticket::SetSettings(const map_plugin_settings_t& pSettings)
/* Should not be deleted (why?) */
const map_plugin_settings_t& CReporterRHticket::GetSettings()
{
- m_pSettings["URL"] = m_strata_url;
- m_pSettings["Login"] = m_login;
- m_pSettings["Password"] = m_password;
+ m_pSettings["URL"] = (m_strata_url)? m_strata_url: "";
+ m_pSettings["Login"] = (m_login)? m_login: "";
+ m_pSettings["Password"] = (m_password)? m_password: "";
m_pSettings["SSLVerify"] = m_ssl_verify ? "yes" : "no";
return m_pSettings;
diff --git a/lib/plugins/RunApp.cpp b/lib/plugins/RunApp.cpp
index 69c9384c..632c26f1 100644
--- a/lib/plugins/RunApp.cpp
+++ b/lib/plugins/RunApp.cpp
@@ -59,8 +59,14 @@ void CActionRunApp::Run(const char *pActionDir, const char *pArgs, int force)
if (args.size() > FILENAME)
{
CDebugDump dd;
- dd.Open(pActionDir);
+ if (!dd.Open(pActionDir))
+ {
+ VERB1 log(_("Unable to open debug dump '%s'"), pActionDir);
+ return;
+ }
+
dd.SaveBinary(args[FILENAME].c_str(), cmd_out, cmd_out_size);
+ dd.Close();
}
free(cmd_out);
diff --git a/lib/plugins/SOSreport.cpp b/lib/plugins/SOSreport.cpp
index 6c8ab1f8..df254ec3 100644
--- a/lib/plugins/SOSreport.cpp
+++ b/lib/plugins/SOSreport.cpp
@@ -53,13 +53,19 @@ void CActionSOSreport::Run(const char *pActionDir, const char *pArgs, int force)
if (!force)
{
CDebugDump dd;
- dd.Open(pActionDir);
+ if (!dd.Open(pActionDir))
+ {
+ VERB1 log(_("Unable to open debug dump '%s'"), pActionDir);
+ return;
+ }
+
bool bt_exists = dd.Exist("sosreport.tar.bz2") || dd.Exist("sosreport.tar.xz");
if (bt_exists)
{
VERB3 log("%s already exists, not regenerating", "sosreport.tar.bz2");
return;
}
+ dd.Close();
}
static const char command_default[] =
@@ -125,7 +131,11 @@ void CActionSOSreport::Run(const char *pActionDir, const char *pArgs, int force)
sosreport_dd_filename += ext;
}
CDebugDump dd;
- dd.Open(pActionDir);
+ if (!dd.Open(pActionDir))
+ {
+ VERB1 log(_("Unable to open debug dump '%s'"), pDebugDumpDir);
+ return;
+ }
//Not useful: dd.SaveText("sosreportoutput", output);
off_t sz = copy_file(sosreport_filename, sosreport_dd_filename.c_str(), 0644);
diff --git a/lib/utils/DebugDump.cpp b/lib/utils/DebugDump.cpp
index 30ceacc1..9bc0ab73 100644
--- a/lib/utils/DebugDump.cpp
+++ b/lib/utils/DebugDump.cpp
@@ -55,7 +55,7 @@ static bool ExistFileDir(const char *pPath)
return false;
}
-static void LoadTextFile(const char *pPath, std::string& pData);
+static bool LoadTextFile(const char *pPath, std::string& pData);
CDebugDump::CDebugDump() :
m_sDebugDumpDir(""),
@@ -82,16 +82,16 @@ CDebugDump::~CDebugDump()
}
}
-void CDebugDump::Open(const char *pDir)
+bool CDebugDump::Open(const char *pDir)
{
if (m_bOpened)
- {
- throw CABRTException(EXCEP_ERROR, "CDebugDump is already opened");
- }
+ error_msg_and_die("CDebugDump is already opened");
+
m_sDebugDumpDir = RemoveBackSlashes(pDir);
if (!ExistFileDir(m_sDebugDumpDir.c_str()))
{
- throw CABRTException(EXCEP_DD_OPEN, "'%s' does not exist", m_sDebugDumpDir.c_str());
+ error_msg("'%s' does not exist", m_sDebugDumpDir.c_str());
+ return false;
}
Lock();
m_bOpened = true;
@@ -104,6 +104,7 @@ void CDebugDump::Open(const char *pDir)
m_uid = stat_buf.st_uid;
m_gid = stat_buf.st_gid;
}
+ return true;
}
bool CDebugDump::Exist(const char* pPath)
@@ -262,17 +263,16 @@ void CDebugDump::UnLock()
* Currently, we set dir's gid to passwd(uid)->pw_gid parameter, and we set uid to
* abrt's user id. We do not allow write access to group.
*/
-void CDebugDump::Create(const char *pDir, uid_t uid)
+bool CDebugDump::Create(const char *pDir, uid_t uid)
{
if (m_bOpened)
- {
- throw CABRTException(EXCEP_ERROR, "DebugDump is already opened");
- }
+ error_msg_and_die("DebugDump is already opened");
m_sDebugDumpDir = RemoveBackSlashes(pDir);
if (ExistFileDir(m_sDebugDumpDir.c_str()))
{
- throw CABRTException(EXCEP_DD_OPEN, "'%s' already exists", m_sDebugDumpDir.c_str());
+ error_msg("'%s' already exists", m_sDebugDumpDir.c_str());
+ return false;
}
Lock();
@@ -286,7 +286,8 @@ void CDebugDump::Create(const char *pDir, uid_t uid)
{
UnLock();
m_bOpened = false;
- throw CABRTException(EXCEP_DD_OPEN, "Can't create dir '%s'", pDir);
+ error_msg("Can't create dir '%s'", pDir);
+ return false;
}
/* mkdir's mode (above) can be affected by umask, fix it */
@@ -294,7 +295,8 @@ void CDebugDump::Create(const char *pDir, uid_t uid)
{
UnLock();
m_bOpened = false;
- throw CABRTException(EXCEP_DD_OPEN, "Can't change mode of '%s'", pDir);
+ error_msg("Can't change mode of '%s'", pDir);
+ return false;
}
/* Get ABRT's user id */
@@ -339,13 +341,21 @@ void CDebugDump::Create(const char *pDir, uid_t uid)
time_t t = time(NULL);
SaveText(FILENAME_TIME, to_string(t).c_str());
+
+ return true;
}
-static void DeleteFileDir(const char *pDir)
+static bool DeleteFileDir(const char *pDir)
{
+ if (!ExistFileDir(pDir))
+ return true;
+
DIR *dir = opendir(pDir);
if (!dir)
- return;
+ {
+ error_msg("Can't open dir '%s'", pDir);
+ return false;
+ }
struct dirent *dent;
while ((dent = readdir(dir)) != NULL)
@@ -358,7 +368,8 @@ static void DeleteFileDir(const char *pDir)
if (errno != EISDIR)
{
closedir(dir);
- throw CABRTException(EXCEP_DD_DELETE, "Can't remove dir %s", fullPath.c_str());
+ error_msg("Can't remove dir '%s'", fullPath.c_str());
+ return false;
}
DeleteFileDir(fullPath.c_str());
}
@@ -366,8 +377,11 @@ static void DeleteFileDir(const char *pDir)
closedir(dir);
if (rmdir(pDir) == -1)
{
- throw CABRTException(EXCEP_DD_DELETE, "Can't remove dir %s", pDir);
+ error_msg("Can't remove dir %s", pDir);
+ return false;
}
+
+ return true;
}
void CDebugDump::Delete()
@@ -390,12 +404,13 @@ void CDebugDump::Close()
m_bOpened = false;
}
-static void LoadTextFile(const char *pPath, std::string& pData)
+static bool LoadTextFile(const char *pPath, std::string& pData)
{
FILE *fp = fopen(pPath, "r");
if (!fp)
{
- throw CABRTException(EXCEP_DD_LOAD, "Can't open file '%s'", pPath);
+ error_msg("Can't open file '%s'", pPath);
+ return false;
}
pData = "";
int ch;
@@ -411,16 +426,18 @@ static void LoadTextFile(const char *pPath, std::string& pData)
}
}
fclose(fp);
+ return true;
}
-static void SaveBinaryFile(const char *pPath, const char* pData, unsigned pSize, uid_t uid, gid_t gid)
+static bool SaveBinaryFile(const char *pPath, const char* pData, unsigned pSize, uid_t uid, gid_t gid)
{
/* "Why 0640?!" See ::Create() for security analysis */
unlink(pPath);
int fd = open(pPath, O_WRONLY | O_TRUNC | O_CREAT, 0640);
if (fd < 0)
{
- throw CABRTException(EXCEP_DD_SAVE, "Can't open file '%s': %s", pPath, errno ? strerror(errno) : "errno == 0");
+ error_msg("Can't open file '%s': %s", pPath, errno ? strerror(errno) : "errno == 0");
+ return false;
}
if (fchown(fd, uid, gid) == -1)
{
@@ -430,16 +447,18 @@ static void SaveBinaryFile(const char *pPath, const char* pData, unsigned pSize,
close(fd);
if (r != pSize)
{
- throw CABRTException(EXCEP_DD_SAVE, "Can't save file '%s'", pPath);
+ error_msg("Can't save file '%s'", pPath);
+ return false;
}
+
+ return true;
}
void CDebugDump::LoadText(const char* pName, std::string& pData)
{
if (!m_bOpened)
- {
- throw CABRTException(EXCEP_DD_OPEN, "DebugDump is not opened");
- }
+ error_msg_and_die("DebugDump is not opened");
+
std::string fullPath = concat_path_file(m_sDebugDumpDir.c_str(), pName);
LoadTextFile(fullPath.c_str(), pData);
}
@@ -447,9 +466,8 @@ void CDebugDump::LoadText(const char* pName, std::string& pData)
void CDebugDump::SaveText(const char* pName, const char* pData)
{
if (!m_bOpened)
- {
- throw CABRTException(EXCEP_DD_OPEN, "DebugDump is not opened");
- }
+ error_msg_and_die("DebugDump is not opened");
+
std::string fullPath = concat_path_file(m_sDebugDumpDir.c_str(), pName);
SaveBinaryFile(fullPath.c_str(), pData, strlen(pData), m_uid, m_gid);
}
@@ -457,19 +475,16 @@ void CDebugDump::SaveText(const char* pName, const char* pData)
void CDebugDump::SaveBinary(const char* pName, const char* pData, unsigned pSize)
{
if (!m_bOpened)
- {
- throw CABRTException(EXCEP_DD_OPEN, "DebugDump is not opened");
- }
+ error_msg_and_die("DebugDump is not opened");
std::string fullPath = concat_path_file(m_sDebugDumpDir.c_str(), pName);
SaveBinaryFile(fullPath.c_str(), pData, pSize, m_uid, m_gid);
}
-void CDebugDump::InitGetNextFile()
+bool CDebugDump::InitGetNextFile()
{
if (!m_bOpened)
- {
- throw CABRTException(EXCEP_DD_OPEN, "DebugDump is not opened");
- }
+ error_msg_and_die("DebugDump is not opened");
+
if (m_pGetNextFileDir != NULL)
{
closedir(m_pGetNextFileDir);
@@ -477,16 +492,17 @@ void CDebugDump::InitGetNextFile()
m_pGetNextFileDir = opendir(m_sDebugDumpDir.c_str());
if (m_pGetNextFileDir == NULL)
{
- throw CABRTException(EXCEP_DD_OPEN, "Can't open dir '%s'", m_sDebugDumpDir.c_str());
+ error_msg("Can't open dir '%s'", m_sDebugDumpDir.c_str());
+ return false;
}
+
+ return true;
}
bool CDebugDump::GetNextFile(std::string *short_name, std::string *full_name)
{
if (m_pGetNextFileDir == NULL)
- {
return false;
- }
struct dirent *dent;
while ((dent = readdir(m_pGetNextFileDir)) != NULL)
@@ -508,14 +524,12 @@ bool CDebugDump::GetNextFile(std::string *short_name, std::string *full_name)
/* Utility function */
void delete_debug_dump_dir(const char *pDebugDumpDir)
{
- try
+ CDebugDump dd;
+ if (dd.Open(pDebugDumpDir))
{
- CDebugDump dd;
- dd.Open(pDebugDumpDir);
dd.Delete();
+ dd.Close();
}
- catch (CABRTException& e)
- {
- /* Ignoring "directory already deleted" and such */
- }
+ else
+ VERB1 log("Unable to open debug dump '%s'", pDebugDumpDir);
}
diff --git a/lib/utils/abrt_curl.cpp b/lib/utils/abrt_curl.cpp
index af3defca..52688ac1 100644
--- a/lib/utils/abrt_curl.cpp
+++ b/lib/utils/abrt_curl.cpp
@@ -154,6 +154,30 @@ save_headers(void *buffer_pv, size_t count, size_t nmemb, void *ptr)
return size;
}
+/* "read local data from a file" callback */
+static size_t fread_with_reporting(void *ptr, size_t size, size_t nmemb, void *userdata)
+{
+ static time_t last_t; // hack
+
+ FILE *fp = (FILE*)userdata;
+ time_t t = time(NULL);
+
+ // Report current file position every 16 seconds
+ if (!(t & 0xf) && last_t != t)
+ {
+ last_t = t;
+ off_t cur_pos = ftello(fp);
+ fseeko(fp, 0, SEEK_END);
+ off_t sz = ftello(fp);
+ fseeko(fp, cur_pos, SEEK_SET);
+ update_client(_("Uploaded: %llu of %llu kbytes"),
+ (unsigned long long)cur_pos / 1024,
+ (unsigned long long)sz / 1024);
+ }
+
+ return fread(ptr, size, nmemb, fp);
+}
+
int
abrt_post(abrt_post_state_t *state,
const char *url,
@@ -217,17 +241,45 @@ abrt_post(abrt_post_state_t *state,
//FIXME:
perror_msg_and_die("can't open '%s'", data);
xcurl_easy_setopt_ptr(handle, CURLOPT_READDATA, data_file);
+ // Want to use custom read function
+ xcurl_easy_setopt_ptr(handle, CURLOPT_READFUNCTION, (const void*)fread_with_reporting);
} else if (data_size == ABRT_POST_DATA_FROMFILE_AS_FORM_DATA) {
// ...from a file, in multipart/formdata format
+ const char *basename = strrchr(data, '/');
+ if (basename) basename++;
+ else basename = data;
+#if 0
+ // Simple way, without custom reader function
CURLFORMcode curlform_err = curl_formadd(&post, &last,
- CURLFORM_PTRNAME, "file",
+ CURLFORM_PTRNAME, "file", // element name
CURLFORM_FILE, data, // filename to read from
CURLFORM_CONTENTTYPE, content_type,
- CURLFORM_FILENAME, data, // filename to put in the form
+ CURLFORM_FILENAME, basename, // filename to put in the form
+ CURLFORM_END);
+#else
+ data_file = fopen(data, "r");
+ if (!data_file)
+//FIXME:
+ perror_msg_and_die("can't open '%s'", data);
+ // Want to use custom read function
+ xcurl_easy_setopt_ptr(handle, CURLOPT_READFUNCTION, (const void*)fread_with_reporting);
+ // Need to know file size
+ fseeko(data_file, 0, SEEK_END);
+ off_t sz = ftello(data_file);
+ fseeko(data_file, 0, SEEK_SET);
+ // Create formdata
+ CURLFORMcode curlform_err = curl_formadd(&post, &last,
+ CURLFORM_PTRNAME, "file", // element name
+ // use CURLOPT_READFUNCTION for reading, pass data_file as its last param:
+ CURLFORM_STREAM, data_file,
+ CURLFORM_CONTENTSLENGTH, (long)sz, // a must if we use CURLFORM_STREAM option
+ CURLFORM_CONTENTTYPE, content_type,
+ CURLFORM_FILENAME, basename, // filename to put in the form
CURLFORM_END);
+#endif
if (curlform_err != 0)
//FIXME:
- error_msg_and_die("out of memory or read error");
+ error_msg_and_die("out of memory or read error (curl_formadd error code: %d)", (int)curlform_err);
xcurl_easy_setopt_ptr(handle, CURLOPT_HTTPPOST, post);
} else {
// .. from a blob in memory
diff --git a/lib/utils/make_descr.cpp b/lib/utils/make_descr.cpp
index 8569100f..dc5273ca 100644
--- a/lib/utils/make_descr.cpp
+++ b/lib/utils/make_descr.cpp
@@ -16,19 +16,13 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
#include "abrtlib.h"
#include "crash_types.h"
#include "debug_dump.h" /* FILENAME_ARCHITECTURE etc */
#include "strbuf.h"
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-#if ENABLE_NLS
-# include <libintl.h>
-# define _(S) gettext(S)
-#else
-# define _(S) (S)
-#endif
using namespace std;
diff --git a/lib/utils/parse_release.cpp b/lib/utils/parse_release.cpp
index 3d6b572f..0b8bf5eb 100644
--- a/lib/utils/parse_release.cpp
+++ b/lib/utils/parse_release.cpp
@@ -16,10 +16,10 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "abrtlib.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include "abrtlib.h"
#include "strbuf.h"
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 342097ad..8fadc664 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -23,6 +23,7 @@ lib/plugins/Mailx.glade
lib/plugins/ReportUploader.glade
lib/plugins/RHTSupport.glade
lib/utils/make_descr.cpp
+lib/utils/abrt_curl.cpp
src/applet/abrt-applet.desktop.in
src/applet/Applet.cpp
src/applet/CCApplet.cpp
diff --git a/src/applet/Applet.cpp b/src/applet/Applet.cpp
index 85ee0db8..be9c662d 100644
--- a/src/applet/Applet.cpp
+++ b/src/applet/Applet.cpp
@@ -16,21 +16,15 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <dbus/dbus-shared.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.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 <dbus/dbus-shared.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
#include "abrtlib.h"
#include "abrt_dbus.h"
#include "dbus_common.h"
diff --git a/src/applet/CCApplet.cpp b/src/applet/CCApplet.cpp
index 5349c7a5..4f6c2c65 100644
--- a/src/applet/CCApplet.cpp
+++ b/src/applet/CCApplet.cpp
@@ -19,12 +19,6 @@
#if HAVE_CONFIG_H
# include <config.h>
#endif
-#if ENABLE_NLS
-# include <libintl.h>
-# define _(S) gettext(S)
-#else
-# define _(S) (S)
-#endif
#include "abrtlib.h"
#include "CCApplet.h"
diff --git a/src/cli/CLI.cpp b/src/cli/CLI.cpp
index 276703dc..d1cc13d8 100644
--- a/src/cli/CLI.cpp
+++ b/src/cli/CLI.cpp
@@ -15,6 +15,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 <getopt.h>
#include "abrt_exception.h"
#include "abrtlib.h"
@@ -22,18 +28,6 @@
#include "dbus_common.h"
#include "report.h"
#include "dbus.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
/** Creates a localized string from crash time. */
static char *localize_crash_time(const char *timestr)
diff --git a/src/cli/report.cpp b/src/cli/report.cpp
index 96dec553..4c5eb6f1 100644
--- a/src/cli/report.cpp
+++ b/src/cli/report.cpp
@@ -15,6 +15,12 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include <cassert>
+#include <algorithm>
+#include <termios.h>
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
#include "report.h"
#include "run-command.h"
#include "dbus.h"
@@ -22,18 +28,6 @@
#include "debug_dump.h"
#include "crash_types.h" // FILENAME_* defines
#include "plugin.h" // LoadPluginSettings
-#include <cassert>
-#include <algorithm>
-#include <termios.h>
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-#if ENABLE_NLS
-# include <libintl.h>
-# define _(S) gettext(S)
-#else
-# define _(S) (S)
-#endif
#include "abrt_packages.h"
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);
diff --git a/src/hooks/abrt-hook-ccpp.cpp b/src/hooks/abrt-hook-ccpp.cpp
index e53007a4..1e469890 100644
--- a/src/hooks/abrt-hook-ccpp.cpp
+++ b/src/hooks/abrt-hook-ccpp.cpp
@@ -416,112 +416,112 @@ int main(int argc, char** argv)
return 1;
CDebugDump dd;
- char *cmdline = get_cmdline(pid); /* never NULL */
- char *reason = xasprintf("Process %s was killed by signal %s (SIG%s)", executable, signal_str, signame ? signame : signal_str);
- dd.Create(path, uid);
- dd.SaveText(FILENAME_ANALYZER, "CCpp");
- dd.SaveText(FILENAME_EXECUTABLE, executable);
- dd.SaveText(FILENAME_CMDLINE, cmdline);
- dd.SaveText(FILENAME_REASON, reason);
- free(cmdline);
- free(reason);
-
- if (src_fd_binary > 0)
+ if (dd.Create(path, uid))
{
- strcpy(path + path_len, "/"FILENAME_BINARY);
- int dst_fd_binary = xopen3(path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
- off_t sz = copyfd_eof(src_fd_binary, dst_fd_binary, COPYFD_SPARSE);
- if (sz < 0 || fsync(dst_fd_binary) != 0)
+ char *cmdline = get_cmdline(pid); /* never NULL */
+ char *reason = xasprintf("Process %s was killed by signal %s (SIG%s)", executable, signal_str, signame ? signame : signal_str);
+ dd.SaveText(FILENAME_ANALYZER, "CCpp");
+ dd.SaveText(FILENAME_EXECUTABLE, executable);
+ dd.SaveText(FILENAME_CMDLINE, cmdline);
+ dd.SaveText(FILENAME_REASON, reason);
+ free(cmdline);
+ free(reason);
+
+ if (src_fd_binary > 0)
{
- unlink(path);
- error_msg_and_die("error saving binary image to %s", path);
+ strcpy(path + path_len, "/"FILENAME_BINARY);
+ int dst_fd_binary = xopen3(path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
+ off_t sz = copyfd_eof(src_fd_binary, dst_fd_binary, COPYFD_SPARSE);
+ if (sz < 0 || fsync(dst_fd_binary) != 0)
+ {
+ unlink(path);
+ error_msg_and_die("error saving binary image to %s", path);
+ }
+ close(dst_fd_binary);
+ close(src_fd_binary);
}
- close(dst_fd_binary);
- close(src_fd_binary);
- }
- /* We need coredumps to be readable by all, because
- * when abrt daemon processes coredump,
- * process producing backtrace is run under the same UID
- * as the crashed process.
- * Thus 644, not 600 */
- strcpy(path + path_len, "/"FILENAME_COREDUMP);
- int abrt_core_fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644);
- if (abrt_core_fd < 0)
- {
- int sv_errno = errno;
- dd.Delete();
- dd.Close();
- if (user_core_fd >= 0)
+ /* We need coredumps to be readable by all, because
+ * when abrt daemon processes coredump,
+ * process producing backtrace is run under the same UID
+ * as the crashed process.
+ * Thus 644, not 600 */
+ strcpy(path + path_len, "/"FILENAME_COREDUMP);
+ int abrt_core_fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644);
+ if (abrt_core_fd < 0)
{
- xchdir(user_pwd);
- unlink(core_basename);
+ int sv_errno = errno;
+ dd.Delete();
+ dd.Close();
+ if (user_core_fd >= 0)
+ {
+ xchdir(user_pwd);
+ unlink(core_basename);
+ }
+ errno = sv_errno;
+ perror_msg_and_die("can't open '%s'", path);
}
- errno = sv_errno;
- perror_msg_and_die("can't open '%s'", path);
- }
- /* We write both coredumps at once.
- * We can't write user coredump first, since it might be truncated
- * and thus can't be copied and used as abrt coredump;
- * and if we write abrt coredump first and then copy it as user one,
- * then we have a race when process exits but coredump does not exist yet:
- * $ echo -e '#include<signal.h>\nmain(){raise(SIGSEGV);}' | gcc -o test -x c -
- * $ rm -f core*; ulimit -c unlimited; ./test; ls -l core*
- * 21631 Segmentation fault (core dumped) ./test
- * ls: cannot access core*: No such file or directory <=== BAD
- */
+ /* We write both coredumps at once.
+ * We can't write user coredump first, since it might be truncated
+ * and thus can't be copied and used as abrt coredump;
+ * and if we write abrt coredump first and then copy it as user one,
+ * then we have a race when process exits but coredump does not exist yet:
+ * $ echo -e '#include<signal.h>\nmain(){raise(SIGSEGV);}' | gcc -o test -x c -
+ * $ rm -f core*; ulimit -c unlimited; ./test; ls -l core*
+ * 21631 Segmentation fault (core dumped) ./test
+ * ls: cannot access core*: No such file or directory <=== BAD
+ */
//TODO: fchown abrt_core_fd to uid:abrt?
//Currently it is owned by 0:0 but is readable by anyone, so the owner
//of the crashed binary still can access it, as he has
//r-x access to the dump dir.
- off_t core_size = copyfd_sparse(STDIN_FILENO, abrt_core_fd, user_core_fd, ulimit_c);
- if (core_size < 0 || fsync(abrt_core_fd) != 0)
- {
- unlink(path);
- dd.Delete();
- dd.Close();
- if (user_core_fd >= 0)
+ off_t core_size = copyfd_sparse(STDIN_FILENO, abrt_core_fd, user_core_fd, ulimit_c);
+ if (core_size < 0 || fsync(abrt_core_fd) != 0)
+ {
+ unlink(path);
+ dd.Delete();
+ dd.Close();
+ if (user_core_fd >= 0)
+ {
+ xchdir(user_pwd);
+ unlink(core_basename);
+ }
+ /* copyfd_sparse logs the error including errno string,
+ * but it does not log file name */
+ error_msg_and_die("error writing %s", path);
+ }
+ log("saved core dump of pid %lu (%s) to %s (%llu bytes)", (long)pid, executable, path, (long long)core_size);
+ if (user_core_fd >= 0 && core_size >= ulimit_c)
{
+ /* user coredump is too big, nuke it */
xchdir(user_pwd);
unlink(core_basename);
}
- /* copyfd_sparse logs the error including errno string,
- * but it does not log file name */
- error_msg_and_die("error writing %s", path);
- }
- log("saved core dump of pid %lu (%s) to %s (%llu bytes)", (long)pid, executable, path, (long long)core_size);
- if (user_core_fd >= 0 && core_size >= ulimit_c)
- {
- /* user coredump is too big, nuke it */
- xchdir(user_pwd);
- unlink(core_basename);
- }
- /* We close dumpdir before we start catering for crash storm case.
- * Otherwise, delete_debug_dump_dir's from other concurrent
- * CCpp's won't be able to delete our dump (their delete_debug_dump_dir
- * will wait for us), and we won't be able to delete their dumps.
- * Classic deadlock.
- */
- dd.Close();
- path[path_len] = '\0'; /* path now contains only directory name */
- char *newpath = xstrndup(path, path_len - (sizeof(".new")-1));
- if (rename(path, newpath) == 0)
- strcpy(path, newpath);
- free(newpath);
-
- /* rhbz#539551: "abrt going crazy when crashing process is respawned" */
- if (setting_MaxCrashReportsSize > 0)
- {
- trim_debug_dumps(setting_MaxCrashReportsSize, path);
- }
+ /* We close dumpdir before we start catering for crash storm case.
+ * Otherwise, delete_debug_dump_dir's from other concurrent
+ * CCpp's won't be able to delete our dump (their delete_debug_dump_dir
+ * will wait for us), and we won't be able to delete their dumps.
+ * Classic deadlock.
+ */
+ dd.Close();
+ path[path_len] = '\0'; /* path now contains only directory name */
+ char *newpath = xstrndup(path, path_len - (sizeof(".new")-1));
+ if (rename(path, newpath) == 0)
+ strcpy(path, newpath);
+ free(newpath);
+
+ /* rhbz#539551: "abrt going crazy when crashing process is respawned" */
+ if (setting_MaxCrashReportsSize > 0)
+ {
+ trim_debug_dumps(setting_MaxCrashReportsSize, path);
+ }
- return 0;
- }
- catch (CABRTException& e)
- {
- error_msg_and_die("%s", e.what());
+ return 0;
+ }
+ else
+ xfunc_die();
}
catch (std::exception& e)
{
diff --git a/src/hooks/dumpoops.cpp b/src/hooks/dumpoops.cpp
index a2d2353a..a14fb65b 100644
--- a/src/hooks/dumpoops.cpp
+++ b/src/hooks/dumpoops.cpp
@@ -77,7 +77,7 @@ int main(int argc, char **argv)
// const plugin_info_t *plugin_info;
CPlugin* (*plugin_newf)(void);
int (*scan_syslog_file)(vector_string_t& oopsList, const char *filename, time_t *last_changed_p);
- void (*save_oops_to_debug_dump)(const vector_string_t& oopsList);
+ int (*save_oops_to_debug_dump)(const vector_string_t& oopsList);
void *handle;
errno = 0;
@@ -110,11 +110,10 @@ int main(int argc, char **argv)
}
if (opt_d) {
log("dumping oopses");
- try {
- save_oops_to_debug_dump(oopsList);
- }
- catch (CABRTException& e) {
- fprintf(stderr, "Error: %s\n", e.what());
+ int errors = save_oops_to_debug_dump(oopsList);
+ if (errors > 0)
+ {
+ log("%d errors while dumping oopses", errors);
return 1;
}
}