mirror of
https://github.com/systemd/systemd.git
synced 2025-03-22 06:50:18 +03:00
hostnamectl: show age of firmware as time span, too
This converts the date into a relative timespan from the current time on, and outputs it. It marks it yellow if older than two years, since old firmware is probably a security risk. We don't make it red, since we don't know though.
This commit is contained in:
parent
4c834779cd
commit
2b5eff67f5
@ -274,11 +274,22 @@ static int print_status_info(StatusInfo *i) {
|
||||
}
|
||||
|
||||
if (timestamp_is_set(i->firmware_date)) {
|
||||
usec_t n = now(CLOCK_REALTIME);
|
||||
|
||||
r = table_add_many(table,
|
||||
TABLE_FIELD, "Firmware Date",
|
||||
TABLE_TIMESTAMP_DATE, i->firmware_date);
|
||||
if (r < 0)
|
||||
return table_log_add_error(r);
|
||||
|
||||
if (i->firmware_date < n) {
|
||||
r = table_add_many(table,
|
||||
TABLE_FIELD, "Firmware Age",
|
||||
TABLE_TIMESPAN_DAY, n - i->firmware_date,
|
||||
TABLE_SET_COLOR, n - i->firmware_date > USEC_PER_YEAR*2 ? ANSI_HIGHLIGHT_YELLOW : NULL);
|
||||
if (r < 0)
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
}
|
||||
|
||||
r = table_print(table, NULL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user