mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-03-13 12:58:20 +03:00
hostnamectl: do not show local machine ID and boot ID when requested to show information about remote host
Prompted by #30293. (cherry picked from commit 01e554e2e71859220e86a14212420720e05bccbf) (cherry picked from commit 683415c1ed731845dddc87ad48f2c8fe973d951a) (cherry picked from commit 9499316fe68b98edf0151aa531fa6fa02733b96b)
This commit is contained in:
parent
3b5f4237a1
commit
b4663fc086
@ -55,6 +55,8 @@ typedef struct StatusInfo {
|
||||
const char *hardware_model;
|
||||
const char *firmware_version;
|
||||
usec_t firmware_date;
|
||||
sd_id128_t machine_id;
|
||||
sd_id128_t boot_id;
|
||||
} StatusInfo;
|
||||
|
||||
static const char* chassis_string_to_glyph(const char *chassis) {
|
||||
@ -96,7 +98,6 @@ static const char *os_support_end_color(usec_t n, usec_t eol) {
|
||||
|
||||
static int print_status_info(StatusInfo *i) {
|
||||
_cleanup_(table_unrefp) Table *table = NULL;
|
||||
sd_id128_t mid = {}, bid = {};
|
||||
TableCell *cell;
|
||||
int r;
|
||||
|
||||
@ -173,20 +174,18 @@ static int print_status_info(StatusInfo *i) {
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
r = sd_id128_get_machine(&mid);
|
||||
if (r >= 0) {
|
||||
if (!sd_id128_is_null(i->machine_id)) {
|
||||
r = table_add_many(table,
|
||||
TABLE_FIELD, "Machine ID",
|
||||
TABLE_ID128, mid);
|
||||
TABLE_ID128, i->machine_id);
|
||||
if (r < 0)
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
r = sd_id128_get_boot(&bid);
|
||||
if (r >= 0) {
|
||||
if (!sd_id128_is_null(i->boot_id)) {
|
||||
r = table_add_many(table,
|
||||
TABLE_FIELD, "Boot ID",
|
||||
TABLE_ID128, bid);
|
||||
TABLE_ID128, i->boot_id);
|
||||
if (r < 0)
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
@ -382,6 +381,13 @@ static int show_all_names(sd_bus *bus) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to query system properties: %s", bus_error_message(&error, r));
|
||||
|
||||
if (!arg_host) {
|
||||
if (sd_id128_is_null(info.machine_id))
|
||||
(void) sd_id128_get_machine(&info.machine_id);
|
||||
if (sd_id128_is_null(info.boot_id))
|
||||
(void) sd_id128_get_boot(&info.boot_id);
|
||||
}
|
||||
|
||||
return print_status_info(&info);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user