summaryrefslogtreecommitdiffstats
path: root/src
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
parent8b22e91dc2ac3e73d628486c91f83da5a0e5ec44 (diff)
parent96071530ea85635cf87a6bf650b7f5ddbd219f44 (diff)
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'src')
-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
10 files changed, 212 insertions, 230 deletions
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;
}
}