diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-09-01 20:29:28 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-09-20 12:50:48 +0200 |
commit | 004eab49e3264cbe9e5552ca02600a324fdc71f7 (patch) | |
tree | ec0d1698cddc4a7a3072d35dc43008aa058083c2 | |
parent | 0fe18a3235f6cd429ed8bcc642131fd922b395c4 (diff) | |
download | systemd-004eab49e3264cbe9e5552ca02600a324fdc71f7.tar.gz |
coredump: don't convert s → µs twice
We already append 000000 early on when parsing the cmdline args, let's
not do that a second time.
Fixes: #16919
(cherry picked from commit 64a5384fd2cde9b66a778c318036e7771f273f17)
(cherry picked from commit 2239965c299e53db961f4294ccd5cbbda4f377df)
(cherry picked from commit a46a8189e370a5f1b58f0cf7158386cee4555fb4)
(cherry picked from commit c829f6e7ca5a3480c5995deb96ee77643128e546)
-rw-r--r-- | src/coredump/coredump.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c index d4052f69db..a1b47530df 100644 --- a/src/coredump/coredump.c +++ b/src/coredump/coredump.c @@ -78,7 +78,7 @@ enum { META_ARGV_UID, /* %u: as seen in the initial user namespace */ META_ARGV_GID, /* %g: as seen in the initial user namespace */ META_ARGV_SIGNAL, /* %s: number of signal causing dump */ - META_ARGV_TIMESTAMP, /* %t: time of dump, expressed as seconds since the Epoch */ + META_ARGV_TIMESTAMP, /* %t: time of dump, expressed as seconds since the Epoch (we expand this to µs granularity) */ META_ARGV_RLIMIT, /* %c: core file size soft resource limit */ META_ARGV_HOSTNAME, /* %h: hostname */ _META_ARGV_MAX, @@ -329,7 +329,7 @@ static int make_filename(const Context *context, char **ret) { return -ENOMEM; if (asprintf(ret, - "/var/lib/systemd/coredump/core.%s.%s." SD_ID128_FORMAT_STR ".%s.%s000000", + "/var/lib/systemd/coredump/core.%s.%s." SD_ID128_FORMAT_STR ".%s.%s", c, u, SD_ID128_FORMAT_VAL(boot), @@ -1047,8 +1047,11 @@ static int send_iovec(const struct iovec_wrapper *iovw, int input_fd) { return 0; } -static int gather_pid_metadata_from_argv(struct iovec_wrapper *iovw, Context *context, - int argc, char **argv) { +static int gather_pid_metadata_from_argv( + struct iovec_wrapper *iovw, + Context *context, + int argc, char **argv) { + _cleanup_free_ char *free_timestamp = NULL; int i, r, signo; char *t; @@ -1066,6 +1069,7 @@ static int gather_pid_metadata_from_argv(struct iovec_wrapper *iovw, Context *co t = argv[i]; switch (i) { + case META_ARGV_TIMESTAMP: /* The journal fields contain the timestamp padded with six * zeroes, so that the kernel-supplied 1s granularity timestamps @@ -1075,12 +1079,14 @@ static int gather_pid_metadata_from_argv(struct iovec_wrapper *iovw, Context *co if (!t) return log_oom(); break; + case META_ARGV_SIGNAL: /* For signal, record its pretty name too */ if (safe_atoi(argv[i], &signo) >= 0 && SIGNAL_VALID(signo)) (void) iovw_put_string_field(iovw, "COREDUMP_SIGNAL_NAME=SIG", signal_to_string(signo)); break; + default: break; } |