[PATCH 5/8] API to query signed status of device drivers

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

 



From: "Zeeshan Ali (Khattak)" <zeeshanak@xxxxxxxxx>

Some vendors recommend or require device drivers to be signed by them
before these device drivers could be installed on their OS.
---
 data/oses/windows.xml.in      |  8 ++++----
 data/schemas/libosinfo.rng    |  5 +++++
 osinfo/libosinfo.syms         |  1 +
 osinfo/osinfo_device_driver.c | 16 ++++++++++++++++
 osinfo/osinfo_device_driver.h |  2 ++
 osinfo/osinfo_loader.c        |  8 ++++++++
 6 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/data/oses/windows.xml.in b/data/oses/windows.xml.in
index 1b762f8..f60786c 100644
--- a/data/oses/windows.xml.in
+++ b/data/oses/windows.xml.in
@@ -383,7 +383,7 @@
     </installer>
 
     <!-- virtio block device driver -->
-    <driver arch="i386" location="http://zeenix.fedorapeople.org/drivers/win-tools/preinst/winxp/x86"; pre-installable="true" format="windows">
+    <driver arch="i386" location="http://zeenix.fedorapeople.org/drivers/win-tools/preinst/winxp/x86"; pre-installable="true" format="windows" signed="false">
       <file>viostor.cat</file>
       <file>viostor.inf</file>
       <file>viostor.sys</file>
@@ -392,7 +392,7 @@
       <device id="http://pciids.sourceforge.net/v2.2/pci.ids/1af4/1001"/>
     </driver>
 
-    <driver arch="x86_64" location="http://zeenix.fedorapeople.org/drivers/win-tools/preinst/winxp/amd64"; pre-installable="true" format="windows">
+    <driver arch="x86_64" location="http://zeenix.fedorapeople.org/drivers/win-tools/preinst/winxp/amd64"; pre-installable="true" format="windows" signed="false">
       <file>viostor.cat</file>
       <file>viostor.inf</file>
       <file>viostor.sys</file>
@@ -754,14 +754,14 @@
     </installer>
 
     <!-- virtio block device driver -->
-    <driver arch="i386" location="http://zeenix.fedorapeople.org/drivers/win-tools/preinst/win7/x86"; pre-installable="true" format="windows">
+    <driver arch="i386" location="http://zeenix.fedorapeople.org/drivers/win-tools/preinst/win7/x86"; pre-installable="true" format="windows" signed="false">
       <file>viostor.cat</file>
       <file>viostor.inf</file>
       <file>viostor.sys</file>
       <device id="http://pciids.sourceforge.net/v2.2/pci.ids/1af4/1001"/>
     </driver>
 
-    <driver arch="x86_64" location="http://zeenix.fedorapeople.org/drivers/win-tools/preinst/win7/amd64"; pre-installable="true" format="windows">
+    <driver arch="x86_64" location="http://zeenix.fedorapeople.org/drivers/win-tools/preinst/win7/amd64"; pre-installable="true" format="windows" signed="false">
       <file>viostor.cat</file>
       <file>viostor.inf</file>
       <file>viostor.sys</file>
diff --git a/data/schemas/libosinfo.rng b/data/schemas/libosinfo.rng
index c193bcc..a3eb01c 100644
--- a/data/schemas/libosinfo.rng
+++ b/data/schemas/libosinfo.rng
@@ -452,6 +452,11 @@
         </attribute>
       </optional>
       <optional>
+        <attribute name="signed">
+          <ref name='bool'/>
+        </attribute>
+      </optional>
+      <optional>
         <attribute name="format">
           <ref name='driver-formats'/>
         </attribute>
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 3e71d9e..8998bf4 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -403,6 +403,7 @@ LIBOSINFO_0.2.4 {
     global:
 	osinfo_device_driver_format_get_type;
 	osinfo_device_driver_get_format;
+	osinfo_device_driver_get_signed;
 	osinfo_install_script_get_pre_install_driver_format;
 	osinfo_install_script_get_post_install_driver_format;
 } LIBOSINFO_0.2.3;
