diff options
Diffstat (limited to 'src/coredump')
-rw-r--r-- | src/coredump/coredump-vacuum.c | 21 | ||||
-rw-r--r-- | src/coredump/coredump-vacuum.h | 19 | ||||
-rw-r--r-- | src/coredump/coredump.c | 74 | ||||
-rw-r--r-- | src/coredump/coredumpctl.c | 288 | ||||
-rw-r--r-- | src/coredump/meson.build | 15 | ||||
-rw-r--r-- | src/coredump/stacktrace.c | 21 | ||||
-rw-r--r-- | src/coredump/stacktrace.h | 19 | ||||
-rw-r--r-- | src/coredump/test-coredump-vacuum.c | 18 |
8 files changed, 168 insertions, 307 deletions
diff --git a/src/coredump/coredump-vacuum.c b/src/coredump/coredump-vacuum.c index e27512167c..6ce5dfc71d 100644 --- a/src/coredump/coredump-vacuum.c +++ b/src/coredump/coredump-vacuum.c @@ -1,22 +1,4 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ -/*** - This file is part of systemd. - - Copyright 2014 Lennart Poettering - - systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 of the License, or - (at your option) any later version. - - systemd is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with systemd; If not, see <http://www.gnu.org/licenses/>. -***/ #include <sys/statvfs.h> @@ -227,8 +209,7 @@ int coredump_vacuum(int exclude_fd, uint64_t keep_free, uint64_t max_use) { if (r < 0) return log_oom(); - c = n; - n = NULL; + c = TAKE_PTR(n); } c->n_files++; diff --git a/src/coredump/coredump-vacuum.h b/src/coredump/coredump-vacuum.h index c61d08f79c..0db116736c 100644 --- a/src/coredump/coredump-vacuum.h +++ b/src/coredump/coredump-vacuum.h @@ -1,25 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ #pragma once -/*** - This file is part of systemd. - - Copyright 2014 Lennart Poettering - - systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 of the License, or - (at your option) any later version. - - systemd is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with systemd; If not, see <http://www.gnu.org/licenses/>. -***/ - #include <inttypes.h> #include <sys/types.h> diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c index e924750d1b..20a1cbdd45 100644 --- a/src/coredump/coredump.c +++ b/src/coredump/coredump.c @@ -1,22 +1,4 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ -/*** - This file is part of systemd. - - Copyright 2012 Lennart Poettering - - systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 of the License, or - (at your option) any later version. - - systemd is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with systemd; If not, see <http://www.gnu.org/licenses/>. -***/ #include <errno.h> #include <stdio.h> @@ -154,7 +136,12 @@ static int parse_config(void) { } static inline uint64_t storage_size_max(void) { - return arg_storage == COREDUMP_STORAGE_EXTERNAL ? arg_external_size_max : arg_journal_size_max; + if (arg_storage == COREDUMP_STORAGE_EXTERNAL) + return arg_external_size_max; + if (arg_storage == COREDUMP_STORAGE_JOURNAL) + return arg_journal_size_max; + assert(arg_storage == COREDUMP_STORAGE_NONE); + return 0; } static int fix_acl(int fd, uid_t uid) { @@ -336,7 +323,7 @@ static int save_external_coredump( _cleanup_free_ char *fn = NULL, *tmp = NULL; _cleanup_close_ int fd = -1; - uint64_t rlimit, max_size; + uint64_t rlimit, process_limit, max_size; struct stat st; uid_t uid; int r; @@ -363,8 +350,14 @@ static int save_external_coredump( return -EBADSLT; } + process_limit = MAX(arg_process_size_max, storage_size_max()); + if (process_limit == 0) { + log_debug("Limits for coredump processing and storage are both 0, not dumping core."); + return -EBADSLT; + } + /* Never store more than the process configured, or than we actually shall keep or process */ - max_size = MIN(rlimit, MAX(arg_process_size_max, storage_size_max())); + max_size = MIN(rlimit, process_limit); r = make_filename(context, &fn); if (r < 0) @@ -386,8 +379,7 @@ static int save_external_coredump( log_struct(LOG_INFO, LOG_MESSAGE("Core file was truncated to %zu bytes.", max_size), "SIZE_LIMIT=%zu", max_size, - "MESSAGE_ID=" SD_MESSAGE_TRUNCATED_CORE_STR, - NULL); + "MESSAGE_ID=" SD_MESSAGE_TRUNCATED_CORE_STR); if (fstat(fd, &st) < 0) { log_error_errno(errno, "Failed to fstat core file %s: %m", coredump_tmpfile_name(tmp)); @@ -432,14 +424,11 @@ static int save_external_coredump( if (tmp) unlink_noerrno(tmp); - *ret_filename = fn_compressed; /* compressed */ - *ret_node_fd = fd_compressed; /* compressed */ - *ret_data_fd = fd; /* uncompressed */ + *ret_filename = TAKE_PTR(fn_compressed); /* compressed */ + *ret_node_fd = TAKE_FD(fd_compressed); /* compressed */ + *ret_data_fd = TAKE_FD(fd); /* uncompressed */ *ret_size = (uint64_t) st.st_size; /* uncompressed */ - fn_compressed = NULL; - fd = fd_compressed = -1; - return 0; fail_compressed: @@ -454,14 +443,11 @@ uncompressed: if (r < 0) goto fail; - *ret_filename = fn; - *ret_data_fd = fd; + *ret_filename = TAKE_PTR(fn); + *ret_data_fd = TAKE_FD(fd); *ret_node_fd = -1; *ret_size = (uint64_t) st.st_size; - fn = NULL; - fd = -1; - return 0; fail: @@ -497,11 +483,9 @@ static int allocate_journal_field(int fd, size_t size, char **ret, size_t *ret_s return -EIO; } - *ret = field; + *ret = TAKE_PTR(field); *ret_size = size + 9; - field = NULL; - return 0; } @@ -584,8 +568,7 @@ static int compose_open_fds(pid_t pid, char **open_fds) { if (errno > 0) return -errno; - *open_fds = buffer; - buffer = NULL; + *open_fds = TAKE_PTR(buffer); return 0; } @@ -863,21 +846,18 @@ static void map_context_fields(const struct iovec *iovec, const char* context[]) assert(context); for (i = 0; i < ELEMENTSOF(context_field_names); i++) { - size_t l; + char *p; if (!context_field_names[i]) continue; - l = strlen(context_field_names[i]); - if (iovec->iov_len < l) - continue; - - if (memcmp(iovec->iov_base, context_field_names[i], l) != 0) + p = memory_startswith(iovec->iov_base, iovec->iov_len, context_field_names[i]); + if (!p) continue; /* Note that these strings are NUL terminated, because we made sure that a trailing NUL byte is in the * buffer, though not included in the iov_len count. (see below) */ - context[i] = (char*) iovec->iov_base + l; + context[i] = p; break; } } @@ -932,7 +912,7 @@ static int process_socket(int fd) { mh.msg_iov = iovec + n_iovec; - n = recvmsg(fd, &mh, MSG_NOSIGNAL|MSG_CMSG_CLOEXEC); + n = recvmsg(fd, &mh, MSG_CMSG_CLOEXEC); if (n < 0) { free(iovec[n_iovec].iov_base); r = log_error_errno(errno, "Failed to receive datagram: %m"); diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c index a4cc9c1db3..99d07c14fb 100644 --- a/src/coredump/coredumpctl.c +++ b/src/coredump/coredumpctl.c @@ -1,22 +1,4 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ -/*** - This file is part of systemd. - - Copyright 2012 Zbigniew Jędrzejewski-Szmek - - systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 of the License, or - (at your option) any later version. - - systemd is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with systemd; If not, see <http://www.gnu.org/licenses/>. -***/ #include <fcntl.h> #include <getopt.h> @@ -51,32 +33,24 @@ #include "terminal-util.h" #include "user-util.h" #include "util.h" +#include "verbs.h" #define SHORT_BUS_CALL_TIMEOUT_USEC (3 * USEC_PER_SEC) static usec_t arg_since = USEC_INFINITY, arg_until = USEC_INFINITY; - -static enum { - ACTION_NONE, - ACTION_INFO, - ACTION_LIST, - ACTION_DUMP, - ACTION_GDB, -} arg_action = ACTION_LIST; static const char* arg_field = NULL; +static const char *arg_debugger = NULL; static const char *arg_directory = NULL; static bool arg_no_pager = false; static int arg_no_legend = false; static int arg_one = false; static FILE* arg_output = NULL; static bool arg_reverse = false; -static char** arg_matches = NULL; static bool arg_quiet = false; static int add_match(sd_journal *j, const char *match) { _cleanup_free_ char *p = NULL; - char *pattern = NULL; - const char* prefix; + const char* prefix, *pattern; pid_t pid; int r; @@ -99,10 +73,11 @@ static int add_match(sd_journal *j, const char *match) { r = sd_journal_add_match(j, pattern, 0); if (r < 0) return log_error_errno(r, "Failed to add match \"%s\": %m", match); + return 0; } -static int add_matches(sd_journal *j) { +static int add_matches(sd_journal *j, char **matches) { char **match; int r; @@ -114,7 +89,7 @@ static int add_matches(sd_journal *j) { if (r < 0) return log_error_errno(r, "Failed to add match \"%s\": %m", "MESSAGE_ID=" SD_MESSAGE_BACKTRACE_STR); - STRV_FOREACH(match, arg_matches) { + STRV_FOREACH(match, matches) { r = add_match(j, *match); if (r < 0) return r; @@ -123,28 +98,67 @@ static int add_matches(sd_journal *j) { return 0; } -static void help(void) { +static int acquire_journal(sd_journal **ret, char **matches) { + _cleanup_(sd_journal_closep) sd_journal *j = NULL; + int r; + + assert(ret); + + if (arg_directory) { + r = sd_journal_open_directory(&j, arg_directory, 0); + if (r < 0) + return log_error_errno(r, "Failed to open journals in directory: %s: %m", arg_directory); + } else { + r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY); + if (r < 0) + return log_error_errno(r, "Failed to open journal: %m"); + } + + r = journal_access_check_and_warn(j, arg_quiet, true); + if (r < 0) + return r; + + r = add_matches(j, matches); + if (r < 0) + return r; + + if (DEBUG_LOGGING) { + _cleanup_free_ char *filter; + + filter = journal_make_match_string(j); + log_debug("Journal filter: %s", filter); + } + + *ret = TAKE_PTR(j); + + return 0; +} + +static int help(void) { printf("%s [OPTIONS...]\n\n" "List or retrieve coredumps from the journal.\n\n" "Flags:\n" - " -h --help Show this help\n" - " --version Print version string\n" - " --no-pager Do not pipe output into a pager\n" - " --no-legend Do not print the column headers.\n" - " -1 Show information about most recent entry only\n" - " -S --since=DATE Only print coredumps since the date\n" - " -U --until=DATE Only print coredumps until the date\n" - " -r --reverse Show the newest entries first\n" - " -F --field=FIELD List all values a certain field takes\n" - " -o --output=FILE Write output to FILE\n" - " -D --directory=DIR Use journal files from directory\n\n" - " -q --quiet Do not show info messages and privilege warning\n" + " -h --help Show this help\n" + " --version Print version string\n" + " --no-pager Do not pipe output into a pager\n" + " --no-legend Do not print the column headers\n" + " --debugger=DEBUGGER Use the given debugger\n" + " -1 Show information about most recent entry only\n" + " -S --since=DATE Only print coredumps since the date\n" + " -U --until=DATE Only print coredumps until the date\n" + " -r --reverse Show the newest entries first\n" + " -F --field=FIELD List all values a certain field takes\n" + " -o --output=FILE Write output to FILE\n" + " -D --directory=DIR Use journal files from directory\n\n" + " -q --quiet Do not show info messages and privilege warning\n" "Commands:\n" " list [MATCHES...] List available coredumps (default)\n" " info [MATCHES...] Show detailed information about one or more coredumps\n" " dump [MATCHES...] Print first matching coredump to stdout\n" - " gdb [MATCHES...] Start gdb for the first matching coredump\n" + " debug [MATCHES...] Start a debugger for the first matching coredump\n" , program_invocation_short_name); + + return 0; } static int parse_argv(int argc, char *argv[]) { @@ -152,6 +166,7 @@ static int parse_argv(int argc, char *argv[]) { ARG_VERSION = 0x100, ARG_NO_PAGER, ARG_NO_LEGEND, + ARG_DEBUGGER, }; int c, r; @@ -161,6 +176,7 @@ static int parse_argv(int argc, char *argv[]) { { "version" , no_argument, NULL, ARG_VERSION }, { "no-pager", no_argument, NULL, ARG_NO_PAGER }, { "no-legend", no_argument, NULL, ARG_NO_LEGEND }, + { "debugger", required_argument, NULL, ARG_DEBUGGER }, { "output", required_argument, NULL, 'o' }, { "field", required_argument, NULL, 'F' }, { "directory", required_argument, NULL, 'D' }, @@ -177,12 +193,9 @@ static int parse_argv(int argc, char *argv[]) { while ((c = getopt_long(argc, argv, "ho:F:1D:rS:U:q", options, NULL)) >= 0) switch(c) { case 'h': - arg_action = ACTION_NONE; - help(); - return 0; + return help(); case ARG_VERSION: - arg_action = ACTION_NONE; return version(); case ARG_NO_PAGER: @@ -193,9 +206,13 @@ static int parse_argv(int argc, char *argv[]) { arg_no_legend = true; break; + case ARG_DEBUGGER: + arg_debugger = optarg; + break; + case 'o': if (arg_output) { - log_error("cannot set output more than once"); + log_error("Cannot set output more than once."); return -EINVAL; } @@ -219,7 +236,7 @@ static int parse_argv(int argc, char *argv[]) { case 'F': if (arg_field) { - log_error("cannot use --field/-F more than once"); + log_error("Cannot use --field/-F more than once."); return -EINVAL; } arg_field = optarg; @@ -254,31 +271,7 @@ static int parse_argv(int argc, char *argv[]) { return -EINVAL; } - if (optind < argc) { - const char *cmd = argv[optind++]; - if (streq(cmd, "list")) - arg_action = ACTION_LIST; - else if (streq(cmd, "dump")) - arg_action = ACTION_DUMP; - else if (streq(cmd, "gdb")) - arg_action = ACTION_GDB; - else if (streq(cmd, "info")) - arg_action = ACTION_INFO; - else { - log_error("Unknown action '%s'", cmd); - return -EINVAL; - } - } - - if (arg_field && arg_action != ACTION_LIST) { - log_error("Option --field/-F only makes sense with list"); - return -EINVAL; - } - - if (optind < argc) - arg_matches = argv + optind; - - return 0; + return 1; } static int retrieve(const void *data, @@ -631,10 +624,10 @@ static int focus(sd_journal *j) { return r; } -static int print_entry(sd_journal *j, unsigned n_found) { +static int print_entry(sd_journal *j, unsigned n_found, bool verb_is_info) { assert(j); - if (arg_action == ACTION_INFO) + if (verb_is_info) return print_info(stdout, j, n_found); else if (arg_field) return print_field(stdout, j); @@ -642,11 +635,19 @@ static int print_entry(sd_journal *j, unsigned n_found) { return print_list(stdout, j, n_found); } -static int dump_list(sd_journal *j) { +static int dump_list(int argc, char **argv, void *userdata) { + _cleanup_(sd_journal_closep) sd_journal *j = NULL; unsigned n_found = 0; + bool verb_is_info; int r; - assert(j); + verb_is_info = (argc >= 1 && streq(argv[0], "info")); + + r = acquire_journal(&j, argv + 1); + if (r < 0) + return r; + + (void) pager_open(arg_no_pager, false); /* The coredumps are likely to compressed, and for just * listing them we don't need to decompress them, so let's @@ -658,7 +659,7 @@ static int dump_list(sd_journal *j) { if (r < 0) return r; - return print_entry(j, 0); + return print_entry(j, 0, verb_is_info); } else { if (arg_since != USEC_INFINITY && !arg_reverse) r = sd_journal_seek_realtime_usec(j, arg_since); @@ -703,7 +704,7 @@ static int dump_list(sd_journal *j) { continue; } - r = print_entry(j, n_found++); + r = print_entry(j, n_found++, verb_is_info); if (r < 0) return r; } @@ -752,8 +753,7 @@ static int save_core(sd_journal *j, FILE *file, char **path, bool *unlink_temp) return log_error_errno(errno, "File \"%s\" is not readable: %m", filename); if (path && !endswith(filename, ".xz") && !endswith(filename, ".lz4")) { - *path = filename; - filename = NULL; + *path = TAKE_PTR(filename); return 0; } @@ -856,10 +856,18 @@ error: return r; } -static int dump_core(sd_journal* j) { +static int dump_core(int argc, char **argv, void *userdata) { + _cleanup_(sd_journal_closep) sd_journal *j = NULL; int r; - assert(j); + if (arg_field) { + log_error("Option --field/-F only makes sense with list"); + return -EINVAL; + } + + r = acquire_journal(&j, argv + 1); + if (r < 0) + return r; r = focus(j); if (r < 0) @@ -878,15 +886,33 @@ static int dump_core(sd_journal* j) { return 0; } -static int run_gdb(sd_journal *j) { +static int run_debug(int argc, char **argv, void *userdata) { + _cleanup_(sd_journal_closep) sd_journal *j = NULL; _cleanup_free_ char *exe = NULL, *path = NULL; bool unlink_path = false; - const char *data; + const char *data, *fork_name; size_t len; pid_t pid; int r; - assert(j); + if (!arg_debugger) { + char *env_debugger; + + env_debugger = getenv("SYSTEMD_DEBUGGER"); + if (env_debugger) + arg_debugger = env_debugger; + else + arg_debugger = "gdb"; + } + + if (arg_field) { + log_error("Option --field/-F only makes sense with list"); + return -EINVAL; + } + + r = acquire_journal(&j, argv + 1); + if (r < 0) + return r; r = focus(j); if (r < 0) @@ -924,17 +950,19 @@ static int run_gdb(sd_journal *j) { /* Don't interfere with gdb and its handling of SIGINT. */ (void) ignore_signals(SIGINT, -1); - r = safe_fork("(gdb)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_CLOSE_ALL_FDS|FORK_LOG, &pid); + fork_name = strjoina("(", arg_debugger, ")"); + + r = safe_fork(fork_name, FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_CLOSE_ALL_FDS|FORK_LOG, &pid); if (r < 0) goto finish; if (r == 0) { - execlp("gdb", "gdb", exe, path, NULL); + execlp(arg_debugger, arg_debugger, exe, "-c", path, NULL); log_open(); - log_error_errno(errno, "Failed to invoke gdb: %m"); + log_error_errno(errno, "Failed to invoke %s: %m", arg_debugger); _exit(EXIT_FAILURE); } - r = wait_for_terminate_and_check("gdb", pid, WAIT_LOG_ABNORMAL); + r = wait_for_terminate_and_check(arg_debugger, pid, WAIT_LOG_ABNORMAL); finish: (void) default_signals(SIGINT, -1); @@ -1007,73 +1035,36 @@ static int check_units_active(void) { return c; } +static int coredumpctl_main(int argc, char *argv[]) { + + static const Verb verbs[] = { + { "list", VERB_ANY, VERB_ANY, VERB_DEFAULT, dump_list }, + { "info", VERB_ANY, VERB_ANY, 0, dump_list }, + { "dump", VERB_ANY, VERB_ANY, 0, dump_core }, + { "debug", VERB_ANY, VERB_ANY, 0, run_debug }, + { "gdb", VERB_ANY, VERB_ANY, 0, run_debug }, + {} + }; + + return dispatch_verb(argc, argv, verbs, NULL); +} + int main(int argc, char *argv[]) { - _cleanup_(sd_journal_closep) sd_journal*j = NULL; - int r = 0, units_active; + int r, units_active; setlocale(LC_ALL, ""); log_parse_environment(); log_open(); r = parse_argv(argc, argv); - if (r < 0) - goto end; - - if (arg_action == ACTION_NONE) + if (r <= 0) goto end; sigbus_install(); - if (arg_directory) { - r = sd_journal_open_directory(&j, arg_directory, 0); - if (r < 0) { - log_error_errno(r, "Failed to open journals in directory: %s: %m", arg_directory); - goto end; - } - } else { - r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY); - if (r < 0) { - log_error_errno(r, "Failed to open journal: %m"); - goto end; - } - } - - r = journal_access_check_and_warn(j, arg_quiet, true); - if (r < 0) - goto end; - - r = add_matches(j); - if (r < 0) - goto end; - - if (DEBUG_LOGGING) { - _cleanup_free_ char *filter; - - filter = journal_make_match_string(j); - log_debug("Journal filter: %s", filter); - } - units_active = check_units_active(); /* error is treated the same as 0 */ - switch(arg_action) { - - case ACTION_LIST: - case ACTION_INFO: - pager_open(arg_no_pager, false); - r = dump_list(j); - break; - - case ACTION_DUMP: - r = dump_core(j); - break; - - case ACTION_GDB: - r = run_gdb(j); - break; - - default: - assert_not_reached("Shouldn't be here"); - } + r = coredumpctl_main(argc, argv); if (units_active > 0) printf("%s-- Notice: %d systemd-coredump@.service %s, output may be incomplete.%s\n", @@ -1083,8 +1074,7 @@ int main(int argc, char *argv[]) { end: pager_close(); - if (arg_output) - fclose(arg_output); + safe_fclose(arg_output); return r >= 0 ? r : EXIT_FAILURE; } diff --git a/src/coredump/meson.build b/src/coredump/meson.build index 4e31e7c7c2..bfba7ef58c 100644 --- a/src/coredump/meson.build +++ b/src/coredump/meson.build @@ -1,19 +1,4 @@ # SPDX-License-Identifier: LGPL-2.1+ -# -# Copyright 2017 Zbigniew Jędrzejewski-Szmek -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; either version 2.1 of the License, or -# (at your option) any later version. -# -# systemd is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with systemd; If not, see <http://www.gnu.org/licenses/>. systemd_coredump_sources = files(''' coredump.c diff --git a/src/coredump/stacktrace.c b/src/coredump/stacktrace.c index 95fd27b79a..dab4c1ad9b 100644 --- a/src/coredump/stacktrace.c +++ b/src/coredump/stacktrace.c @@ -1,22 +1,4 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ -/*** - This file is part of systemd. - - Copyright 2014 Lennart Poettering - - systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 of the License, or - (at your option) any later version. - - systemd is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with systemd; If not, see <http://www.gnu.org/licenses/>. -***/ #include <dwarf.h> #include <elfutils/libdwfl.h> @@ -184,8 +166,7 @@ int coredump_make_stack_trace(int fd, const char *executable, char **ret) { c.f = safe_fclose(c.f); - *ret = buf; - buf = NULL; + *ret = TAKE_PTR(buf); r = 0; diff --git a/src/coredump/stacktrace.h b/src/coredump/stacktrace.h index d435878b44..52900424a7 100644 --- a/src/coredump/stacktrace.h +++ b/src/coredump/stacktrace.h @@ -1,23 +1,4 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ #pragma once -/*** - This file is part of systemd. - - Copyright 2014 Lennart Poettering - - systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 of the License, or - (at your option) any later version. - - systemd is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with systemd; If not, see <http://www.gnu.org/licenses/>. -***/ - int coredump_make_stack_trace(int fd, const char *executable, char **ret); diff --git a/src/coredump/test-coredump-vacuum.c b/src/coredump/test-coredump-vacuum.c index 0836825b07..75fb442873 100644 --- a/src/coredump/test-coredump-vacuum.c +++ b/src/coredump/test-coredump-vacuum.c @@ -1,22 +1,4 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ -/*** - This file is part of systemd. - - Copyright 2012 Zbigniew Jędrzejewski-Szmek - - systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 of the License, or - (at your option) any later version. - - systemd is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with systemd; If not, see <http://www.gnu.org/licenses/>. -***/ #include <stdlib.h> |