]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/coredump/coredumpctl.c
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / coredump / coredumpctl.c
index 93d5e1c9d14582bcb9ddf964a9fcd709ce13a0de..b92f5d330d81ee3622034085c18b50ee34f98fff 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
@@ -51,6 +52,8 @@
 #include "user-util.h"
 #include "util.h"
 
+#define SHORT_BUS_CALL_TIMEOUT_USEC (3 * USEC_PER_SEC)
+
 static usec_t arg_since = USEC_INFINITY, arg_until = USEC_INFINITY;
 
 static enum {
@@ -414,7 +417,7 @@ static int print_list(FILE* file, sd_journal *j, int had_legend) {
         else
                 present = "-";
 
-        if (STR_IN_SET(present, "present", "journal") && streq_ptr(truncated, "yes"))
+        if (STR_IN_SET(present, "present", "journal") && truncated && parse_boolean(truncated) > 0)
                 present = "truncated";
 
         fprintf(file, "%-*s %*s %*s %*s %*s %-*s %s\n",
@@ -583,8 +586,10 @@ static int print_info(FILE *file, sd_journal *j, bool need_space) {
                 fprintf(file, "      Hostname: %s\n", hostname);
 
         if (filename) {
-                bool inacc = access(filename, R_OK) < 0;
-                bool trunc = streq_ptr(truncated, "yes");
+                bool inacc, trunc;
+
+                inacc = access(filename, R_OK) < 0;
+                trunc = truncated && parse_boolean(truncated) > 0;
 
                 if (inacc || trunc)
                         fprintf(file, "       Storage: %s%s (%s%s%s)%s\n",
@@ -795,7 +800,7 @@ static int save_core(sd_journal *j, FILE *file, char **path, bool *unlink_temp)
         }
 
         if (filename) {
-#if defined(HAVE_XZ) || defined(HAVE_LZ4)
+#if HAVE_XZ || HAVE_LZ4
                 _cleanup_close_ int fdf;
 
                 fdf = open(filename, O_RDONLY | O_CLOEXEC);
@@ -990,7 +995,7 @@ static int check_units_active(void) {
         if (r < 0)
                 return bus_log_create_error(r);
 
-        r = sd_bus_call(bus, m, 3 * USEC_PER_SEC, &error, &reply);
+        r = sd_bus_call(bus, m, SHORT_BUS_CALL_TIMEOUT_USEC, &error, &reply);
         if (r < 0)
                 return log_error_errno(r, "Failed to check if any systemd-coredump@.service units are running: %s",
                                        bus_error_message(&error, r));
@@ -1003,7 +1008,7 @@ static int check_units_active(void) {
                                 reply, "(ssssssouso)",
                                 &id,  NULL,  NULL,  &state,  &substate,
                                 NULL,  NULL,  NULL,  NULL,  NULL)) > 0) {
-                bool found = !STR_IN_SET(state, "dead", "failed");
+                bool found = !STR_IN_SET(state, "inactive", "dead", "failed");
                 log_debug("Unit %s is %s/%s, %scounting it.", id, state, substate, found ? "" : "not ");
                 c += found;
         }