privacy: Use CcHostname to detect when running in a VM
We currently hide "Device Security" when running in a VM or an undefined systemd-hostnamed chassis-type. This makes our existing check use the CcHostname utility.
This commit is contained in:
parent
cd911dfa5d
commit
47774b9968
1 changed files with 7 additions and 35 deletions
|
@ -27,6 +27,7 @@
|
|||
#include "cc-firmware-security-boot-dialog.h"
|
||||
#include "cc-firmware-security-help-dialog.h"
|
||||
#include "cc-firmware-security-utils.h"
|
||||
#include "cc-hostname.h"
|
||||
#include "cc-util.h"
|
||||
|
||||
#include <gio/gdesktopappinfo.h>
|
||||
|
@ -630,44 +631,15 @@ on_properties_bus_ready_cb (GObject *source_object,
|
|||
static void
|
||||
update_page_visibility (CcFirmwareSecurityPage *self)
|
||||
{
|
||||
g_autoptr(GDBusConnection) connection = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
g_autoptr(GVariant) inner = NULL;
|
||||
g_autoptr(GVariant) variant = NULL;
|
||||
CcHostname *hostname;
|
||||
gboolean visible = TRUE;
|
||||
const gchar *chassis_type;
|
||||
g_autofree gchar *chassis_type = NULL;
|
||||
|
||||
connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, self->cancellable, &error);
|
||||
if (!connection)
|
||||
{
|
||||
g_warning ("system bus not available: %s", error->message);
|
||||
return;
|
||||
}
|
||||
variant = g_dbus_connection_call_sync (connection,
|
||||
"org.freedesktop.hostname1",
|
||||
"/org/freedesktop/hostname1",
|
||||
"org.freedesktop.DBus.Properties",
|
||||
"Get",
|
||||
g_variant_new ("(ss)",
|
||||
"org.freedesktop.hostname1",
|
||||
"Chassis"),
|
||||
NULL,
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
self->cancellable,
|
||||
&error);
|
||||
if (!variant)
|
||||
{
|
||||
g_warning ("Cannot get org.freedesktop.hostname1.Chassis: %s", error->message);
|
||||
return;
|
||||
}
|
||||
g_variant_get (variant, "(v)", &inner);
|
||||
|
||||
chassis_type = g_variant_get_string (inner, NULL);
|
||||
|
||||
/* there's no point showing this */
|
||||
if (g_strcmp0 (chassis_type, "vm") == 0 || g_strcmp0 (chassis_type, "") == 0)
|
||||
hostname = cc_hostname_get_default ();
|
||||
chassis_type = cc_hostname_get_chassis_type (hostname);
|
||||
if (cc_hostname_is_vm_chassis (hostname) || g_strcmp0 (chassis_type, "") == 0)
|
||||
visible = FALSE;
|
||||
|
||||
gtk_widget_set_visible (GTK_WIDGET (self), visible);
|
||||
g_debug ("Firmware Security page visible: %s as chassis was %s",
|
||||
visible ? "yes" : "no",
|
||||
|
|
Loading…
Add table
Reference in a new issue