summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-11-03 18:07:56 +0100
committerDenys Vlasenko <dvlasenk@redhat.com>2010-11-03 18:07:56 +0100
commita8f39ad24b77926929fe6780dfeba44ac0558a92 (patch)
tree34afaa6667ff688df49d0fe8597295d6a3a55b27 /lib
parentb6bb9e0ad581b5534ef51c627f274b0a24ebb7d7 (diff)
downloadabrt-a8f39ad24b77926929fe6780dfeba44ac0558a92.tar.gz
abrt-a8f39ad24b77926929fe6780dfeba44ac0558a92.tar.xz
abrt-a8f39ad24b77926929fe6780dfeba44ac0558a92.zip
abrtd: convert reporting step to run_action, part 1 (main)
There are a few things which are missing in this commit: for example, the list of possible reporting "paths" is not extracted from abrt_event.conf yet. Part 2 will deal with it. Tested: reporting thru bugzilla and thru logger. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/plugins/CCpp.cpp161
-rw-r--r--lib/plugins/CCpp.h1
-rw-r--r--lib/plugins/Kerneloops.cpp54
-rw-r--r--lib/plugins/Kerneloops.h2
-rw-r--r--lib/plugins/Python.cpp62
-rw-r--r--lib/plugins/Python.h4
6 files changed, 0 insertions, 284 deletions
diff --git a/lib/plugins/CCpp.cpp b/lib/plugins/CCpp.cpp
index ddc17206..fad9cf62 100644
--- a/lib/plugins/CCpp.cpp
+++ b/lib/plugins/CCpp.cpp
@@ -50,167 +50,6 @@ CAnalyzerCCpp::CAnalyzerCCpp() :
m_nGdbTimeoutSec(60)
{}
-static void create_hash(char hash_str[SHA1_RESULT_LEN*2 + 1], const char *pInput)
-{
- unsigned len;
- unsigned char hash2[SHA1_RESULT_LEN];
- sha1_ctx_t sha1ctx;
-
- sha1_begin(&sha1ctx);
- sha1_hash(pInput, strlen(pInput), &sha1ctx);
- sha1_end(hash2, &sha1ctx);
- len = SHA1_RESULT_LEN;
-
- char *d = hash_str;
- unsigned char *s = hash2;
- while (len)
- {
- *d++ = "0123456789abcdef"[*s >> 4];
- *d++ = "0123456789abcdef"[*s & 0xf];
- s++;
- len--;
- }
- *d = '\0';
- //log("hash2:%s str:'%s'", hash_str, pInput);
-}
-
-string CAnalyzerCCpp::GetGlobalUUID(const char *pDebugDumpDir)
-{
- struct dump_dir *dd = dd_opendir(pDebugDumpDir, /*flags:*/ 0);
- if (!dd)
- return string("");
-
- if (dd_exist(dd, FILENAME_DUPHASH))
- {
- char *uuid = dd_load_text(dd, FILENAME_DUPHASH);
- dd_close(dd);
- string ret = uuid;
- free(uuid);
- return ret;
- }
- else
- {
- // Compatibility code.
- // This whole block should be deleted for Fedora 14.
- log(_("Getting global universal unique identification..."));
-
- string backtrace_path = concat_path_file(pDebugDumpDir, FILENAME_BACKTRACE);
- char *executable = dd_load_text(dd, FILENAME_EXECUTABLE);
- char *package = dd_load_text(dd, FILENAME_PACKAGE);
- char *uid_str = m_bBacktrace ? dd_load_text(dd, CD_UID) : xstrdup("");
-
- string independent_backtrace;
- if (m_bBacktrace)
- {
- /* Run abrt-backtrace to get independent backtrace suitable
- to UUID calculation. */
- char *backtrace_path = concat_path_file(pDebugDumpDir, FILENAME_BACKTRACE);
- char *args[7];
- args[0] = (char*)"abrt-backtrace";
- args[1] = (char*)"--single-thread";
- args[2] = (char*)"--remove-exit-handlers";
- args[3] = (char*)"--frame-depth=5";
- args[4] = (char*)"--remove-noncrash-frames";
- args[5] = backtrace_path;
- args[6] = NULL;
-
- int pipeout[2];
- xpipe(pipeout); /* stdout of abrt-backtrace */
-
- fflush(NULL);
- pid_t child = fork();
- if (child == -1)
- perror_msg_and_die("fork");
- if (child == 0)
- {
- VERB1 log("Executing %s", args[0]);
-
- xmove_fd(pipeout[1], STDOUT_FILENO);
- close(pipeout[0]); /* read side of the pipe */
-
- /* abrt-backtrace is executed under the user's uid and gid. */
- uid_t uid = xatoi_u(uid_str);
- struct passwd* pw = getpwuid(uid);
- gid_t gid = pw ? pw->pw_gid : uid;
- setgroups(1, &gid);
- xsetregid(gid, gid);
- xsetreuid(uid, uid);
-
- execvp(args[0], args);
- VERB1 perror_msg("Can't execute '%s'", args[0]);
- exit(1);
- }
-
- free(backtrace_path);
- close(pipeout[1]); /* write side of the pipe */
-
- /* Read the result from abrt-backtrace. */
- int r;
- char buff[1024];
- while ((r = safe_read(pipeout[0], buff, sizeof(buff) - 1)) > 0)
- {
- buff[r] = '\0';
- independent_backtrace += buff;
- }
- close(pipeout[0]);
-
- /* Wait until it exits, and check the exit status. */
- errno = 0;
- int status;
- waitpid(child, &status, 0);
- if (!WIFEXITED(status))
- {
- perror_msg("abrt-backtrace not executed properly, "
- "status: %x signal: %d", status, WIFSIGNALED(status));
- }
- else
- {
- int exit_status = WEXITSTATUS(status);
- if (exit_status == 79) /* EX_PARSINGFAILED */
- {
- /* abrt-backtrace returns alternative backtrace
- representation in this case, so everything will work
- as expected except worse duplication detection */
- log_msg("abrt-backtrace failed to parse the backtrace");
- }
- else if (exit_status == 80) /* EX_THREADDETECTIONFAILED */
- {
- /* abrt-backtrace returns backtrace with all threads
- in this case, so everything will work as expected
- except worse duplication detection */
- log_msg("abrt-backtrace failed to determine crash frame");
- }
- else if (exit_status != 0)
- {
- /* this is unexpected problem and it should be investigated */
- error_msg("abrt-backtrace run failed, exit value: %d",
- exit_status);
- }
- }
-
- /*VERB1 log("abrt-backtrace result: %s", independent_backtrace.c_str());*/
- }
- /* else: no backtrace, independent_backtrace == ""
- no backtrace => rating = 0
- */
- else
- {
- dd_save_text(dd, FILENAME_RATING, "0");
- }
- dd_close(dd);
-
- char *hash_str = xasprintf("%s%s%s", package, executable, independent_backtrace.c_str());
- free(package);
- free(executable);
-
- char hash_str2[SHA1_RESULT_LEN*2 + 1];
- create_hash(hash_str2, hash_str);
- free(hash_str);
-
- return hash_str2;
- }
-}
-
/*
this is just a workaround until kernel changes it's behavior
when handling pipes in core_pattern
diff --git a/lib/plugins/CCpp.h b/lib/plugins/CCpp.h
index dcd80982..db372b01 100644
--- a/lib/plugins/CCpp.h
+++ b/lib/plugins/CCpp.h
@@ -41,7 +41,6 @@ class CAnalyzerCCpp : public CAnalyzer
public:
CAnalyzerCCpp();
- virtual std::string GetGlobalUUID(const char *pDebugDumpDir);
virtual void Init();
virtual void DeInit();
virtual void SetSettings(const map_plugin_settings_t& pSettings);
diff --git a/lib/plugins/Kerneloops.cpp b/lib/plugins/Kerneloops.cpp
index 0a59681b..37cab992 100644
--- a/lib/plugins/Kerneloops.cpp
+++ b/lib/plugins/Kerneloops.cpp
@@ -21,60 +21,6 @@
#include "Kerneloops.h"
#include "abrt_exception.h"
-using namespace std;
-
-static string load(const char *dirname, const char *filename)
-{
- string ret;
-
- struct dump_dir *dd = dd_opendir(dirname, /*flags:*/ 0);
- if (!dd)
- return ret; /* "" */
- char *s = dd_load_text(dd, filename);
- dd_close(dd);
-
- if (!s[0])
- {
- free(s);
-
- pid_t pid = fork();
- if (pid < 0)
- {
- perror_msg("fork");
- return ret; /* "" */
- }
- if (pid == 0) /* child */
- {
- char *argv[4]; /* abrt-action-analyze-oops -d DIR <NULL> */
- char **pp = argv;
- *pp++ = (char*)"abrt-action-analyze-oops";
- *pp++ = (char*)"-d";
- *pp++ = (char*)dirname;
- *pp = NULL;
-
- execvp(argv[0], argv);
- perror_msg_and_die("Can't execute '%s'", argv[0]);
- }
- /* parent */
- waitpid(pid, NULL, 0);
-
- dd = dd_opendir(dirname, /*flags:*/ 0);
- if (!dd)
- return ret; /* "" */
- s = dd_load_text(dd, filename);
- dd_close(dd);
- }
-
- ret = s;
- free(s);
- return ret;
-}
-
-string CAnalyzerKerneloops::GetGlobalUUID(const char *pDebugDumpDir)
-{
- return load(pDebugDumpDir, FILENAME_DUPHASH);
-}
-
PLUGIN_INFO(ANALYZER,
CAnalyzerKerneloops,
"Kerneloops",
diff --git a/lib/plugins/Kerneloops.h b/lib/plugins/Kerneloops.h
index af6bef0e..914f1fc8 100644
--- a/lib/plugins/Kerneloops.h
+++ b/lib/plugins/Kerneloops.h
@@ -33,8 +33,6 @@
class CAnalyzerKerneloops : public CAnalyzer
{
- public:
- virtual std::string GetGlobalUUID(const char *pDebugDumpDir);
};
#endif
diff --git a/lib/plugins/Python.cpp b/lib/plugins/Python.cpp
index 9d625a1c..e955b5fb 100644
--- a/lib/plugins/Python.cpp
+++ b/lib/plugins/Python.cpp
@@ -20,68 +20,6 @@
#include "Python.h"
#include "abrt_exception.h"
-using namespace std;
-
-static string load(const char *dirname, const char *filename)
-{
- string ret;
-
- struct dump_dir *dd = dd_opendir(dirname, /*flags:*/ 0);
- if (!dd)
- return ret; /* "" */
- char *s = dd_load_text(dd, filename);
- dd_close(dd);
-
- if (!s[0])
- {
- free(s);
-
- pid_t pid = fork();
- if (pid < 0)
- {
- perror_msg("fork");
- return ret; /* "" */
- }
- if (pid == 0) /* child */
- {
- char *argv[4]; /* abrt-action-analyze-python -d DIR <NULL> */
- char **pp = argv;
- *pp++ = (char*)"abrt-action-analyze-python";
- *pp++ = (char*)"-d";
- *pp++ = (char*)dirname;
- *pp = NULL;
-
- execvp(argv[0], argv);
- perror_msg_and_die("Can't execute '%s'", argv[0]);
- }
- /* parent */
- waitpid(pid, NULL, 0);
-
- dd = dd_opendir(dirname, /*flags:*/ 0);
- if (!dd)
- return ret; /* "" */
- s = dd_load_text(dd, filename);
- dd_close(dd);
- }
-
- ret = s;
- free(s);
- return ret;
-}
-
-string CAnalyzerPython::GetGlobalUUID(const char *pDebugDumpDir)
-{
- return load(pDebugDumpDir, FILENAME_DUPHASH);
-}
-
-void CAnalyzerPython::Init()
-{
-}
-
-void CAnalyzerPython::DeInit()
-{
-}
-
PLUGIN_INFO(ANALYZER,
CAnalyzerPython,
"Python",
diff --git a/lib/plugins/Python.h b/lib/plugins/Python.h
index c862ad45..3f01d2c6 100644
--- a/lib/plugins/Python.h
+++ b/lib/plugins/Python.h
@@ -25,10 +25,6 @@
class CAnalyzerPython : public CAnalyzer
{
- public:
- virtual std::string GetGlobalUUID(const char *pDebugDumpDir);
- virtual void Init();
- virtual void DeInit();
};
#endif /* PYTHON_H_ */