X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fjournal%2Fcoredump.c;h=a507fc65f8ae24eb56daa7bf69030835c6238cc3;hb=2fb7a5ce67fd6196416919535fa6a6065e0ea815;hp=db805d6cb57dfe9f77d6c17cfc7cbe07a7a6f547;hpb=5430f7f2bc7330f3088b894166bf3524a067e3d8;p=elogind.git diff --git a/src/journal/coredump.c b/src/journal/coredump.c index db805d6cb..a507fc65f 100644 --- a/src/journal/coredump.c +++ b/src/journal/coredump.c @@ -25,12 +25,16 @@ #include #include + +#ifdef HAVE_LOGIND #include +#endif #include "log.h" #include "util.h" #include "mkdir.h" #include "special.h" +#include "cgroup-util.h" #define COREDUMP_MAX (24*1024*1024) @@ -50,7 +54,7 @@ static int divert_coredump(void) { log_info("Detected coredump of the journal daemon itself, diverting coredump to /var/lib/systemd/coredump/."); - mkdir_p("/var/lib/systemd/coredump", 0755); + mkdir_p_label("/var/lib/systemd/coredump", 0755); f = fopen("/var/lib/systemd/coredump/core.systemd-journald", "we"); if (!f) { @@ -126,7 +130,7 @@ int main(int argc, char* argv[]) { goto finish; } - if (sd_pid_get_unit(pid, &t) >= 0) { + if (cg_pid_get_unit(pid, &t) >= 0) { if (streq(t, SPECIAL_JOURNALD_SERVICE)) { /* Make sure we don't make use of the journal, @@ -182,6 +186,7 @@ int main(int argc, char* argv[]) { if (core_comm) IOVEC_SET_STRING(iovec[j++], core_comm); +#ifdef HAVE_LOGIND if (sd_pid_get_session(pid, &t) >= 0) { core_session = strappend("COREDUMP_SESSION=", t); free(t); @@ -190,6 +195,8 @@ int main(int argc, char* argv[]) { IOVEC_SET_STRING(iovec[j++], core_session); } +#endif + if (get_process_exe(pid, &t) >= 0) { core_exe = strappend("COREDUMP_EXE=", t); free(t); @@ -206,14 +213,14 @@ int main(int argc, char* argv[]) { IOVEC_SET_STRING(iovec[j++], core_cmdline); } - core_timestamp = join("COREDUMP_TIMESTAMP=", argv[ARG_TIMESTAMP], "000000", NULL); + core_timestamp = strjoin("COREDUMP_TIMESTAMP=", argv[ARG_TIMESTAMP], "000000", NULL); if (core_timestamp) IOVEC_SET_STRING(iovec[j++], core_timestamp); IOVEC_SET_STRING(iovec[j++], "MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1"); IOVEC_SET_STRING(iovec[j++], "PRIORITY=2"); - core_message = join("MESSAGE=Process ", argv[ARG_PID], " (", argv[ARG_COMM], ") dumped core.", NULL); + core_message = strjoin("MESSAGE=Process ", argv[ARG_PID], " (", argv[ARG_COMM], ") dumped core.", NULL); if (core_message) IOVEC_SET_STRING(iovec[j++], core_message); @@ -232,8 +239,7 @@ int main(int argc, char* argv[]) { p = malloc(9 + COREDUMP_MAX); if (!p) { - log_error("Out of memory"); - r = -ENOMEM; + r = log_oom(); goto finish; }