[Libosinfo] [v2 4/8] API to query signed status of device drivers

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Sun Feb 10 16:41:05 UTC 2013


From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>

Some OS 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 042ba53..96b31a7 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 5a61e93..70202f5 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_entity_get_param_value_enum_list;
 	osinfo_install_script_get_pre_install_driver_formats;
 	osinfo_install_script_get_post_install_driver_formats;
diff --git a/osinfo/osinfo_device_driver.c b/osinfo/osinfo_device_driver.c
index da525cf..5c31300 100644
--- a/osinfo/osinfo_device_driver.c
+++ b/osinfo/osinfo_device_driver.c
@@ -179,6 +179,22 @@ void osinfo_device_driver_add_device(OsinfoDeviceDriver *driver,
                     OSINFO_ENTITY(device));
 }
 
+/**
+ * osinfo_device_driver_get_signed:
+ * @driver: an #OsinfoDeviceDriver instance
+ *
+ * Some OS 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 dae3f97..8c2553b 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
@@ -103,6 +104,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 0c9cc0b..e467099 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -1037,6 +1037,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);
 
@@ -1068,6 +1069,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.2




More information about the Libosinfo mailing list