summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-01-06 16:18:09 +0100
committerDenys Vlasenko <dvlasenk@redhat.com>2011-01-06 16:18:09 +0100
commitd108d7d2fbe0b178110295fd8335c258f699a5d4 (patch)
tree3bebcc8c7f66a15383be577beb04300f6fe6e9af /src/plugins
parent6c7086f6c0086496a5a1ae9ab13fdbb310e070ba (diff)
downloadabrt-d108d7d2fbe0b178110295fd8335c258f699a5d4.tar.gz
abrt-d108d7d2fbe0b178110295fd8335c258f699a5d4.tar.xz
abrt-d108d7d2fbe0b178110295fd8335c258f699a5d4.zip
pass old pattern to ccpp hook and use it
abrtd: instead of "|/usr/libexec/abrt-ccpp-hook DEBUG_DUMPS_DIR %p %s %u %c", sets coredump handler to "|/usr/libexec/abrt-ccpp-hook DEBUG_DUMPS_DIR %s %c %p %u %g %t %h %e OLD_PATTERN" abrt-ccpp-hook: expands OLD_PATTERN using values of %s %c %p %u %g %t %h %e and uses it as a name of "compat coredump". Patch has a feature which prevents usage of kernel-truncated OLD_PATTERN: it is passed as hex string *with terminating NUL* (encoded as 00). If ccpp hook doesn't see 00, it refuses to use OLD_PATTERN and uses string "core" instead. Run tested. On a new kernel, passes up to 27 char long old pattern. Longer patterns are still truncated. This may be improved in future kernels. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/CCpp.cpp55
1 files changed, 44 insertions, 11 deletions
diff --git a/src/plugins/CCpp.cpp b/src/plugins/CCpp.cpp
index d88a593d..df2c4482 100644
--- a/src/plugins/CCpp.cpp
+++ b/src/plugins/CCpp.cpp
@@ -26,16 +26,28 @@
using namespace std;
#define CORE_PATTERN_IFACE "/proc/sys/kernel/core_pattern"
-#define CORE_PATTERN "|"CCPP_HOOK_PATH" "DEBUG_DUMPS_DIR" %p %s %u %c"
+/*
+ * %s - signal number
+ * %c - ulimit -c value
+ * %p - pid
+ * %u - uid
+ * %g - gid
+ * %t - UNIX time of dump
+ * %h - hostname
+ * %e - executable filename
+ * %% - output one "%"
+ */
+#define CORE_PATTERN "|"CCPP_HOOK_PATH" "DEBUG_DUMPS_DIR" %s %c %p %u %g %t %h %e"
+
#define CORE_PIPE_LIMIT_IFACE "/proc/sys/kernel/core_pipe_limit"
/* core_pipe_limit specifies how many dump_helpers might run at the same time
* 0 - means unlimited, but it's not guaranteed that /proc/<pid> of crashing
- * process will be available for dump_helper
+ * process will be available for dump_helper.
* 4 - means that 4 dump_helpers can run at the same time (the rest will also
- * run, but they will fail to read /proc/<pid>)
- * This should be enough for ABRT, we can miss some crashes, but what are
- * the odds that more processes crash at the same time?
- * The value of 4 has been recommended by nhorman.
+ * run, but they will fail to read /proc/<pid>).
+ * This should be enough for ABRT, we can miss some crashes, but what are
+ * the odds that more processes crash at the same time?
+ * The value of 4 has been recommended by nhorman.
*/
#define CORE_PIPE_LIMIT "4"
@@ -133,7 +145,7 @@ void CAnalyzerCCpp::Init()
}
if (m_sOldCorePattern[0] == '|')
{
- if (m_sOldCorePattern == CORE_PATTERN)
+ if (strncmp(m_sOldCorePattern.c_str(), CORE_PATTERN, strlen(CORE_PATTERN)) == 0)
{
log("warning: %s already contains %s, "
"did abrt daemon crash recently?",
@@ -157,14 +169,35 @@ void CAnalyzerCCpp::Init()
fp = fopen(CORE_PATTERN_IFACE, "w");
if (fp)
{
- fputs(CORE_PATTERN, fp);
+ if (m_sOldCorePattern[0] != '|')
+ {
+ const char *old = m_sOldCorePattern.c_str();
+ unsigned len = strchrnul(old, '\n') - old;
+ char *hex_old = (char*)xmalloc(len * 2 + 1);
+ bin2hex(hex_old, old, len)[0] = '\0';
+ /* Trailing 00 is a sentinel. Decoder in the hook will check it.
+ * If it won't see it, then kernel has truncated the argument:
+ */
+ char *pattern = xasprintf("%s %s00", CORE_PATTERN, hex_old);
+ //log("old:'%s'->'%s'", old, hex_old);
+ //log("pattern:'%s'", pattern);
+
+ fputs(pattern, fp);
+
+ free(pattern);
+ free(hex_old);
+ }
+ else
+ {
+ fputs(CORE_PATTERN, fp);
+ }
fclose(fp);
}
/* read the core_pipe_limit and change it if it's == 0
- otherwise the abrt-hook-ccpp won't be able to read /proc/<pid>
- of the crashing process
- */
+ * otherwise the abrt-hook-ccpp won't be able to read /proc/<pid>
+ * of the crashing process
+ */
fp = fopen(CORE_PIPE_LIMIT_IFACE, "r");
if (fp)
{