coredump: normalize generation/parsing of COREDUMP_TRUNCATED=
authorLennart Poettering <lennart@poettering.net>
Wed, 1 Mar 2017 14:46:54 +0000 (15:46 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 1 Mar 2017 17:13:00 +0000 (18:13 +0100)
Given that this is a field primarily processed by computers, and not so
much by humans, assign "1" instead of "yes". Also, use parse_boolean()
as we usually do for parsing it again.

This makes things more alike udev options (as one example), such as
SYSTEMD_READY where we also spit out "1" and "0", and parse with
parse_boolean().

src/coredump/coredump.c
src/coredump/coredumpctl.c

index 270af630cf9053f488364df54cc9e36dbdc467f5..190ffc631e9fa30bae2e38472a2fd637a3d0dae1 100644 (file)
@@ -795,7 +795,7 @@ log:
                 IOVEC_SET_STRING(iovec[n_iovec++], core_message);
 
         if (truncated)
-                IOVEC_SET_STRING(iovec[n_iovec++], "COREDUMP_TRUNCATED=yes");
+                IOVEC_SET_STRING(iovec[n_iovec++], "COREDUMP_TRUNCATED=1");
 
         /* Optionally store the entire coredump in the journal */
         if (arg_storage == COREDUMP_STORAGE_JOURNAL) {
index 3e9a00bbcf78d4b641af66506351fd280897c33a..bffb3d458f0c0b7580ef8bbafdf0975a162e3bc8 100644 (file)
@@ -414,7 +414,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 +583,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",