dcavalca / rpms / systemd

Forked from rpms/systemd 4 months ago
Clone
594167
From ab458e74eccf14550711ca024e9176fba7993abc Mon Sep 17 00:00:00 2001
594167
From: Frantisek Sumsal <frantisek@sumsal.cz>
594167
Date: Fri, 18 Feb 2022 23:09:18 +0100
594167
Subject: [PATCH] systemctl: make `--timestamp=` affect the `show` verb as well
594167
594167
Currently the `--timestamp=` option has no effect on timestamps shown by
594167
`systemctl show`, let's fix that.
594167
594167
Spotted in #22567.
594167
594167
Before:
594167
```
594167
$ systemctl show --timestamp=us+utc systemd-journald | grep Timestamp=
594167
ExecMainStartTimestamp=Sat 2021-12-11 15:25:57 CET
594167
StateChangeTimestamp=Sat 2021-12-11 15:25:57 CET
594167
InactiveExitTimestamp=Sat 2021-12-11 15:25:57 CET
594167
ActiveEnterTimestamp=Sat 2021-12-11 15:25:57 CET
594167
ActiveExitTimestamp=Sat 2021-12-11 15:25:57 CET
594167
InactiveEnterTimestamp=Sat 2021-12-11 15:25:57 CET
594167
ConditionTimestamp=Sat 2021-12-11 15:25:57 CET
594167
AssertTimestamp=Sat 2021-12-11 15:25:57 CET
594167
```
594167
594167
After:
594167
```
594167
$ systemctl show --timestamp=us+utc systemd-journald | grep Timestamp=
594167
ExecMainStartTimestamp=Sat 2021-12-11 14:25:57.177848 UTC
594167
StateChangeTimestamp=Sat 2021-12-11 14:25:57.196714 UTC
594167
InactiveExitTimestamp=Sat 2021-12-11 14:25:57.177871 UTC
594167
ActiveEnterTimestamp=Sat 2021-12-11 14:25:57.196714 UTC
594167
ActiveExitTimestamp=Sat 2021-12-11 14:25:57.144677 UTC
594167
InactiveEnterTimestamp=Sat 2021-12-11 14:25:57.176331 UTC
594167
ConditionTimestamp=Sat 2021-12-11 14:25:57.176980 UTC
594167
AssertTimestamp=Sat 2021-12-11 14:25:57.176980 UTC
594167
594167
```
594167
594167
(cherry picked from commit a59e5c625da5a6e0c46e493d55f2f4212e9457ca)
594167
594167
Related: #2017035
594167
---
594167
 src/systemctl/systemctl-show.c | 14 ++++++++++++++
594167
 1 file changed, 14 insertions(+)
594167
594167
diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c
594167
index 9b23471990..7a6655da74 100644
594167
--- a/src/systemctl/systemctl-show.c
594167
+++ b/src/systemctl/systemctl-show.c
594167
@@ -1001,6 +1001,20 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m
594167
                 }
594167
                 break;
594167
 
594167
+        case SD_BUS_TYPE_UINT64:
594167
+                if (endswith(name, "Timestamp")) {
594167
+                        uint64_t timestamp;
594167
+
594167
+                        r = sd_bus_message_read_basic(m, bus_type, &timestamp);
594167
+                        if (r < 0)
594167
+                                return r;
594167
+
594167
+                        bus_print_property_value(name, expected_value, flags, FORMAT_TIMESTAMP_STYLE(timestamp, arg_timestamp_style));
594167
+
594167
+                        return 1;
594167
+                }
594167
+                break;
594167
+
594167
         case SD_BUS_TYPE_STRUCT:
594167
 
594167
                 if (contents[0] == SD_BUS_TYPE_UINT32 && streq(name, "Job")) {