]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
coredump: Add --all option
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 6 Oct 2021 12:47:46 +0000 (13:47 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 7 Oct 2021 20:13:12 +0000 (22:13 +0200)
This option has coredumpctl look at all journals instead of only the
local ones. This allows coredumpctl to show information about remote
coredumps if the coredumps are made available in /var/lib/systemd/coredump
and the corresponding journals are made available in /var/log/journal.

This is already possible using the --directory option but --all makes it
more user friendly since users don't have to enter the journal directory
anymore as long as it's available under /var/log/journal.

man/coredumpctl.xml
shell-completion/bash/coredumpctl
shell-completion/zsh/_coredumpctl
src/coredump/coredumpctl.c

index d45ed753b25502c368efbfef7953215bd08c2493..2a1f654112553d47f8b9061429c156b0a7946339 100644 (file)
         of access to journal files and possible in-flight coredumps.
         </para></listitem>
       </varlistentry>
+
+      <varlistentry>
+        <term><option>--all</option></term>
+
+        <listitem><para>Look at all available journal files in <filename>/var/log/journal/</filename>
+        (excluding journal namespaces) instead of only local ones.</para></listitem>
+      </varlistentry>
     </variablelist>
   </refsect1>
 
index 54b85725158b14ea690e4c8f336224df79e1fcc7..b43338eb21d771410b243f21a5e47ffefc205070 100644 (file)
@@ -40,7 +40,7 @@ _coredumpctl() {
     local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
     local OPTS='-h --help --version --no-pager --no-legend -o --output -F --field -1
                 -r --reverse -S --since -U --until -D --directory -q --quiet --debugger
-                -A --debugger-arguments --json -n'
+                -A --debugger-arguments --json -n --all'
 
     local -A VERBS=(
         [LIST]='list info'
index ae62e50f3a4f0d9b4da7ae3a42e9117efe0276d2..dad21a74ad825b5f4eb0f10bc02e40d2b1b6669f 100644 (file)
@@ -43,4 +43,5 @@ _arguments \
     '--debugger=[Use the given debugger]:debugger: _command_names -e' \
     {-D,--directory=}'[Use the journal files in the specified dir]:directory: _directories' \
     {-q,--quiet}'[Do not show info messages and privilege warning]' \
+    '--all[Look at all journal files instead of local ones]' \
     '*::coredumpctl commands:_coredumpctl_commands'
index b7957921ef0c62dae6a78f9e38e8cd77f50a331e..2eaa56a4fd957cb4623ddf2b76c89449d11a8a67 100644 (file)
@@ -56,6 +56,7 @@ static size_t arg_rows_max = SIZE_MAX;
 static const char* arg_output = NULL;
 static bool arg_reverse = false;
 static bool arg_quiet = false;
+static bool arg_all = false;
 
 STATIC_DESTRUCTOR_REGISTER(arg_debugger_args, strv_freep);
 STATIC_DESTRUCTOR_REGISTER(arg_file, strv_freep);
@@ -125,7 +126,7 @@ static int acquire_journal(sd_journal **ret, char **matches) {
                 if (r < 0)
                         return log_error_errno(r, "Failed to open journal files: %m");
         } else {
-                r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY);
+                r = sd_journal_open(&j, arg_all ? 0 : SD_JOURNAL_LOCAL_ONLY);
                 if (r < 0)
                         return log_error_errno(r, "Failed to open journal: %m");
         }
@@ -184,6 +185,7 @@ static int verb_help(int argc, char **argv, void *userdata) {
                "     --file=PATH               Use journal file\n"
                "  -D --directory=DIR           Use journal files from directory\n\n"
                "  -q --quiet                   Do not show info messages and privilege warning\n"
+               "     --all                     Look at all journal files instead of local ones\n"
                "\nSee the %2$s for details.\n",
                program_invocation_short_name,
                link,
@@ -203,6 +205,7 @@ static int parse_argv(int argc, char *argv[]) {
                 ARG_JSON,
                 ARG_DEBUGGER,
                 ARG_FILE,
+                ARG_ALL,
         };
 
         int c, r;
@@ -223,6 +226,7 @@ static int parse_argv(int argc, char *argv[]) {
                 { "until",              required_argument, NULL, 'U'           },
                 { "quiet",              no_argument,       NULL, 'q'           },
                 { "json",               required_argument, NULL, ARG_JSON      },
+                { "all",                no_argument,       NULL, ARG_ALL       },
                 {}
         };
 
@@ -327,6 +331,10 @@ static int parse_argv(int argc, char *argv[]) {
 
                         break;
 
+                case ARG_ALL:
+                        arg_all = true;
+                        break;
+
                 case '?':
                         return -EINVAL;