|
|
baab13 |
From fb05144fada665ac319b0d9fa1af7bc9f42e8c26 Mon Sep 17 00:00:00 2001
|
|
|
baab13 |
From: Martin Milata <mmilata@redhat.com>
|
|
|
baab13 |
Date: Thu, 16 Jul 2015 16:10:49 +0200
|
|
|
baab13 |
Subject: [PATCH] abrt-install-ccpp-hook check configuration
|
|
|
baab13 |
|
|
|
baab13 |
Check that either full coredump or core backtrace are configured to be
|
|
|
baab13 |
saved, fail init script if neither is.
|
|
|
baab13 |
|
|
|
baab13 |
Related to #829.
|
|
|
baab13 |
|
|
|
baab13 |
Signed-off-by: Martin Milata <mmilata@redhat.com>
|
|
|
baab13 |
---
|
|
|
baab13 |
src/hooks/abrt-hook-ccpp.c | 63 +++++++++++++++++++++++--------------
|
|
|
baab13 |
src/hooks/abrt-install-ccpp-hook.in | 5 +++
|
|
|
baab13 |
2 files changed, 44 insertions(+), 24 deletions(-)
|
|
|
baab13 |
|
|
|
baab13 |
diff --git a/src/hooks/abrt-hook-ccpp.c b/src/hooks/abrt-hook-ccpp.c
|
|
|
baab13 |
index b5f00f6..d95228f 100644
|
|
|
baab13 |
--- a/src/hooks/abrt-hook-ccpp.c
|
|
|
baab13 |
+++ b/src/hooks/abrt-hook-ccpp.c
|
|
|
baab13 |
@@ -626,6 +626,18 @@ finito:
|
|
|
baab13 |
return err;
|
|
|
baab13 |
}
|
|
|
baab13 |
|
|
|
baab13 |
+static int test_configuration(bool setting_SaveFullCore, bool setting_CreateCoreBacktrace)
|
|
|
baab13 |
+{
|
|
|
baab13 |
+ if (!setting_SaveFullCore && !setting_CreateCoreBacktrace)
|
|
|
baab13 |
+ {
|
|
|
baab13 |
+ fprintf(stderr, "Both SaveFullCore and CreateCoreBacktrace are disabled - "
|
|
|
baab13 |
+ "at least one of them is needed for useful report.\n");
|
|
|
baab13 |
+ return 1;
|
|
|
baab13 |
+ }
|
|
|
baab13 |
+
|
|
|
baab13 |
+ return 0;
|
|
|
baab13 |
+}
|
|
|
baab13 |
+
|
|
|
baab13 |
int main(int argc, char** argv)
|
|
|
baab13 |
{
|
|
|
baab13 |
int err = 1;
|
|
|
baab13 |
@@ -636,31 +648,9 @@ int main(int argc, char** argv)
|
|
|
baab13 |
*/
|
|
|
baab13 |
int fd = xopen("/dev/null", O_RDWR);
|
|
|
baab13 |
while (fd < 2)
|
|
|
baab13 |
- fd = xdup(fd);
|
|
|
baab13 |
+ fd = xdup(fd);
|
|
|
baab13 |
if (fd > 2)
|
|
|
baab13 |
- close(fd);
|
|
|
baab13 |
-
|
|
|
baab13 |
- if (argc < 8)
|
|
|
baab13 |
- {
|
|
|
baab13 |
- /* percent specifier: %s %c %p %u %g %t %e %i */
|
|
|
baab13 |
- /* argv: [0] [1] [2] [3] [4] [5] [6] [7] [8]*/
|
|
|
baab13 |
- error_msg_and_die("Usage: %s SIGNO CORE_SIZE_LIMIT PID UID GID TIME BINARY_NAME [TID]", argv[0]);
|
|
|
baab13 |
- }
|
|
|
baab13 |
-
|
|
|
baab13 |
- /* Not needed on 2.6.30.
|
|
|
baab13 |
- * At least 2.6.18 has a bug where
|
|
|
baab13 |
- * argv[1] = "SIGNO CORE_SIZE_LIMIT PID ..."
|
|
|
baab13 |
- * argv[2] = "CORE_SIZE_LIMIT PID ..."
|
|
|
baab13 |
- * and so on. Fixing it:
|
|
|
baab13 |
- */
|
|
|
baab13 |
- if (strchr(argv[1], ' '))
|
|
|
baab13 |
- {
|
|
|
baab13 |
- int i;
|
|
|
baab13 |
- for (i = 1; argv[i]; i++)
|
|
|
baab13 |
- {
|
|
|
baab13 |
- strchrnul(argv[i], ' ')[0] = '\0';
|
|
|
baab13 |
- }
|
|
|
baab13 |
- }
|
|
|
baab13 |
+ close(fd);
|
|
|
baab13 |
|
|
|
baab13 |
logmode = LOGMODE_JOURNAL;
|
|
|
baab13 |
|
|
|
baab13 |
@@ -689,6 +679,31 @@ int main(int argc, char** argv)
|
|
|
baab13 |
free_map_string(settings);
|
|
|
baab13 |
}
|
|
|
baab13 |
|
|
|
baab13 |
+ if (argc == 2 && strcmp(argv[1], "--config-test"))
|
|
|
baab13 |
+ return test_configuration(setting_SaveFullCore, setting_CreateCoreBacktrace);
|
|
|
baab13 |
+
|
|
|
baab13 |
+ if (argc < 8)
|
|
|
baab13 |
+ {
|
|
|
baab13 |
+ /* percent specifier: %s %c %p %u %g %t %e %i */
|
|
|
baab13 |
+ /* argv: [0] [1] [2] [3] [4] [5] [6] [7] [8]*/
|
|
|
baab13 |
+ error_msg_and_die("Usage: %s SIGNO CORE_SIZE_LIMIT PID UID GID TIME BINARY_NAME [TID]", argv[0]);
|
|
|
baab13 |
+ }
|
|
|
baab13 |
+
|
|
|
baab13 |
+ /* Not needed on 2.6.30.
|
|
|
baab13 |
+ * At least 2.6.18 has a bug where
|
|
|
baab13 |
+ * argv[1] = "SIGNO CORE_SIZE_LIMIT PID ..."
|
|
|
baab13 |
+ * argv[2] = "CORE_SIZE_LIMIT PID ..."
|
|
|
baab13 |
+ * and so on. Fixing it:
|
|
|
baab13 |
+ */
|
|
|
baab13 |
+ if (strchr(argv[1], ' '))
|
|
|
baab13 |
+ {
|
|
|
baab13 |
+ int i;
|
|
|
baab13 |
+ for (i = 1; argv[i]; i++)
|
|
|
baab13 |
+ {
|
|
|
baab13 |
+ strchrnul(argv[i], ' ')[0] = '\0';
|
|
|
baab13 |
+ }
|
|
|
baab13 |
+ }
|
|
|
baab13 |
+
|
|
|
baab13 |
errno = 0;
|
|
|
baab13 |
const char* signal_str = argv[1];
|
|
|
baab13 |
int signal_no = xatoi_positive(signal_str);
|
|
|
baab13 |
diff --git a/src/hooks/abrt-install-ccpp-hook.in b/src/hooks/abrt-install-ccpp-hook.in
|
|
|
baab13 |
index d4ed4a5..fff0a33 100755
|
|
|
baab13 |
--- a/src/hooks/abrt-install-ccpp-hook.in
|
|
|
baab13 |
+++ b/src/hooks/abrt-install-ccpp-hook.in
|
|
|
baab13 |
@@ -31,6 +31,11 @@ CORE_PIPE_LIMIT_FILE="/proc/sys/kernel/core_pipe_limit"
|
|
|
baab13 |
CORE_PIPE_LIMIT="4"
|
|
|
baab13 |
|
|
|
baab13 |
start() {
|
|
|
baab13 |
+ if ! $HOOK_BIN --test-config; then
|
|
|
baab13 |
+ echo "Invalid configuration."
|
|
|
baab13 |
+ exit 1
|
|
|
baab13 |
+ fi
|
|
|
baab13 |
+
|
|
|
baab13 |
cur=`cat "$PATTERN_FILE"`
|
|
|
baab13 |
cur_first=`printf "%s" "$cur" | sed 's/ .*//'`
|
|
|
baab13 |
|
|
|
baab13 |
--
|
|
|
baab13 |
2.4.3
|
|
|
baab13 |
|