From 276f03b8c191348cd3dbf0ccc24273b328621eb1 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 3 Jul 2017 18:58:42 +0100 Subject: [PATCH 2/7] internals: Add a log severity that looks like FATAL, but does not _exit() This lets _dbus_warn() and _dbus_warn_check_failed() fall through to flushing stderr and calling _dbus_abort(), meaning that failed checks and warnings can result in a core dump as intended. Signed-off-by: Simon McVittie --- dbus/dbus-internals.c | 4 ++-- dbus/dbus-sysdeps-unix.c | 1 + dbus/dbus-sysdeps-win.c | 1 + dbus/dbus-sysdeps.h | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index bc3454d5..3508b7e6 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -237,7 +237,7 @@ _dbus_warn (const char *format, init_warnings (); if (fatal_warnings) - severity = DBUS_SYSTEM_LOG_FATAL; + severity = DBUS_SYSTEM_LOG_GOING_TO_BE_FATAL; va_start (args, format); _dbus_logv (severity, format, args); @@ -269,7 +269,7 @@ _dbus_warn_check_failed(const char *format, init_warnings (); if (fatal_warnings_on_check_failed) - severity = DBUS_SYSTEM_LOG_FATAL; + severity = DBUS_SYSTEM_LOG_GOING_TO_BE_FATAL; va_start (args, format); _dbus_logv (severity, format, args); diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 92217e35..d92a80af 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -4639,6 +4639,7 @@ _dbus_logv (DBusSystemLogSeverity severity, case DBUS_SYSTEM_LOG_SECURITY: flags = LOG_AUTH | LOG_NOTICE; break; + case DBUS_SYSTEM_LOG_GOING_TO_BE_FATAL: case DBUS_SYSTEM_LOG_FATAL: flags = LOG_DAEMON|LOG_CRIT; break; diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 5a94eaf5..348f2e19 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -3719,6 +3719,7 @@ _dbus_logv (DBusSystemLogSeverity severity, case DBUS_SYSTEM_LOG_INFO: s = "info"; break; case DBUS_SYSTEM_LOG_WARNING: s = "warning"; break; case DBUS_SYSTEM_LOG_SECURITY: s = "security"; break; + case DBUS_SYSTEM_LOG_GOING_TO_BE_FATAL: /* fall through */ case DBUS_SYSTEM_LOG_FATAL: s = "fatal"; break; default: _dbus_assert_not_reached ("invalid log severity"); } diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index 281d719e..328f43f7 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -563,6 +563,7 @@ typedef enum { DBUS_SYSTEM_LOG_INFO, DBUS_SYSTEM_LOG_WARNING, DBUS_SYSTEM_LOG_SECURITY, + DBUS_SYSTEM_LOG_GOING_TO_BE_FATAL, DBUS_SYSTEM_LOG_FATAL } DBusSystemLogSeverity; -- 2.13.2