summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-07-22 18:37:42 +0200
committerGitHub <noreply@github.com>2016-07-22 18:37:42 +0200
commitc907cba919a1e9840859296f192f3a55345ff29c (patch)
tree654a4153613d59324fd2cb6180cbb680ee5f4c80
parent5052c4eadd31715ed21e091dec0dce5f4f3d7baa (diff)
parent5157879b757bffce3da0a68ca207753569e8627d (diff)
Merge pull request #3783 from poettering/fix-3285
coredump: make sure to handle crashes of PID 1 and journald special
-rw-r--r--src/coredump/coredump.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c
index 998b047c29..e5719e67c3 100644
--- a/src/coredump/coredump.c
+++ b/src/coredump/coredump.c
@@ -756,7 +756,6 @@ static int process_socket(int fd) {
iovec[n_iovec].iov_len = l;
iovec[n_iovec].iov_base = malloc(l + 1);
-
if (!iovec[n_iovec].iov_base) {
r = log_oom();
goto finish;
@@ -897,7 +896,7 @@ static int send_iovec(const struct iovec iovec[], size_t n_iovec, int input_fd)
return 0;
}
-static int process_journald_crash(const char *context[], int input_fd) {
+static int process_special_crash(const char *context[], int input_fd) {
_cleanup_close_ int coredump_fd = -1, coredump_node_fd = -1;
_cleanup_free_ char *filename = NULL;
uint64_t coredump_size;
@@ -906,7 +905,7 @@ static int process_journald_crash(const char *context[], int input_fd) {
assert(context);
assert(input_fd >= 0);
- /* If we are journald, we cut things short, don't write to the journal, but still create a coredump. */
+ /* If we are pid1 or journald, we cut things short, don't write to the journal, but still create a coredump. */
if (arg_storage != COREDUMP_STORAGE_NONE)
arg_storage = COREDUMP_STORAGE_EXTERNAL;
@@ -919,7 +918,11 @@ static int process_journald_crash(const char *context[], int input_fd) {
if (r < 0)
return r;
- log_info("Detected coredump of the journal daemon itself, diverted to %s.", filename);
+ log_notice("Detected coredump of the journal daemon or PID 1, diverted to %s.", filename);
+
+ log_notice("Due to the special circumstances, coredump collection will now be turned off.");
+ (void) write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", 0);
+
return 0;
}
@@ -979,9 +982,11 @@ static int process_kernel(int argc, char* argv[]) {
if (cg_pid_get_unit(pid, &t) >= 0) {
- if (streq(t, SPECIAL_JOURNALD_SERVICE)) {
+ /* Let's avoid dead-locks when processing journald and init crashes, as socket activation and logging
+ * are unlikely to work then. */
+ if (STR_IN_SET(t, SPECIAL_JOURNALD_SERVICE, SPECIAL_INIT_SCOPE)) {
free(t);
- return process_journald_crash(context, STDIN_FILENO);
+ return process_special_crash(context, STDIN_FILENO);
}
core_unit = strjoina("COREDUMP_UNIT=", t);