diff options
Diffstat (limited to 'src/Hooks')
-rw-r--r-- | src/Hooks/abrt-hook-ccpp.cpp | 5 | ||||
-rw-r--r-- | src/Hooks/abrt-hook-python.cpp | 29 | ||||
-rw-r--r-- | src/Hooks/abrt_exception_handler.py.in | 11 |
3 files changed, 19 insertions, 26 deletions
diff --git a/src/Hooks/abrt-hook-ccpp.cpp b/src/Hooks/abrt-hook-ccpp.cpp index 54a4c7a5..9d1dc19c 100644 --- a/src/Hooks/abrt-hook-ccpp.cpp +++ b/src/Hooks/abrt-hook-ccpp.cpp @@ -99,8 +99,7 @@ int main(int argc, char** argv) case SIGFPE : signame = "FPE" ; break; case SIGSEGV: signame = "SEGV"; break; } - if (signame == NULL) - { + if (signame == NULL) { /* not a signal we care about, exit silently */ return 0; } @@ -223,8 +222,10 @@ int main(int argc, char** argv) core_fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644); if (core_fd < 0) { + int sv_errno = errno; dd.Delete(); dd.Close(); + errno = sv_errno; perror_msg_and_die("can't open '%s'", path); } //TODO: chown to uid:abrt? diff --git a/src/Hooks/abrt-hook-python.cpp b/src/Hooks/abrt-hook-python.cpp index 4607b87d..356174f8 100644 --- a/src/Hooks/abrt-hook-python.cpp +++ b/src/Hooks/abrt-hook-python.cpp @@ -20,8 +20,8 @@ */ #include <getopt.h> #include <syslog.h> -/* We can easily get rid of abrtlib (libABRTUtils.so) usage in this file, - * but DebugDump will pull it in anyway */ +// We can easily get rid of abrtlib (libABRTUtils.so) usage in this file, +// but DebugDump will pull it in anyway #include "abrtlib.h" #include "hooklib.h" #include "DebugDump.h" @@ -36,14 +36,13 @@ static char *pid; static char *executable; -static char *uuid; -/* Note: "" will return false */ +// Note: "" will return false static bool isxdigit_str(const char *str) { do { - if ((*str < '0' || *str > '9') /* not a digit */ - && ((*str | 0x20) < 'a' || (*str | 0x20) > 'f') /* not A-F or a-f */ + if ((*str < '0' || *str > '9') // not a digit + && ((*str | 0x20) < 'a' || (*str | 0x20) > 'f') // not A-F or a-f ) { return false; @@ -70,7 +69,6 @@ int main(int argc, char** argv) // name , has_arg , flag, val { "pid" , required_argument, NULL, 'p' }, { "executable", required_argument, NULL, 'e' }, - { "uuid" , required_argument, NULL, 'u' }, { 0 }, }; int opt; @@ -84,9 +82,6 @@ int main(int argc, char** argv) case 'e': executable = optarg; break; - case 'u': - uuid = optarg; - break; default: usage: error_msg_and_die( @@ -94,13 +89,10 @@ int main(int argc, char** argv) "\nOptions:\n" " -p,--pid PID PID of process that caused the crash\n" " -p,--executable PATH absolute path to the program that crashed\n" - " -u,--uuid UUID hash generated from the backtrace\n" ); } } - if (!pid || !executable || !uuid) - goto usage; - if (strlen(uuid) > 128 || !isxdigit_str(uuid)) + if (!pid || !executable) goto usage; if (strlen(executable) > PATH_MAX || !printable_str(executable)) goto usage; @@ -134,7 +126,7 @@ int main(int argc, char** argv) } // This also checks that pid is a valid numeric string - char *cmdline = get_cmdline(xatou(pid)); /* never NULL */ + char *cmdline = get_cmdline(xatou(pid)); // never NULL // Create directory with the debug dump char path[PATH_MAX]; @@ -146,16 +138,21 @@ int main(int argc, char** argv) try { dd.Create(path, getuid()); } catch (CABRTException &e) { + dd.Delete(); + dd.Close(); error_msg_and_die("error while creating crash dump %s: %s", path, e.what()); } dd.SaveText(FILENAME_ANALYZER, "Python"); dd.SaveText(FILENAME_EXECUTABLE, executable); dd.SaveText(FILENAME_BACKTRACE, bt); + // python handler puts a short(er) crash descr in 1st line. Example: + // "CCMainWindow.py:1:<module>:ZeroDivisionError: integer division or modulo by zero" + strchrnul(bt, '\n')[0] = '\0'; + dd.SaveText(FILENAME_REASON, bt); free(bt); dd.SaveText(FILENAME_CMDLINE, cmdline); free(cmdline); - dd.SaveText(FILENAME_UUID, uuid); char uid[sizeof(long) * 3 + 2]; sprintf(uid, "%lu", (long)getuid()); dd.SaveText(FILENAME_UID, uid); diff --git a/src/Hooks/abrt_exception_handler.py.in b/src/Hooks/abrt_exception_handler.py.in index e21a5303..89f30132 100644 --- a/src/Hooks/abrt_exception_handler.py.in +++ b/src/Hooks/abrt_exception_handler.py.in @@ -27,7 +27,7 @@ import syslog import subprocess -def write_dump(pid, tb_uuid, tb): +def write_dump(pid, tb): executable = "Exception raised from python shell" if sys.argv[0]: # FIXME: is this reliable?! @@ -38,7 +38,6 @@ def write_dump(pid, tb_uuid, tb): command = ["/usr/libexec/abrt-hook-python"] command.append("--pid=%s" % pid) command.append("--executable=%s" % executable) - command.append("--uuid=%s" % tb_uuid) helper = subprocess.Popen(command, stdin=subprocess.PIPE) helper.communicate(tb) @@ -61,7 +60,6 @@ def handleMyException((etype, value, tb)): try: import os.path - from hashlib import md5 import traceback # "-c" appears in this case: @@ -83,14 +81,11 @@ def handleMyException((etype, value, tb)): ll[0] = os.path.basename(tblast[0]) tblast = ll - m = md5() ntext = "" for t in tblast: ntext += str(t) + ":" - m.update(str(t)) - tb_uuid = str(m.hexdigest())[:8] - text = "Summary: TB" + tb_uuid + " " + ntext + text = ntext text += extxt[0] text += "\n" text += "".join(elist) @@ -107,7 +102,7 @@ def handleMyException((etype, value, tb)): pass # add coredump saving - write_dump(os.getpid(), tb_uuid, text) + write_dump(os.getpid(), text) except: # silently ignore any error in this hook, |