From 4b35eb2579b226785f0d94129a7652450f9723fd Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 21 Jan 2022 18:56:42 +0100 Subject: [PATCH 1/2] hostname: Allow overriding the chassis type from hwdb Closes: #7390 --- src/hostname/hostnamed.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index b20a93ad81c..559326b9f51 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -725,16 +725,18 @@ static int property_get_chassis( sd_bus_error *error) { Context *c = userdata; - const char *name; + _cleanup_free_ char *dmi_chassis = NULL; + const char *name = NULL; context_read_machine_info(c); - if (isempty(c->data[PROP_CHASSIS])) - name = fallback_chassis(); - else + if (isempty(c->data[PROP_CHASSIS])) { + if (get_dmi_data("ID_CHASSIS", NULL, &dmi_chassis) <= 0) + name = fallback_chassis(); + } else name = c->data[PROP_CHASSIS]; - return sd_bus_message_append(reply, "s", name); + return sd_bus_message_append(reply, "s", name ?: dmi_chassis); } static int property_get_uname_field( From bdf182debe715ff7876c610b0f93540437cb8b43 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 21 Jan 2022 18:57:21 +0100 Subject: [PATCH 2/2] hwdb: Add Microsoft Surface Pro 1 chassis quirk See https://github.com/systemd/systemd/issues/7390#issuecomment-345546127 --- hwdb.d/20-dmi-id.hwdb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hwdb.d/20-dmi-id.hwdb b/hwdb.d/20-dmi-id.hwdb index a614473bd90..c7bf6cfab10 100644 --- a/hwdb.d/20-dmi-id.hwdb +++ b/hwdb.d/20-dmi-id.hwdb @@ -4,3 +4,7 @@ dmi:bvnLENOVO* ID_SYSFS_ATTRIBUTE_MODEL=product_version ID_VENDOR_FROM_DATABASE=Lenovo + +# Microsoft Surface 1's chassis type +dmi:bvnMicrosoft Corporation*:pvrSurface with Windows 8 Pro* + ID_CHASSIS=tablet