summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-08-20 12:25:24 +0200
committerThomas Haller <thaller@redhat.com>2015-08-20 12:42:20 +0200
commit1889e9c568c140ac952c0aaeb51a291fee658841 (patch)
tree773c6e44e43533db5c04da2cfe8de697ebac0ccb
parentad7cdfc76678512988869607b0b614217f32903a (diff)
downloadNetworkManager-1889e9c568c140ac952c0aaeb51a291fee658841.tar.gz
libnm/vpn: set special error code when loading vpn plugin fails due to missing file
VPN plugins are usually split into different packages. It might be that the plugin file is simply not installed. We want the caller to be able to recognize that conditation to fail gracefully. Thus return a certain error code.
-rw-r--r--libnm-core/nm-utils.c17
-rw-r--r--libnm-core/nm-vpn-editor-plugin.c2
2 files changed, 17 insertions, 2 deletions
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
index 8b44a32bc8..70777ae379 100644
--- a/libnm-core/nm-utils.c
+++ b/libnm-core/nm-utils.c
@@ -2516,12 +2516,25 @@ _nm_utils_check_module_file (const char *name,
return FALSE;
}
- /* check whether we have a readable file right away */
+ /* Set special error code if the file doesn't exist.
+ * The VPN package might be split into separate packages,
+ * so it could be correct that the plugin file is missing.
+ *
+ * Note that nm-applet checks for this error code to fail
+ * gracefully. */
+ if (!g_file_test (name, G_FILE_TEST_EXISTS)) {
+ g_set_error (error,
+ G_FILE_ERROR,
+ G_FILE_ERROR_NOENT,
+ _("Plugin file does not exist (%s)"), name);
+ return FALSE;
+ }
+
if (!g_file_test (name, G_FILE_TEST_IS_REGULAR)) {
g_set_error (error,
NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_FAILED,
- _("could not find plugin (%s)"), name);
+ _("Plugin is not a valid file (%s)"), name);
return FALSE;
}
diff --git a/libnm-core/nm-vpn-editor-plugin.c b/libnm-core/nm-vpn-editor-plugin.c
index 80200f41a8..5657d17320 100644
--- a/libnm-core/nm-vpn-editor-plugin.c
+++ b/libnm-core/nm-vpn-editor-plugin.c
@@ -119,6 +119,8 @@ nm_vpn_editor_plugin_load_from_file (const char *plugin_filename,
g_return_val_if_fail (plugin_filename && *plugin_filename, NULL);
+ /* _nm_utils_check_module_file() fails with ENOENT if the plugin file
+ * does not exist. That is relevant, because nm-applet checks for that. */
if (_nm_utils_check_module_file (plugin_filename,
check_owner,
check_file,