diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:45 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:45 +0000 |
commit | efeb864cb547a2cbf96dc0053a8bdb4d9190b364 (patch) | |
tree | c0b83368f18be983fcc763200c4c24d633244588 /src/coredump/coredumpctl.c | |
parent | Releasing progress-linux version 255.5-1~progress7.99u1. (diff) | |
download | systemd-efeb864cb547a2cbf96dc0053a8bdb4d9190b364.tar.xz systemd-efeb864cb547a2cbf96dc0053a8bdb4d9190b364.zip |
Merging upstream version 256.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/coredump/coredumpctl.c')
-rw-r--r-- | src/coredump/coredumpctl.c | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c index 84d4531..3a3cd7d 100644 --- a/src/coredump/coredumpctl.c +++ b/src/coredump/coredumpctl.c @@ -67,34 +67,38 @@ static bool arg_all = false; static ImagePolicy *arg_image_policy = NULL; STATIC_DESTRUCTOR_REGISTER(arg_debugger_args, strv_freep); +STATIC_DESTRUCTOR_REGISTER(arg_root, freep); +STATIC_DESTRUCTOR_REGISTER(arg_image, freep); STATIC_DESTRUCTOR_REGISTER(arg_file, strv_freep); STATIC_DESTRUCTOR_REGISTER(arg_image_policy, image_policy_freep); static int add_match(sd_journal *j, const char *match) { _cleanup_free_ char *p = NULL; - const char* prefix, *pattern; - pid_t pid; + const char *field; int r; if (strchr(match, '=')) - prefix = ""; - else if (strchr(match, '/')) { + field = NULL; + else if (is_path(match)) { r = path_make_absolute_cwd(match, &p); if (r < 0) return log_error_errno(r, "path_make_absolute_cwd(\"%s\"): %m", match); match = p; - prefix = "COREDUMP_EXE="; - } else if (parse_pid(match, &pid) >= 0) - prefix = "COREDUMP_PID="; + field = "COREDUMP_EXE"; + } else if (parse_pid(match, NULL) >= 0) + field = "COREDUMP_PID"; else - prefix = "COREDUMP_COMM="; + field = "COREDUMP_COMM"; - pattern = strjoina(prefix, match); - log_debug("Adding match: %s", pattern); - r = sd_journal_add_match(j, pattern, 0); + log_debug("Adding match: %s%s%s", strempty(field), field ? "=" : "", match); + if (field) + r = journal_add_match_pair(j, field, match); + else + r = sd_journal_add_match(j, match, SIZE_MAX); if (r < 0) - return log_error_errno(r, "Failed to add match \"%s\": %m", match); + return log_error_errno(r, "Failed to add match \"%s%s%s\": %m", + strempty(field), field ? "=" : "", match); return 0; } @@ -102,11 +106,11 @@ static int add_match(sd_journal *j, const char *match) { static int add_matches(sd_journal *j, char **matches) { int r; - r = sd_journal_add_match(j, "MESSAGE_ID=" SD_MESSAGE_COREDUMP_STR, 0); + r = sd_journal_add_match(j, "MESSAGE_ID=" SD_MESSAGE_COREDUMP_STR, SIZE_MAX); if (r < 0) return log_error_errno(r, "Failed to add match \"%s\": %m", "MESSAGE_ID=" SD_MESSAGE_COREDUMP_STR); - r = sd_journal_add_match(j, "MESSAGE_ID=" SD_MESSAGE_BACKTRACE_STR, 0); + r = sd_journal_add_match(j, "MESSAGE_ID=" SD_MESSAGE_BACKTRACE_STR, SIZE_MAX); if (r < 0) return log_error_errno(r, "Failed to add match \"%s\": %m", "MESSAGE_ID=" SD_MESSAGE_BACKTRACE_STR); @@ -126,19 +130,19 @@ static int acquire_journal(sd_journal **ret, char **matches) { assert(ret); if (arg_directory) { - r = sd_journal_open_directory(&j, arg_directory, 0); + r = sd_journal_open_directory(&j, arg_directory, SD_JOURNAL_ASSUME_IMMUTABLE); if (r < 0) return log_error_errno(r, "Failed to open journals in directory: %s: %m", arg_directory); } else if (arg_root) { - r = sd_journal_open_directory(&j, arg_root, SD_JOURNAL_OS_ROOT); + r = sd_journal_open_directory(&j, arg_root, SD_JOURNAL_OS_ROOT | SD_JOURNAL_ASSUME_IMMUTABLE); if (r < 0) return log_error_errno(r, "Failed to open journals in root directory: %s: %m", arg_root); } else if (arg_file) { - r = sd_journal_open_files(&j, (const char**)arg_file, 0); + r = sd_journal_open_files(&j, (const char**)arg_file, SD_JOURNAL_ASSUME_IMMUTABLE); if (r < 0) return log_error_errno(r, "Failed to open journal files: %m"); } else { - r = sd_journal_open(&j, arg_all ? 0 : SD_JOURNAL_LOCAL_ONLY); + r = sd_journal_open(&j, arg_all ? 0 : SD_JOURNAL_LOCAL_ONLY | SD_JOURNAL_ASSUME_IMMUTABLE); if (r < 0) return log_error_errno(r, "Failed to open journal: %m"); } @@ -875,7 +879,7 @@ static int dump_list(int argc, char **argv, void *userdata) { verb_is_info = argc >= 1 && streq(argv[0], "info"); - r = acquire_journal(&j, argv + 1); + r = acquire_journal(&j, strv_skip(argv, 1)); if (r < 0) return r; @@ -1126,7 +1130,7 @@ static int dump_core(int argc, char **argv, void *userdata) { return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Option --field/-F only makes sense with list"); - r = acquire_journal(&j, argv + 1); + r = acquire_journal(&j, strv_skip(argv, 1)); if (r < 0) return r; @@ -1199,7 +1203,7 @@ static int run_debug(int argc, char **argv, void *userdata) { return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Option --field/-F only makes sense with list"); - r = acquire_journal(&j, argv + 1); + r = acquire_journal(&j, strv_skip(argv, 1)); if (r < 0) return r; @@ -1240,7 +1244,7 @@ static int run_debug(int argc, char **argv, void *userdata) { if (r < 0) return r; - r = strv_extend_strv(&debugger_call, STRV_MAKE(exe, "-c", path), false); + r = strv_extend_many(&debugger_call, exe, "-c", path); if (r < 0) return log_oom(); @@ -1249,14 +1253,14 @@ static int run_debug(int argc, char **argv, void *userdata) { const char *sysroot_cmd; sysroot_cmd = strjoina("set sysroot ", arg_root); - r = strv_extend_strv(&debugger_call, STRV_MAKE("-iex", sysroot_cmd), false); + r = strv_extend_many(&debugger_call, "-iex", sysroot_cmd); if (r < 0) return log_oom(); } else if (streq(arg_debugger, "lldb")) { const char *sysroot_cmd; sysroot_cmd = strjoina("platform select --sysroot ", arg_root, " host"); - r = strv_extend_strv(&debugger_call, STRV_MAKE("-O", sysroot_cmd), false); + r = strv_extend_many(&debugger_call, "-O", sysroot_cmd); if (r < 0) return log_oom(); } @@ -1392,7 +1396,8 @@ static int run(int argc, char *argv[]) { DISSECT_IMAGE_GENERIC_ROOT | DISSECT_IMAGE_REQUIRE_ROOT | DISSECT_IMAGE_RELAX_VAR_CHECK | - DISSECT_IMAGE_VALIDATE_OS, + DISSECT_IMAGE_VALIDATE_OS | + DISSECT_IMAGE_ALLOW_USERSPACE_VERITY, &mounted_dir, /* ret_dir_fd= */ NULL, &loop_device); |