From 2a29e9a99b98f9060284a1116ad82bacaa04fb6f Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 20 Nov 2009 14:18:03 +0100 Subject: do not report uid resolution error as *error*; report UID -1 as "N/A" Signed-off-by: Denys Vlasenko --- src/Gui/CCMainWindow.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py index ee802a8..f34ac2e 100644 --- a/src/Gui/CCMainWindow.py +++ b/src/Gui/CCMainWindow.py @@ -202,10 +202,12 @@ class MainWindow(): except: icon = None if os.getuid() == 0: - try: - user = pwd.getpwuid(int(entry.getUID()))[0] - except Exception, e: - user = _("Can't get username for uid %s" % entry.getUID()) + user = "N/A" + if entry.getUID() != "-1": + try: + user = pwd.getpwuid(int(entry.getUID()))[0] + except Exception, e: + user = "UID: %s" % entry.getUID() n = self.dumpsListStore.append([icon, entry.getPackage(), entry.getExecutable(), entry.getTime("%c"), entry.getCount(), user, entry.isReported(), entry]) else: -- cgit From d36c440b0393908208e70a66d38bf1cd2a7c60f9 Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Fri, 20 Nov 2009 14:31:37 +0100 Subject: GUI: fix button order in question_dialog --- src/Gui/CC_gui_functions.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Gui/CC_gui_functions.py b/src/Gui/CC_gui_functions.py index bfc1318..86ca54e 100644 --- a/src/Gui/CC_gui_functions.py +++ b/src/Gui/CC_gui_functions.py @@ -141,9 +141,11 @@ def gui_question_dialog ( message, parent_dialog=None, dialog = gtk.MessageDialog( parent_dialog, gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, - message_type, gtk.BUTTONS_YES_NO, + message_type, gtk.BUTTONS_NONE, message ) dialog.add_button("gtk-cancel", gtk.RESPONSE_CANCEL) + dialog.add_button("gtk-yes", gtk.RESPONSE_YES) + dialog.add_button("gtk-no", gtk.RESPONSE_NO) dialog.set_markup(message) if parent_dialog: dialog.set_position (gtk.WIN_POS_CENTER_ON_PARENT) -- cgit From 9825281af6cdcdac7d27ba5ae3f10429c15f576d Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Fri, 20 Nov 2009 15:42:50 +0100 Subject: GUI: reorder question_dialog buttons --- src/Gui/CC_gui_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Gui/CC_gui_functions.py b/src/Gui/CC_gui_functions.py index 86ca54e..511e4bc 100644 --- a/src/Gui/CC_gui_functions.py +++ b/src/Gui/CC_gui_functions.py @@ -144,8 +144,8 @@ def gui_question_dialog ( message, parent_dialog=None, message_type, gtk.BUTTONS_NONE, message ) dialog.add_button("gtk-cancel", gtk.RESPONSE_CANCEL) - dialog.add_button("gtk-yes", gtk.RESPONSE_YES) dialog.add_button("gtk-no", gtk.RESPONSE_NO) + dialog.add_button("gtk-yes", gtk.RESPONSE_YES) dialog.set_markup(message) if parent_dialog: dialog.set_position (gtk.WIN_POS_CENTER_ON_PARENT) -- cgit From 4b3c5291814821a6f9824971b8a00771a378f6eb Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Mon, 23 Nov 2009 14:11:19 +0100 Subject: kerneloops use only one config. Kerneloops.conf merge addon-kerneloops and plugin-kerneloopsreporter into one package --- src/Daemon/PluginManager.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Daemon/PluginManager.cpp b/src/Daemon/PluginManager.cpp index 2f4d875..a75b48b 100644 --- a/src/Daemon/PluginManager.cpp +++ b/src/Daemon/PluginManager.cpp @@ -205,7 +205,19 @@ void CPluginManager::RegisterPlugin(const char *pName) CPlugin* plugin = abrt_plugin->second->PluginNew(); map_plugin_settings_t pluginSettings; - LoadPluginSettings(ssprintf(PLUGINS_CONF_DIR"/%s."PLUGINS_CONF_EXTENSION, pName).c_str(), pluginSettings); + if ((strcmp(pName, "Kerneloops") == 0) + || (strcmp(pName, "KerneloopsReporter") == 0) + || (strcmp(pName, "KerneloopsScanner") == 0) + ) + { + LoadPluginSettings(PLUGINS_CONF_DIR"/Kerneloops."PLUGINS_CONF_EXTENSION, pluginSettings); + VERB3 log("Load kerneloops.conf settings"); + } + else + { + LoadPluginSettings(ssprintf(PLUGINS_CONF_DIR"/%s."PLUGINS_CONF_EXTENSION, pName).c_str(), pluginSettings); + VERB3 log("Load %s.conf settings", pName); + } try { plugin->Init(); -- cgit From 47d99223599b1c880dd0e2b827213fad60b7ff11 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 23 Nov 2009 14:53:57 +0100 Subject: CCpp.cpp: quote parameters if needed. closes 540164 Signed-off-by: Denys Vlasenko --- src/Hooks/CCpp.cpp | 100 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 69 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/Hooks/CCpp.cpp b/src/Hooks/CCpp.cpp index 2b75381..783c880 100644 --- a/src/Hooks/CCpp.cpp +++ b/src/Hooks/CCpp.cpp @@ -1,8 +1,8 @@ /* CCpp.cpp - the hook for C/C++ crashing program - Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com) - Copyright (C) 2009 RedHat inc. + Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com) + Copyright (C) 2009 RedHat inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,17 +19,15 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "abrtlib.h" - #include "DebugDump.h" #include "ABRTException.h" #include -#include #define FILENAME_EXECUTABLE "executable" #define FILENAME_CMDLINE "cmdline" #define FILENAME_COREDUMP "coredump" -#define VAR_RUN_PID_FILE VAR_RUN"/abrt.pid" +#define VAR_RUN_PID_FILE VAR_RUN"/abrt.pid" static char* get_executable(pid_t pid) { @@ -46,16 +44,71 @@ static char* get_executable(pid_t pid) return NULL; } +static char *append_escaped(char *start, const char *s) +{ + char hex_char_buf[] = "\\x00"; + + *start++ = ' '; + char *dst = start; + const unsigned char *p = (unsigned char *)s; + + while (1) + { + const unsigned char *old_p = p; + while (*p > ' ' && *p <= 0x7e && *p != '\"' && *p != '\'' && *p != '\\') + p++; + if (dst == start) + { + if (p != (unsigned char *)s && *p == '\0') + { + /* entire word does not need escaping and quoting */ + strcpy(dst, s); + dst += strlen(s); + return dst; + } + *dst++ = '\''; + } + + strncpy(dst, s, (p - old_p)); + dst += (p - old_p); + + if (*p == '\0') + { + *dst++ = '\''; + *dst = '\0'; + return dst; + } + const char *a; + switch (*p) + { + case '\r': a = "\\r"; break; + case '\n': a = "\\n"; break; + case '\t': a = "\\t"; break; + case '\'': a = "\\\'"; break; + case '\"': a = "\\\""; break; + case '\\': a = "\\\\"; break; + case ' ': a = " "; break; + default: + hex_char_buf[2] = "0123456789abcdef"[*p >> 4]; + hex_char_buf[3] = "0123456789abcdef"[*p & 0xf]; + a = hex_char_buf; + } + strcpy(dst, a); + dst += strlen(a); + p++; + } +} + // taken from kernel #define COMMAND_LINE_SIZE 2048 - static char* get_cmdline(pid_t pid) { - char path[PATH_MAX]; + char path[sizeof("/proc/%u/cmdline") + sizeof(int)*3]; char cmdline[COMMAND_LINE_SIZE]; - snprintf(path, sizeof(path), "/proc/%u/cmdline", (int)pid); - int idx = 0; + char escaped_cmdline[COMMAND_LINE_SIZE*4 + 4]; + escaped_cmdline[1] = '\0'; + sprintf(path, "/proc/%u/cmdline", (int)pid); int fd = open(path, O_RDONLY); if (fd >= 0) { @@ -64,33 +117,18 @@ static char* get_cmdline(pid_t pid) if (len > 0) { - /* In Linux, there is always one trailing NUL byte, - * prevent it from being replaced by space below. - */ - if (cmdline[len - 1] == '\0') - len--; - - while (idx < len) + cmdline[len] = '\0'; + char *src = cmdline; + char *dst = escaped_cmdline; + while ((src - cmdline) < len) { - unsigned char ch = cmdline[idx]; - if (ch == '\0') - { - cmdline[idx++] = ' '; - } - else if (ch >= ' ' && ch <= 0x7e) - { - cmdline[idx++] = ch; - } - else - { - cmdline[idx++] = '?'; - } + dst = append_escaped(dst, src); + src += strlen(src) + 1; } } } - cmdline[idx] = '\0'; - return xstrdup(cmdline); + return xstrdup(escaped_cmdline + 1); /* +1 skips extraneous leading space */ } static int daemon_is_ok() -- cgit From 84b0c28cf3f41067069409cca888a95c4ccda27f Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 23 Nov 2009 17:27:05 +0100 Subject: src/Hooks/CCpp.cpp: do save abrtd's own coredumps, but carefully... Signed-off-by: Denys Vlasenko --- src/Hooks/CCpp.cpp | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Hooks/CCpp.cpp b/src/Hooks/CCpp.cpp index 783c880..90aa1bf 100644 --- a/src/Hooks/CCpp.cpp +++ b/src/Hooks/CCpp.cpp @@ -207,18 +207,38 @@ int main(int argc, char** argv) { error_msg_and_die("can't read /proc/%u/exe link", (int)pid); } - if (strstr(executable, "/abrt")) + if (strstr(executable, "/hookCCpp")) { - /* free(executable); - why bother? */ - error_msg_and_die("pid %u is '%s', not dumping it to avoid abrt recursion", + error_msg_and_die("pid %u is '%s', not dumping it to avoid recursion", (int)pid, executable); } + char path[PATH_MAX]; + + if (strstr(executable, "/abrtd")) + { + /* If abrtd crashes, we don't want to create a _directory_, + * since that can make new copy of abrtd to process it, + * and crash again... + * On the contrary, mere files are ignored by abrtd. + */ + snprintf(path, sizeof(path), "%s/abrtd-coredump", dddir); + int fd = xopen3(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); + off_t size = copyfd_eof(STDIN_FILENO, fd); + if (size < 0 || close(fd) != 0) + { + unlink(path); + /* copyfd_eof logs the error including errno string, + * but it does not log file name */ + error_msg_and_die("error saving coredump to %s", path); + } + log("saved core dump of pid %u to %s (%llu bytes)", (int)pid, path, (long long)size); + return 0; + } + char* cmdline = get_cmdline(pid); /* never NULL */ - char path[PATH_MAX]; snprintf(path, sizeof(path), "%s/ccpp-%ld-%u", dddir, (long)time(NULL), (int)pid); - CDebugDump dd; dd.Create(path, uid); dd.SaveText(FILENAME_ANALYZER, "CCpp"); @@ -229,12 +249,11 @@ int main(int argc, char** argv) int len = strlen(path); snprintf(path + len, sizeof(path) - len, "/"FILENAME_COREDUMP); - int fd; /* We need coredumps to be readable by all, because * process producing backtraces is run under the same UID * as the crashed process. * Thus 644, not 600 */ - fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); + int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd < 0) { dd.Delete(); @@ -254,6 +273,7 @@ int main(int argc, char** argv) /* free(executable); - why bother? */ /* free(cmdline); */ log("saved core dump of pid %u to %s (%llu bytes)", (int)pid, path, (long long)size); + return 0; } catch (CABRTException& e) { -- cgit From 642fc6b9b9120917d5f7c947a5a293e3b6960407 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 23 Nov 2009 18:32:20 +0100 Subject: src/Hooks/CCpp.cpp: print signal name; document future work in comments Signed-off-by: Denys Vlasenko --- src/Hooks/CCpp.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Hooks/CCpp.cpp b/src/Hooks/CCpp.cpp index 90aa1bf..138d0d6 100644 --- a/src/Hooks/CCpp.cpp +++ b/src/Hooks/CCpp.cpp @@ -219,7 +219,7 @@ int main(int argc, char** argv) { /* If abrtd crashes, we don't want to create a _directory_, * since that can make new copy of abrtd to process it, - * and crash again... + * and maybe crash again... * On the contrary, mere files are ignored by abrtd. */ snprintf(path, sizeof(path), "%s/abrtd-coredump", dddir); @@ -236,7 +236,19 @@ int main(int argc, char** argv) return 0; } + /* rhbz#539551: "abrt going crazy when crashing process is respawned". + * Do we want to protect against or ameliorate this? How? Ideas: + * (1) nice ourself? + * (2) check total size of dump dir, if it overflows, either abort dump + * or delete oldest/biggest dumps? [abort would be simpler, + * abrtd already does "delete on overflow" thing] + * (3) detect parallel dumps in progress and back off + * (pause/renice further/??) + */ + char* cmdline = get_cmdline(pid); /* never NULL */ + const char *signame = strsignal(atoi(signal_str)); + char *reason = xasprintf("Process was terminated by signal %s (%s)", signal_str, signame ? signame : signal_str); snprintf(path, sizeof(path), "%s/ccpp-%ld-%u", dddir, (long)time(NULL), (int)pid); CDebugDump dd; @@ -244,7 +256,7 @@ int main(int argc, char** argv) dd.SaveText(FILENAME_ANALYZER, "CCpp"); dd.SaveText(FILENAME_EXECUTABLE, executable); dd.SaveText(FILENAME_CMDLINE, cmdline); - dd.SaveText(FILENAME_REASON, ssprintf("Process was terminated by signal %s", signal_str).c_str()); + dd.SaveText(FILENAME_REASON, reason); int len = strlen(path); snprintf(path + len, sizeof(path) - len, "/"FILENAME_COREDUMP); -- cgit