[dbus PATCH v2 5/8] Implement Secure property for Connect Interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx>
---
 data/org.libvirt.Connect.xml |  5 +++++
 src/connect.c                | 20 ++++++++++++++++++++
 test/test_connect.py         |  1 +
 3 files changed, 26 insertions(+)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 84eadb0..10bd6d2 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -16,6 +16,11 @@
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectGetLibVersion"/>
     </property>
+    <property name="Secure" type="b" access="read">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectIsSecure
+               Note that monitoring of traffic on the dbus message bus is out of the scope of this property"/>
+    </property>
     <property name="Version" type="t" access="read">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectGetVersion"/>
diff --git a/src/connect.c b/src/connect.c
index 8335e51..dab6f34 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -147,6 +147,25 @@ virtDBusConnectGetLibVersion(const gchar *objectPath G_GNUC_UNUSED,
     *value = g_variant_new("t", libVer);
 }
 
+static void
+virtDBusConnectGetSecure(const gchar *objectPath G_GNUC_UNUSED,
+                         gpointer userData,
+                         GVariant **value,
+                         GError **error)
+{
+    virtDBusConnect *connect = userData;
+    gint secure;
+
+    if (!virtDBusConnectOpen(connect, error))
+        return;
+
+    secure = virConnectIsEncrypted(connect->connection);
+    if (secure < 0)
+        return virtDBusUtilSetLastVirtError(error);
+
+    *value = g_variant_new("b", !!secure);
+}
+
 static void
 virtDBusConnectGetVersion(const gchar *objectPath G_GNUC_UNUSED,
                           gpointer userData,
@@ -524,6 +543,7 @@ static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = {
     { "Encrypted", virtDBusConnectGetEncrypted, NULL },
     { "Hostname", virtDBusConnectGetHostname, NULL },
     { "LibVersion", virtDBusConnectGetLibVersion, NULL },
+    { "Secure", virtDBusConnectGetSecure, NULL },
     { "Version", virtDBusConnectGetVersion, NULL },
     { 0 }
 };
diff --git a/test/test_connect.py b/test/test_connect.py
index 58bc267..6baa6df 100755
--- a/test/test_connect.py
+++ b/test/test_connect.py
@@ -84,6 +84,7 @@ class TestConnect(libvirttest.BaseTestClass):
         ("Encrypted", dbus.Boolean),
         ("Hostname", dbus.String),
         ("LibVersion", dbus.UInt64),
+        ("Secure", dbus.Boolean),
         ("Version", dbus.UInt64),
     ])
     def test_connect_properties_return_type(self, property_name, expected_type):
-- 
2.15.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux