diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-02-08 18:17:16 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-02-08 18:17:16 +0100 |
commit | ed333008ad25e2ca4d590cf2052337ef6cf1af71 (patch) | |
tree | 5a8e2efbce3029cd4066dcbd5b4802d70b4e00f5 /lib/Plugins/Python.cpp | |
parent | f80fd803eab649f6b245b3169b165ba2fd170a6e (diff) | |
download | abrt-ed333008ad25e2ca4d590cf2052337ef6cf1af71.tar.gz abrt-ed333008ad25e2ca4d590cf2052337ef6cf1af71.tar.xz abrt-ed333008ad25e2ca4d590cf2052337ef6cf1af71.zip |
python hook: move UUID generation to abrtd; generate REASON, add it to bz title
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib/Plugins/Python.cpp')
-rw-r--r-- | lib/Plugins/Python.cpp | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/lib/Plugins/Python.cpp b/lib/Plugins/Python.cpp index cf4d81e2..d6a3084d 100644 --- a/lib/Plugins/Python.cpp +++ b/lib/Plugins/Python.cpp @@ -20,21 +20,45 @@ #include "Python.h" #include "DebugDump.h" #include "ABRTException.h" +#include "Python_hash.h" -static std::string CreateHash(const char *pDebugDumpDir) +using namespace std; + +string CAnalyzerPython::GetLocalUUID(const char *pDebugDumpDir) { CDebugDump dd; dd.Open(pDebugDumpDir); - std::string uuid; - dd.LoadText(FILENAME_UUID, uuid); - return uuid; -} + string bt; + dd.LoadText(FILENAME_BACKTRACE, bt); + + const char *bt_str = bt.c_str(); + const char *bt_end = strchrnul(bt_str, '\n'); + + char hash_str[MD5_RESULT_LEN*2 + 1]; + unsigned char hash2[MD5_RESULT_LEN]; + md5_ctx_t md5ctx; + md5_begin(&md5ctx); + md5_hash(bt_str, bt_end - bt_str, &md5ctx); + md5_end(hash2, &md5ctx); + + // Hash is MD5_RESULT_LEN bytes long, but we use only first 4 + // (I don't know why old Python code was using only 4, I mimic that) + unsigned len = 4; + 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, (int)(bt_end - bt_str), bt_str); + + return hash_str; -std::string CAnalyzerPython::GetLocalUUID(const char *pDebugDumpDir) -{ - return CreateHash(pDebugDumpDir); } -std::string CAnalyzerPython::GetGlobalUUID(const char *pDebugDumpDir) +string CAnalyzerPython::GetGlobalUUID(const char *pDebugDumpDir) { return GetLocalUUID(pDebugDumpDir); } |