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