From 8024b6ca0335cb59f737769f2e573435e32dd155 Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Tue, 2 Jun 2009 17:06:39 +0200 Subject: New hook for python apps - minor fixes in python analyzer --- lib/Plugins/Python.cpp | 72 ++++++++++++++++++-------------------------------- 1 file changed, 25 insertions(+), 47 deletions(-) (limited to 'lib/Plugins/Python.cpp') diff --git a/lib/Plugins/Python.cpp b/lib/Plugins/Python.cpp index dcf78fa..f58a6c9 100644 --- a/lib/Plugins/Python.cpp +++ b/lib/Plugins/Python.cpp @@ -1,54 +1,25 @@ #include "Python.h" #include "DebugDump.h" -#include -#include -#include -#include -#include +#include +#include "ABRTException.h" #define FILENAME_BACKTRACE "backtrace" +#define PYHOOK_CONFIG "/etc/abrt/pyhook.conf" -std::string CAnalyzerPython::CreateHash(const std::string& pInput) -{ - std::string ret = ""; - HASHContext* hc; - unsigned char hash[SHA1_LENGTH]; - unsigned int len; - - hc = HASH_Create(HASH_AlgSHA1); - if (!hc) - { - throw std::string("CAnalyzerPython::CreateHash(): cannot initialize hash."); - } - HASH_Begin(hc); - HASH_Update(hc, reinterpret_cast(pInput.c_str()), pInput.length()); - HASH_End(hc, hash, &len, sizeof(hash)); - HASH_Destroy(hc); - - unsigned int ii; - std::stringstream ss; - for (ii = 0; ii < len; ii++) - ss << std::setw(2) << std::setfill('0') << std::hex << (hash[ii]&0xff); - - return ss.str(); -} - -std::string CAnalyzerPython::GetLocalUUID(const std::string& pDebugDumpDir) +std::string CAnalyzerPython::CreateHash(const std::string& pDebugDumpDir) { + std::string uuid; CDebugDump dd; - std::string executable; - std::string package; - std::string backtrace; dd.Open(pDebugDumpDir); - dd.LoadText(FILENAME_EXECUTABLE, executable); - dd.LoadText(FILENAME_PACKAGE, package); - dd.LoadText(FILENAME_BACKTRACE, backtrace); + dd.LoadText("uuid", uuid); dd.Close(); + return uuid; +} - // TODO: get independent backtrace - - return CreateHash(package + executable + backtrace ); +std::string CAnalyzerPython::GetLocalUUID(const std::string& pDebugDumpDir) +{ + return CreateHash(pDebugDumpDir); } std::string CAnalyzerPython::GetGlobalUUID(const std::string& pDebugDumpDir) { @@ -57,16 +28,23 @@ std::string CAnalyzerPython::GetGlobalUUID(const std::string& pDebugDumpDir) void CAnalyzerPython::Init() { - // TODO: Copy abrt exception handler to proper place - if (NSS_NoDB_Init(NULL) != SECSuccess) - { - throw std::string("CAnalyzerPython::Init(): cannot initialize NSS library."); - } + std::ofstream fOutPySiteCustomize; + fOutPySiteCustomize.open(PYHOOK_CONFIG); + if (fOutPySiteCustomize.is_open()) + { + fOutPySiteCustomize << "enabled = yes" << std::endl; + fOutPySiteCustomize.close(); + } } - void CAnalyzerPython::DeInit() { // TODO: remove copied abrt exception handler - NSS_Shutdown(); + std::ofstream fOutPySiteCustomize; + fOutPySiteCustomize.open(PYHOOK_CONFIG); + if (fOutPySiteCustomize.is_open()) + { + fOutPySiteCustomize << "enabled = no" << std::endl; + fOutPySiteCustomize.close(); + } } -- cgit