summaryrefslogtreecommitdiff
path: root/src/hostname
diff options
context:
space:
mode:
authorJelle van der Waa <jvanderwaa@redhat.com>2022-12-07 17:33:50 +0100
committerJelle van der Waa <jvanderwaa@redhat.com>2022-12-07 20:35:56 +0100
commitff4d26dff4283d08c39c60d7a928490886f635c6 (patch)
tree3bb286d266f27ce2172a488fda12608ffebcf771 /src/hostname
parentf233bbd6074d8323413a705f927fea3b819bb35f (diff)
downloadsystemd-ff4d26dff4283d08c39c60d7a928490886f635c6.tar.gz
hostnamed: expose FirmwareDate dbus property
Expose /sys/class/dmi/id/bios_date as dbus property in hostnamed.
Diffstat (limited to 'src/hostname')
-rw-r--r--src/hostname/hostnamed.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index 46d4ea8ebd..ea19dfbb04 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -250,6 +250,10 @@ static int get_firmware_vendor(char **ret) {
return get_hardware_firmware_data("bios_vendor", ret);
}
+static int get_firmware_date(char **ret) {
+ return get_hardware_firmware_data("bios_date", ret);
+}
+
static const char* valid_chassis(const char *chassis) {
assert(chassis);
@@ -648,6 +652,21 @@ static int property_get_firmware_vendor(
return sd_bus_message_append(reply, "s", firmware_vendor);
}
+static int property_get_firmware_date(
+ sd_bus *bus,
+ const char *path,
+ const char *interface,
+ const char *property,
+ sd_bus_message *reply,
+ void *userdata,
+ sd_bus_error *error) {
+
+ _cleanup_free_ char *firmware_date = NULL;
+
+ (void) get_firmware_date(&firmware_date);
+
+ return sd_bus_message_append(reply, "s", firmware_date);
+}
static int property_get_hostname(
sd_bus *bus,
const char *path,
@@ -1170,7 +1189,7 @@ static int method_get_hardware_serial(sd_bus_message *m, void *userdata, sd_bus_
static int method_describe(sd_bus_message *m, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *hn = NULL, *dhn = NULL, *in = NULL, *text = NULL,
*chassis = NULL, *vendor = NULL, *model = NULL, *serial = NULL, *firmware_version = NULL,
- *firmware_vendor = NULL;
+ *firmware_vendor = NULL, *firmware_date = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
sd_id128_t product_uuid = SD_ID128_NULL;
@@ -1235,6 +1254,7 @@ static int method_describe(sd_bus_message *m, void *userdata, sd_bus_error *erro
}
(void) get_firmware_version(&firmware_version);
(void) get_firmware_vendor(&firmware_vendor);
+ (void) get_firmware_date(&firmware_date);
r = json_build(&v, JSON_BUILD_OBJECT(
JSON_BUILD_PAIR("Hostname", JSON_BUILD_STRING(hn)),
@@ -1257,6 +1277,7 @@ static int method_describe(sd_bus_message *m, void *userdata, sd_bus_error *erro
JSON_BUILD_PAIR("HardwareSerial", JSON_BUILD_STRING(serial)),
JSON_BUILD_PAIR("FirmwareVersion", JSON_BUILD_STRING(firmware_version)),
JSON_BUILD_PAIR("FirmwareVendor", JSON_BUILD_STRING(firmware_vendor)),
+ JSON_BUILD_PAIR("FirmwareDate", JSON_BUILD_STRING(firmware_date)),
JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(product_uuid), "ProductUUID", JSON_BUILD_ID128(product_uuid)),
JSON_BUILD_PAIR_CONDITION(sd_id128_is_null(product_uuid), "ProductUUID", JSON_BUILD_NULL)));
@@ -1299,6 +1320,7 @@ static const sd_bus_vtable hostname_vtable[] = {
SD_BUS_PROPERTY("HardwareModel", "s", property_get_hardware_model, 0, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("FirmwareVersion", "s", property_get_firmware_version, 0, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("FirmwareVendor", "s", property_get_firmware_vendor, 0, SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("FirmwareDate", "s", property_get_firmware_date, 0, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_METHOD_WITH_ARGS("SetHostname",
SD_BUS_ARGS("s", hostname, "b", interactive),