X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fjournal%2Fcoredump.c;h=88d720f6517c8c82e4b73cecfbe4771f570bf95d;hp=4ac1a41299af2e12292574c7c0b799f53df31580;hb=b26c631ac99ac7f4f5cfa5b9b933f0bb22cace97;hpb=874bc134ac6504c45e94174e37af13ff21a6bfe2 diff --git a/src/journal/coredump.c b/src/journal/coredump.c index 4ac1a4129..88d720f65 100644 --- a/src/journal/coredump.c +++ b/src/journal/coredump.c @@ -26,8 +26,13 @@ #include #include -#include -#include +#ifdef HAVE_ELFUTILS +# include +# include +#endif + +#include "systemd/sd-journal.h" +#include "systemd/sd-login.h" #include "log.h" #include "util.h" @@ -114,16 +119,10 @@ static int parse_config(void) { {} }; - return config_parse( - NULL, - "/etc/systemd/coredump.conf", - NULL, - "Coredump\0", - config_item_table_lookup, - items, - false, - false, - NULL); + return config_parse(NULL, "/etc/systemd/coredump.conf", NULL, + "Coredump\0", + config_item_table_lookup, items, + false, false, true, NULL); } static int fix_acl(int fd, uid_t uid) { @@ -597,9 +596,9 @@ int main(int argc, char* argv[]) { } if (sd_pid_get_owner_uid(pid, &owner_uid) >= 0) { - asprintf(&core_owner_uid, "COREDUMP_OWNER_UID=" UID_FMT, owner_uid); - - if (core_owner_uid) + r = asprintf(&core_owner_uid, + "COREDUMP_OWNER_UID=" UID_FMT, owner_uid); + if (r > 0) IOVEC_SET_STRING(iovec[j++], core_owner_uid); } @@ -674,9 +673,9 @@ int main(int argc, char* argv[]) { /* Now, let's drop privileges to become the user who owns the * segfaulted process and allocate the coredump memory under - * his uid. This also ensures that the credentials journald - * will see are the ones of the coredumping user, thus making - * sure the user himself gets access to the core dump. */ + * the user's uid. This also ensures that the credentials + * journald will see are the ones of the coredumping user, + * thus making sure the user gets access to the core dump. */ if (setresgid(gid, gid, gid) < 0 || setresuid(uid, uid, uid) < 0) { log_error("Failed to drop privileges: %m"); @@ -692,6 +691,8 @@ int main(int argc, char* argv[]) { r = coredump_make_stack_trace(coredump_fd, exe, &stacktrace); if (r >= 0) core_message = strjoin("MESSAGE=Process ", info[INFO_PID], " (", comm, ") of user ", info[INFO_UID], " dumped core.\n\n", stacktrace, NULL); + else if (r == -EINVAL) + log_warning("Failed to generate stack trace: %s", dwfl_errmsg(dwfl_errno())); else log_warning("Failed to generate stack trace: %s", strerror(-r)); }