Skip to content
Snippets Groups Projects
Commit 4a8f81a6 authored by Luca Weiss's avatar Luca Weiss
Browse files

hostnamed: add support for HardwareVendor and HardwareModel properties

Read the values from machine-info file and expose them on D-Bus.
parent 0558706b
Branches main
No related tags found
No related merge requests found
......@@ -38,5 +38,7 @@
<property name="Chassis" type="s" access="read"/>
<property name="Deployment" type="s" access="read"/>
<property name="Location" type="s" access="read"/>
<property name="HardwareVendor" type="s" access="read"/>
<property name="HardwareModel" type="s" access="read"/>
</interface>
</node>
......@@ -62,6 +62,8 @@ static gchar *icon_name = NULL;
static gchar *chassis = NULL;
static gchar *deployment = NULL;
static gchar *location = NULL;
static gchar *hardware_vendor = NULL;
static gchar *hardware_model = NULL;
static GFile *machine_info_file = NULL;
G_LOCK_DEFINE_STATIC (machine_info);
......@@ -606,6 +608,8 @@ on_bus_acquired (GDBusConnection *connection,
openrc_settingsd_hostnamed_hostname1_set_chassis (hostname1, chassis);
openrc_settingsd_hostnamed_hostname1_set_deployment (hostname1, deployment);
openrc_settingsd_hostnamed_hostname1_set_location (hostname1, location);
openrc_settingsd_hostnamed_hostname1_set_hardware_vendor (hostname1, hardware_vendor);
openrc_settingsd_hostnamed_hostname1_set_hardware_model (hostname1, hardware_model);
g_signal_connect (hostname1, "handle-set-hostname", G_CALLBACK (on_handle_set_hostname), NULL);
g_signal_connect (hostname1, "handle-set-static-hostname", G_CALLBACK (on_handle_set_static_hostname), NULL);
......@@ -723,6 +727,24 @@ hostnamed_init (gboolean _read_only)
err = NULL;
}
hardware_vendor = shell_source_var (machine_info_file, "${HARDWARE_VENDOR}", &err);
if (hardware_vendor == NULL)
hardware_vendor = g_strdup ("");
if (err != NULL) {
g_debug ("%s", err->message);
g_error_free (err);
err = NULL;
}
hardware_model = shell_source_var (machine_info_file, "${HARDWARE_MODEL}", &err);
if (hardware_model == NULL)
hardware_model = g_strdup ("");
if (err != NULL) {
g_debug ("%s", err->message);
g_error_free (err);
err = NULL;
}
read_only = _read_only;
bus_id = g_bus_own_name (G_BUS_TYPE_SYSTEM,
......@@ -748,6 +770,8 @@ hostnamed_destroy (void)
g_free (chassis);
g_free (deployment);
g_free (location);
g_free (hardware_vendor);
g_free (hardware_model);
g_object_unref (static_hostname_file);
g_object_unref (machine_info_file);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment