mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 01:47:58 +02:00
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.
This commit is contained in:
parent
ad7cdfc766
commit
1889e9c568
2 changed files with 17 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue