Merge pull request #22209 from systemd/wip/hadess/chassis-override

hostname: Allow overriding the chassis type from hwdb
This commit is contained in:
Yu Watanabe 2022-01-22 16:49:36 +09:00 committed by GitHub
commit f939a8984a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View file

@ -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

View file

@ -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(