55fc26
From e31199054797ca8de62d9d1f32a46a58f2211159 Mon Sep 17 00:00:00 2001
55fc26
From: Vojtech Trefny <vtrefny@redhat.com>
55fc26
Date: Wed, 4 Oct 2017 09:24:08 +0200
55fc26
Subject: [PATCH] Use new libblockdev functionality to disable checks during
55fc26
 init
55fc26
55fc26
Loading a plugin shouldn't fail because one of its runtime
55fc26
dependecies is missing. Libblockdev can now skip dependency checks
55fc26
during init and only return an error if the dependency is still
55fc26
missing when a function that needs it is called.
55fc26
---
55fc26
 src/udisksdaemon.c | 35 ++++++++++++++++++++++-------------
55fc26
 1 file changed, 22 insertions(+), 13 deletions(-)
55fc26
55fc26
diff --git a/src/udisksdaemon.c b/src/udisksdaemon.c
55fc26
index a15e5c42..9a013ec9 100644
55fc26
--- a/src/udisksdaemon.c
55fc26
+++ b/src/udisksdaemon.c
55fc26
@@ -263,27 +263,36 @@ udisks_daemon_constructed (GObject *object)
55fc26
   BDPluginSpec **plugin_p = NULL;
55fc26
   error = NULL;
55fc26
 
55fc26
-  ret = bd_try_init (plugins, NULL, NULL, &error);
55fc26
+  /* Skip runtime dependency checks when initializing libblockdev. Plugin
55fc26
+     shouldn't fail to load just because some if its dependencies is missing.
55fc26
+   */
55fc26
+  ret = bd_switch_init_checks (FALSE, &error);
55fc26
   if (!ret)
55fc26
-  {
55fc26
-    if (error)
55fc26
     {
55fc26
       udisks_error ("Error initializing libblockdev library: %s (%s, %d)",
55fc26
                     error->message, g_quark_to_string (error->domain), error->code);
55fc26
       g_clear_error (&error);
55fc26
     }
55fc26
-    else
55fc26
+
55fc26
+  ret = bd_try_init (plugins, NULL, NULL, &error);
55fc26
+  if (!ret)
55fc26
     {
55fc26
-      /* a missing plugin is okay, calling functions from it will fail, but
55fc26
-         until that happens, life will just be great */
55fc26
-      for (plugin_p=plugins; *plugin_p; plugin_p++)
55fc26
-        if (!bd_is_plugin_available ((*plugin_p)->name))
55fc26
-          /* TODO: log plugin names when the function below is available */
55fc26
-          /* udisks_warning ("Failed to load the '%s' libblockdev plugin", */
55fc26
-          /*                 bd_get_plugin_name ((*plugin_p)->name)); */
55fc26
-          udisks_warning ("Failed to load a libblockdev plugin");
55fc26
+      if (error)
55fc26
+        {
55fc26
+          udisks_error ("Error initializing libblockdev library: %s (%s, %d)",
55fc26
+                        error->message, g_quark_to_string (error->domain), error->code);
55fc26
+          g_clear_error (&error);
55fc26
+        }
55fc26
+    else
55fc26
+      {
55fc26
+        /* a missing plugin is okay, calling functions from it will fail, but
55fc26
+           until that happens, life will just be great */
55fc26
+        for (plugin_p=plugins; *plugin_p; plugin_p++)
55fc26
+          if (!bd_is_plugin_available ((*plugin_p)->name))
55fc26
+            udisks_warning ("Failed to load the '%s' libblockdev plugin",
55fc26
+                            bd_get_plugin_name ((*plugin_p)->name));
55fc26
+      }
55fc26
     }
55fc26
-  }
55fc26
 
55fc26
   daemon->authority = polkit_authority_get_sync (NULL, &error);
55fc26
   if (daemon->authority == NULL)