diff --git a/osinfo/osinfo_device_driver.c b/osinfo/osinfo_device_driver.c
index d88273a..ef2c204 100644
--- a/osinfo/osinfo_device_driver.c
+++ b/osinfo/osinfo_device_driver.c
@@ -181,6 +181,22 @@ void osinfo_device_driver_add_device(OsinfoDeviceDriver *driver,
                     OSINFO_ENTITY(device));
 }
 
+/**
+ * osinfo_device_driver_get_signed:
+ * @driver: an #OsinfoDeviceDriver instance
+ *
+ * Some vendors recommend or require device drivers to be signed by them before
+ * these device drivers could be installed on their OS.
+ *
+ * Returns: TRUE if @driver is signed, FALSE otherwise.
+ */
+gboolean osinfo_device_driver_get_signed(OsinfoDeviceDriver *driver)
+{
+    return osinfo_entity_get_param_value_boolean
+                (OSINFO_ENTITY(driver),
+                 OSINFO_DEVICE_DRIVER_PROP_SIGNED);
+}
+
 /*
  * Local variables:
  *  indent-tabs-mode: nil
diff --git a/osinfo/osinfo_device_driver.h b/osinfo/osinfo_device_driver.h
index b45f0ab..4ee2322 100644
--- a/osinfo/osinfo_device_driver.h
+++ b/osinfo/osinfo_device_driver.h
@@ -56,6 +56,7 @@ typedef struct _OsinfoDeviceDriverPrivate OsinfoDeviceDriverPrivate;
 #define OSINFO_DEVICE_DRIVER_PROP_FILE            "file"
 #define OSINFO_DEVICE_DRIVER_PROP_DEVICE          "device"
 #define OSINFO_DEVICE_DRIVER_PROP_FORMAT          "format"
+#define OSINFO_DEVICE_DRIVER_PROP_SIGNED          "signed"
 
 /* object */
 struct _OsinfoDeviceDriver
@@ -99,6 +100,7 @@ gboolean osinfo_device_driver_get_pre_installable(OsinfoDeviceDriver *driver);
 GList *osinfo_device_driver_get_files(OsinfoDeviceDriver *driver);
 OsinfoDeviceList *osinfo_device_driver_get_devices(OsinfoDeviceDriver *driver);
 OsinfoDeviceDriverFormat osinfo_device_driver_get_format(OsinfoDeviceDriver *driver);
+gboolean osinfo_device_driver_get_signed(OsinfoDeviceDriver *driver);
 
 #endif /* __OSINFO_DEVICE_DRIVER_H__ */
 /*
diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
index aad5a61..776a4b6 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -1021,6 +1021,7 @@ static OsinfoDeviceDriver *osinfo_loader_driver(OsinfoLoader *loader,
     xmlChar *location = xmlGetProp(root, BAD_CAST OSINFO_DEVICE_DRIVER_PROP_LOCATION);
     xmlChar *preinst = xmlGetProp(root, BAD_CAST OSINFO_DEVICE_DRIVER_PROP_PRE_INSTALLABLE);
     xmlChar *format = xmlGetProp(root, BAD_CAST OSINFO_DEVICE_DRIVER_PROP_FORMAT);
+    xmlChar *is_signed = xmlGetProp(root, BAD_CAST OSINFO_DEVICE_DRIVER_PROP_SIGNED);
 
     OsinfoDeviceDriver *driver = osinfo_device_driver_new(id);
 
@@ -1052,6 +1053,13 @@ static OsinfoDeviceDriver *osinfo_loader_driver(OsinfoLoader *loader,
         xmlFree(format);
     }
 
+    if (is_signed) {
+        osinfo_entity_set_param(OSINFO_ENTITY(driver),
+                                OSINFO_DEVICE_DRIVER_PROP_SIGNED,
+                                (gchar *)is_signed);
+        xmlFree(is_signed);
+    }
+
     gint nnodes = osinfo_loader_nodeset("./*", ctxt, &nodes, err);
     if (error_is_set(err)) {
         g_object_unref(G_OBJECT(driver));
-- 
1.8.1

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo


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

  Powered by Linux