2014-11-05 11:01:09 -05:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
|
|
|
|
/*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
|
* Boston, MA 02110-1301 USA.
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2008 Novell, Inc.
|
2015-05-25 13:55:37 +02:00
|
|
|
* Copyright 2008 - 2010 Red Hat, Inc.
|
|
|
|
|
* Copyright 2015 Red Hat, Inc.
|
2014-11-05 11:01:09 -05:00
|
|
|
*/
|
|
|
|
|
|
2016-02-12 14:44:52 +01:00
|
|
|
#include "nm-default.h"
|
2016-02-19 14:57:48 +01:00
|
|
|
|
2014-11-05 11:01:09 -05:00
|
|
|
#include "nm-vpn-editor-plugin.h"
|
|
|
|
|
|
2015-05-28 22:16:00 +02:00
|
|
|
#include "nm-core-internal.h"
|
|
|
|
|
|
2014-11-05 11:01:09 -05:00
|
|
|
static void nm_vpn_editor_plugin_default_init (NMVpnEditorPluginInterface *iface);
|
|
|
|
|
|
|
|
|
|
G_DEFINE_INTERFACE (NMVpnEditorPlugin, nm_vpn_editor_plugin, G_TYPE_OBJECT)
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_vpn_editor_plugin_default_init (NMVpnEditorPluginInterface *iface)
|
|
|
|
|
{
|
|
|
|
|
/* Properties */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMVpnEditorPlugin:name:
|
|
|
|
|
*
|
|
|
|
|
* Short display name of the VPN plugin.
|
|
|
|
|
*/
|
|
|
|
|
g_object_interface_install_property (iface,
|
|
|
|
|
g_param_spec_string (NM_VPN_EDITOR_PLUGIN_NAME, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMVpnEditorPlugin:description:
|
|
|
|
|
*
|
|
|
|
|
* Longer description of the VPN plugin.
|
|
|
|
|
*/
|
|
|
|
|
g_object_interface_install_property (iface,
|
|
|
|
|
g_param_spec_string (NM_VPN_EDITOR_PLUGIN_DESCRIPTION, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMVpnEditorPlugin:service:
|
|
|
|
|
*
|
|
|
|
|
* D-Bus service name of the plugin's VPN service.
|
|
|
|
|
*/
|
|
|
|
|
g_object_interface_install_property (iface,
|
|
|
|
|
g_param_spec_string (NM_VPN_EDITOR_PLUGIN_SERVICE, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-28 22:16:00 +02:00
|
|
|
/*********************************************************************/
|
|
|
|
|
|
|
|
|
|
NMVpnEditorPlugin *
|
libnm/vpn: allow specifying non-absolute plugin name in VPN .name file
Since commit 3dfbbb227e82b47973f612b6b031d8d591727436, we enforce that
the plugin path in the .name file is absolute and we perform several
checks on the file before loading it (ownership, etc).
Relax that, to also allow libray names without path component.
In that case, g_module_open()/dlopen() will search for a library
in various search paths. This allows, to omit absolute paths
in the .name file. The latter is problematic, because by default
we install the .name file in the architecture independent location
/usr/lib/NetworkManager. As such, it should not contain paths
to architecture dependent libraries. With this change, a .name
file can contain only the library name and it will be loaded
using the usual mechanism.
However, specifying absolute paths is still possible and works
same as before, including checking file permissions.
As such, distributions probably should package the VPN plugins
to have no path in the .name file. On the other hand, a user
compiling from source probably wants to specify an absolute
path. The reason is, that the user probably doesn't build the
plugin for multiple achitectures and that way, he can install
the plugin in a separate (private) prefix.
2016-04-18 18:19:04 +02:00
|
|
|
_nm_vpn_editor_plugin_load (const char *plugin_filename,
|
|
|
|
|
gboolean force_absolute_filename,
|
|
|
|
|
const char *check_service,
|
|
|
|
|
int check_owner,
|
|
|
|
|
NMUtilsCheckFilePredicate check_file,
|
|
|
|
|
gpointer user_data,
|
|
|
|
|
GError **error)
|
2015-05-28 22:16:00 +02:00
|
|
|
{
|
|
|
|
|
GModule *module = NULL;
|
|
|
|
|
gs_free_error GError *local = NULL;
|
|
|
|
|
NMVpnEditorPluginFactory factory = NULL;
|
|
|
|
|
NMVpnEditorPlugin *editor_plugin = NULL;
|
libnm/vpn: allow specifying non-absolute plugin name in VPN .name file
Since commit 3dfbbb227e82b47973f612b6b031d8d591727436, we enforce that
the plugin path in the .name file is absolute and we perform several
checks on the file before loading it (ownership, etc).
Relax that, to also allow libray names without path component.
In that case, g_module_open()/dlopen() will search for a library
in various search paths. This allows, to omit absolute paths
in the .name file. The latter is problematic, because by default
we install the .name file in the architecture independent location
/usr/lib/NetworkManager. As such, it should not contain paths
to architecture dependent libraries. With this change, a .name
file can contain only the library name and it will be loaded
using the usual mechanism.
However, specifying absolute paths is still possible and works
same as before, including checking file permissions.
As such, distributions probably should package the VPN plugins
to have no path in the .name file. On the other hand, a user
compiling from source probably wants to specify an absolute
path. The reason is, that the user probably doesn't build the
plugin for multiple achitectures and that way, he can install
the plugin in a separate (private) prefix.
2016-04-18 18:19:04 +02:00
|
|
|
gboolean search_lib = FALSE;
|
2015-05-28 22:16:00 +02:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (plugin_filename && *plugin_filename, NULL);
|
|
|
|
|
|
libnm/vpn: allow specifying non-absolute plugin name in VPN .name file
Since commit 3dfbbb227e82b47973f612b6b031d8d591727436, we enforce that
the plugin path in the .name file is absolute and we perform several
checks on the file before loading it (ownership, etc).
Relax that, to also allow libray names without path component.
In that case, g_module_open()/dlopen() will search for a library
in various search paths. This allows, to omit absolute paths
in the .name file. The latter is problematic, because by default
we install the .name file in the architecture independent location
/usr/lib/NetworkManager. As such, it should not contain paths
to architecture dependent libraries. With this change, a .name
file can contain only the library name and it will be loaded
using the usual mechanism.
However, specifying absolute paths is still possible and works
same as before, including checking file permissions.
As such, distributions probably should package the VPN plugins
to have no path in the .name file. On the other hand, a user
compiling from source probably wants to specify an absolute
path. The reason is, that the user probably doesn't build the
plugin for multiple achitectures and that way, he can install
the plugin in a separate (private) prefix.
2016-04-18 18:19:04 +02:00
|
|
|
if ( !force_absolute_filename
|
|
|
|
|
&& !strchr (plugin_filename, '/')
|
|
|
|
|
&& !g_str_has_suffix (plugin_filename, ".la")) {
|
|
|
|
|
/* we allow omitting the (absolute) path.
|
|
|
|
|
*
|
|
|
|
|
* If the @plugin_filename contains no '/', we skip any checks
|
|
|
|
|
* for the file and pass it directly to g_module_open()/dlopen().
|
|
|
|
|
* One exception is that we don't allow for the "la" suffix. The
|
|
|
|
|
* reason is that g_module_open() interprets files with this extension
|
|
|
|
|
* special and we don't want that. */
|
|
|
|
|
search_lib = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-20 12:25:24 +02:00
|
|
|
/* _nm_utils_check_module_file() fails with ENOENT if the plugin file
|
|
|
|
|
* does not exist. That is relevant, because nm-applet checks for that. */
|
libnm/vpn: allow specifying non-absolute plugin name in VPN .name file
Since commit 3dfbbb227e82b47973f612b6b031d8d591727436, we enforce that
the plugin path in the .name file is absolute and we perform several
checks on the file before loading it (ownership, etc).
Relax that, to also allow libray names without path component.
In that case, g_module_open()/dlopen() will search for a library
in various search paths. This allows, to omit absolute paths
in the .name file. The latter is problematic, because by default
we install the .name file in the architecture independent location
/usr/lib/NetworkManager. As such, it should not contain paths
to architecture dependent libraries. With this change, a .name
file can contain only the library name and it will be loaded
using the usual mechanism.
However, specifying absolute paths is still possible and works
same as before, including checking file permissions.
As such, distributions probably should package the VPN plugins
to have no path in the .name file. On the other hand, a user
compiling from source probably wants to specify an absolute
path. The reason is, that the user probably doesn't build the
plugin for multiple achitectures and that way, he can install
the plugin in a separate (private) prefix.
2016-04-18 18:19:04 +02:00
|
|
|
if ( search_lib
|
|
|
|
|
|| _nm_utils_check_module_file (plugin_filename,
|
|
|
|
|
check_owner,
|
|
|
|
|
check_file,
|
|
|
|
|
user_data,
|
|
|
|
|
&local))
|
libnm: require exact vpn plugin filename
Originally, nm-applet loaded the vpn plugins by passing the filename
to g_module_open(). Thereby, g_module_open() allowed for missing file
extension and tries to complete the name with a system-dependent suffix.
When porting to libnm, we kept that behavior but did more elaborate
checks on the file, like checking owner and permissions.
Change to no longer trying to append the system suffix, but require
an exact path. That is no usability problem, because the plugin path
is specified in the .name files, and we just require them now to be the
full path (including the .so extension).
Note also, that this only affects new, libnm-based vpn plugins, thus there
is no change in behavior for legacy libnm-glib based plugins.
Fixes: eed0d0c58f7f13638eb587e240737048d729cb68
2015-08-18 11:56:17 +02:00
|
|
|
module = g_module_open (plugin_filename, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
|
2015-05-28 22:16:00 +02:00
|
|
|
|
|
|
|
|
if (!module) {
|
|
|
|
|
if (local) {
|
|
|
|
|
g_propagate_error (error, local);
|
|
|
|
|
local = NULL;
|
libnm/vpn: allow specifying non-absolute plugin name in VPN .name file
Since commit 3dfbbb227e82b47973f612b6b031d8d591727436, we enforce that
the plugin path in the .name file is absolute and we perform several
checks on the file before loading it (ownership, etc).
Relax that, to also allow libray names without path component.
In that case, g_module_open()/dlopen() will search for a library
in various search paths. This allows, to omit absolute paths
in the .name file. The latter is problematic, because by default
we install the .name file in the architecture independent location
/usr/lib/NetworkManager. As such, it should not contain paths
to architecture dependent libraries. With this change, a .name
file can contain only the library name and it will be loaded
using the usual mechanism.
However, specifying absolute paths is still possible and works
same as before, including checking file permissions.
As such, distributions probably should package the VPN plugins
to have no path in the .name file. On the other hand, a user
compiling from source probably wants to specify an absolute
path. The reason is, that the user probably doesn't build the
plugin for multiple achitectures and that way, he can install
the plugin in a separate (private) prefix.
2016-04-18 18:19:04 +02:00
|
|
|
} else if (search_lib) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
G_FILE_ERROR,
|
|
|
|
|
G_FILE_ERROR_NOENT,
|
|
|
|
|
_("Plugin does not exist (%s)"), plugin_filename);
|
2015-05-28 22:16:00 +02:00
|
|
|
} else {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_VPN_PLUGIN_ERROR,
|
|
|
|
|
NM_VPN_PLUGIN_ERROR_FAILED,
|
|
|
|
|
_("cannot load plugin %s"), plugin_filename);
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
g_clear_error (&local);
|
|
|
|
|
|
|
|
|
|
if (g_module_symbol (module, "nm_vpn_editor_plugin_factory", (gpointer) &factory)) {
|
|
|
|
|
gs_free_error GError *factory_error = NULL;
|
|
|
|
|
gboolean success = FALSE;
|
|
|
|
|
|
|
|
|
|
editor_plugin = factory (&factory_error);
|
|
|
|
|
|
|
|
|
|
g_assert (!editor_plugin || G_IS_OBJECT (editor_plugin));
|
|
|
|
|
|
|
|
|
|
if (editor_plugin) {
|
2015-08-21 16:00:37 +02:00
|
|
|
gs_free char *plug_name = NULL, *plug_service = NULL;
|
2015-05-28 22:16:00 +02:00
|
|
|
|
|
|
|
|
/* Validate plugin properties */
|
|
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (editor_plugin),
|
2015-08-21 16:00:37 +02:00
|
|
|
NM_VPN_EDITOR_PLUGIN_NAME, &plug_name,
|
2015-05-28 22:16:00 +02:00
|
|
|
NM_VPN_EDITOR_PLUGIN_SERVICE, &plug_service,
|
|
|
|
|
NULL);
|
|
|
|
|
|
2015-08-21 13:36:11 +02:00
|
|
|
if (!plug_name || !*plug_name) {
|
2015-08-21 16:00:37 +02:00
|
|
|
g_set_error (error,
|
|
|
|
|
NM_VPN_PLUGIN_ERROR,
|
|
|
|
|
NM_VPN_PLUGIN_ERROR_FAILED,
|
2015-08-21 13:36:11 +02:00
|
|
|
_("cannot load VPN plugin in '%s': missing plugin name"),
|
2015-08-21 16:00:37 +02:00
|
|
|
g_module_name (module));
|
|
|
|
|
} else if ( check_service
|
|
|
|
|
&& g_strcmp0 (plug_service, check_service) != 0) {
|
2015-05-28 22:16:00 +02:00
|
|
|
g_set_error (error,
|
|
|
|
|
NM_VPN_PLUGIN_ERROR,
|
|
|
|
|
NM_VPN_PLUGIN_ERROR_FAILED,
|
|
|
|
|
_("cannot load VPN plugin in '%s': invalid service name"),
|
|
|
|
|
g_module_name (module));
|
|
|
|
|
} else {
|
|
|
|
|
/* Success! */
|
|
|
|
|
g_object_set_data_full (G_OBJECT (editor_plugin), "gmodule", module,
|
|
|
|
|
(GDestroyNotify) g_module_close);
|
|
|
|
|
success = TRUE;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (factory_error) {
|
|
|
|
|
g_propagate_error (error, factory_error);
|
|
|
|
|
factory_error = NULL;
|
|
|
|
|
} else {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_VPN_PLUGIN_ERROR,
|
|
|
|
|
NM_VPN_PLUGIN_ERROR_FAILED,
|
|
|
|
|
_("unknown error initializing plugin %s"), plugin_filename);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!success) {
|
|
|
|
|
g_module_close (module);
|
|
|
|
|
editor_plugin = NULL;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_VPN_PLUGIN_ERROR,
|
|
|
|
|
NM_VPN_PLUGIN_ERROR_FAILED,
|
|
|
|
|
_("failed to load nm_vpn_editor_plugin_factory() from %s (%s)"),
|
|
|
|
|
g_module_name (module), g_module_error ());
|
|
|
|
|
g_module_close (module);
|
|
|
|
|
editor_plugin = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return editor_plugin;
|
|
|
|
|
}
|
|
|
|
|
|
libnm/vpn: allow specifying non-absolute plugin name in VPN .name file
Since commit 3dfbbb227e82b47973f612b6b031d8d591727436, we enforce that
the plugin path in the .name file is absolute and we perform several
checks on the file before loading it (ownership, etc).
Relax that, to also allow libray names without path component.
In that case, g_module_open()/dlopen() will search for a library
in various search paths. This allows, to omit absolute paths
in the .name file. The latter is problematic, because by default
we install the .name file in the architecture independent location
/usr/lib/NetworkManager. As such, it should not contain paths
to architecture dependent libraries. With this change, a .name
file can contain only the library name and it will be loaded
using the usual mechanism.
However, specifying absolute paths is still possible and works
same as before, including checking file permissions.
As such, distributions probably should package the VPN plugins
to have no path in the .name file. On the other hand, a user
compiling from source probably wants to specify an absolute
path. The reason is, that the user probably doesn't build the
plugin for multiple achitectures and that way, he can install
the plugin in a separate (private) prefix.
2016-04-18 18:19:04 +02:00
|
|
|
/**
|
|
|
|
|
* nm_vpn_editor_plugin_load_from_file:
|
2016-04-18 18:26:28 +02:00
|
|
|
* @plugin_filename: The path to the shared library to load.
|
libnm/vpn: allow specifying non-absolute plugin name in VPN .name file
Since commit 3dfbbb227e82b47973f612b6b031d8d591727436, we enforce that
the plugin path in the .name file is absolute and we perform several
checks on the file before loading it (ownership, etc).
Relax that, to also allow libray names without path component.
In that case, g_module_open()/dlopen() will search for a library
in various search paths. This allows, to omit absolute paths
in the .name file. The latter is problematic, because by default
we install the .name file in the architecture independent location
/usr/lib/NetworkManager. As such, it should not contain paths
to architecture dependent libraries. With this change, a .name
file can contain only the library name and it will be loaded
using the usual mechanism.
However, specifying absolute paths is still possible and works
same as before, including checking file permissions.
As such, distributions probably should package the VPN plugins
to have no path in the .name file. On the other hand, a user
compiling from source probably wants to specify an absolute
path. The reason is, that the user probably doesn't build the
plugin for multiple achitectures and that way, he can install
the plugin in a separate (private) prefix.
2016-04-18 18:19:04 +02:00
|
|
|
* The path must be an absolute filename to an existing file.
|
|
|
|
|
* @check_service: if not-null, check that the loaded plugin advertises
|
|
|
|
|
* the given service.
|
|
|
|
|
* @check_owner: if non-negative, check whether the file is owned
|
|
|
|
|
* by UID @check_owner or by root. In this case also check that
|
|
|
|
|
* the file is not writable by anybody else.
|
|
|
|
|
* @check_file: (scope call): optional callback to validate the file prior to
|
|
|
|
|
* loading the shared library.
|
|
|
|
|
* @user_data: user data for @check_file
|
|
|
|
|
* @error: on failure the error reason.
|
|
|
|
|
*
|
|
|
|
|
* Load the shared libary @plugin_filename and create a new
|
|
|
|
|
* #NMVpnEditorPlugin instace via the #NMVpnEditorPluginFactory
|
|
|
|
|
* function.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full): a new plugin instance or %NULL on error.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
*/
|
|
|
|
|
NMVpnEditorPlugin *
|
|
|
|
|
nm_vpn_editor_plugin_load_from_file (const char *plugin_filename,
|
|
|
|
|
const char *check_service,
|
|
|
|
|
int check_owner,
|
|
|
|
|
NMUtilsCheckFilePredicate check_file,
|
|
|
|
|
gpointer user_data,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
return _nm_vpn_editor_plugin_load (plugin_filename,
|
|
|
|
|
TRUE,
|
|
|
|
|
check_service,
|
|
|
|
|
check_owner,
|
|
|
|
|
check_file,
|
|
|
|
|
user_data,
|
|
|
|
|
error);
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-18 18:26:28 +02:00
|
|
|
/**
|
|
|
|
|
* nm_vpn_editor_plugin_load:
|
|
|
|
|
* @plugin_name: The name of the shared library to load.
|
|
|
|
|
* If it is an absolute path, for further checks will be
|
|
|
|
|
* performed on the file (aside from being a regular file
|
|
|
|
|
* and existing).
|
|
|
|
|
* The @plugin_name can also be a library name only. In this
|
|
|
|
|
* case, system dependent directories will be searched for a
|
|
|
|
|
* matching library.
|
|
|
|
|
* @check_service: if not-null, check that the loaded plugin advertises
|
|
|
|
|
* the given service.
|
|
|
|
|
* @error: on failure the error reason.
|
|
|
|
|
*
|
|
|
|
|
* Load the shared libary @plugin_filename and create a new
|
|
|
|
|
* #NMVpnEditorPlugin instace via the #NMVpnEditorPluginFactory
|
|
|
|
|
* function.
|
|
|
|
|
*
|
|
|
|
|
* This is similar to nm_vpn_editor_plugin_load_from_file(), but
|
|
|
|
|
* also allows searching for a matching library and not perform
|
|
|
|
|
* any checks on the file. If you have the full path to a plugin
|
|
|
|
|
* file, nm_vpn_editor_plugin_load_from_file() is preferred.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full): a new plugin instance or %NULL on error.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.4
|
|
|
|
|
*/
|
|
|
|
|
NMVpnEditorPlugin *
|
|
|
|
|
nm_vpn_editor_plugin_load (const char *plugin_name,
|
|
|
|
|
const char *check_service,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
return _nm_vpn_editor_plugin_load (plugin_name,
|
|
|
|
|
FALSE,
|
|
|
|
|
check_service,
|
|
|
|
|
-1,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
error);
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-28 22:16:00 +02:00
|
|
|
/*********************************************************************/
|
|
|
|
|
|
2014-11-05 11:01:09 -05:00
|
|
|
/**
|
|
|
|
|
* nm_vpn_editor_plugin_get_editor:
|
2016-01-20 11:25:37 -06:00
|
|
|
* @plugin: the #NMVpnEditorPlugin
|
|
|
|
|
* @connection: the #NMConnection to be edited
|
|
|
|
|
* @error: on return, an error or %NULL
|
2014-11-05 11:01:09 -05:00
|
|
|
*
|
2016-01-20 11:25:37 -06:00
|
|
|
* Returns: (transfer full): a new #NMVpnEditor or %NULL on error
|
2014-11-05 11:01:09 -05:00
|
|
|
*/
|
|
|
|
|
NMVpnEditor *
|
|
|
|
|
nm_vpn_editor_plugin_get_editor (NMVpnEditorPlugin *plugin,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_VPN_EDITOR_PLUGIN (plugin), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_VPN_EDITOR_PLUGIN_GET_INTERFACE (plugin)->get_editor (plugin, connection, error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NMVpnEditorPluginCapability
|
|
|
|
|
nm_vpn_editor_plugin_get_capabilities (NMVpnEditorPlugin *plugin)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_VPN_EDITOR_PLUGIN (plugin), 0);
|
|
|
|
|
|
|
|
|
|
return NM_VPN_EDITOR_PLUGIN_GET_INTERFACE (plugin)->get_capabilities (plugin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_vpn_editor_plugin_import:
|
2016-01-20 11:25:37 -06:00
|
|
|
* @plugin: the #NMVpnEditorPlugin
|
|
|
|
|
* @path: full path to the file to attempt to read into a new #NMConnection
|
|
|
|
|
* @error: on return, an error or %NULL
|
2014-11-05 11:01:09 -05:00
|
|
|
*
|
2016-01-20 11:25:37 -06:00
|
|
|
* Returns: (transfer full): a new #NMConnection imported from @path, or %NULL
|
|
|
|
|
* on error or if the file at @path was not recognized by this plugin
|
2014-11-05 11:01:09 -05:00
|
|
|
*/
|
|
|
|
|
NMConnection *
|
|
|
|
|
nm_vpn_editor_plugin_import (NMVpnEditorPlugin *plugin,
|
|
|
|
|
const char *path,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_VPN_EDITOR_PLUGIN (plugin), NULL);
|
|
|
|
|
|
|
|
|
|
if (nm_vpn_editor_plugin_get_capabilities (plugin) & NM_VPN_EDITOR_PLUGIN_CAPABILITY_IMPORT) {
|
|
|
|
|
g_return_val_if_fail (NM_VPN_EDITOR_PLUGIN_GET_INTERFACE (plugin)->import_from_file != NULL, NULL);
|
|
|
|
|
return NM_VPN_EDITOR_PLUGIN_GET_INTERFACE (plugin)->import_from_file (plugin, path, error);
|
|
|
|
|
}
|
2015-12-07 11:20:14 +01:00
|
|
|
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_VPN_PLUGIN_ERROR,
|
|
|
|
|
NM_VPN_PLUGIN_ERROR_FAILED,
|
|
|
|
|
_("the plugin does not support import capability"));
|
2014-11-05 11:01:09 -05:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
nm_vpn_editor_plugin_export (NMVpnEditorPlugin *plugin,
|
|
|
|
|
const char *path,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_VPN_EDITOR_PLUGIN (plugin), FALSE);
|
|
|
|
|
|
|
|
|
|
if (nm_vpn_editor_plugin_get_capabilities (plugin) & NM_VPN_EDITOR_PLUGIN_CAPABILITY_EXPORT) {
|
|
|
|
|
g_return_val_if_fail (NM_VPN_EDITOR_PLUGIN_GET_INTERFACE (plugin)->export_to_file != NULL, FALSE);
|
|
|
|
|
return NM_VPN_EDITOR_PLUGIN_GET_INTERFACE (plugin)->export_to_file (plugin, path, connection, error);
|
|
|
|
|
}
|
2015-12-07 11:20:14 +01:00
|
|
|
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_VPN_PLUGIN_ERROR,
|
|
|
|
|
NM_VPN_PLUGIN_ERROR_FAILED,
|
|
|
|
|
_("the plugin does not support export capability"));
|
2014-11-05 11:01:09 -05:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
nm_vpn_editor_plugin_get_suggested_filename (NMVpnEditorPlugin *plugin,
|
|
|
|
|
NMConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_VPN_EDITOR_PLUGIN (plugin), NULL);
|
|
|
|
|
|
|
|
|
|
if (NM_VPN_EDITOR_PLUGIN_GET_INTERFACE (plugin)->get_suggested_filename)
|
|
|
|
|
return NM_VPN_EDITOR_PLUGIN_GET_INTERFACE (plugin)->get_suggested_filename (plugin, connection);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|