[NetworkManager-openvpn] properties: drop file extension check when importing a file
- From: Francesco Giudici <fgiudici src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [NetworkManager-openvpn] properties: drop file extension check when importing a file
- Date: Thu, 8 Nov 2018 14:42:28 +0000 (UTC)
commit 8802a1f81604cb3fd366fdbc0bbdef98d3e5fe41
Author: Francesco Giudici <fgiudici redhat com>
Date: Thu Nov 8 12:19:18 2018 +0100
properties: drop file extension check when importing a file
We don't enforce any policy on the file name/extension when
exporting a connection, but we do it when importing one.
So, one could end up exporting a connection succesfully and
not being able to import it back.
Example:
~]$ nmcli connection export ovpn_test pippo.vpn
~]$ nmcli connection import file pippo.vpn type openvpn
Error: failed to import 'pippo.vpn': unknown OpenVPN file extension.
Moreover, when importing, we enforce the user to specify the connection
type (openvpn in this case).
Drop the policy on the file name extension when importing openvpn
connections.
properties/nm-openvpn-editor-plugin.c | 15 ---------------
1 file changed, 15 deletions(-)
---
diff --git a/properties/nm-openvpn-editor-plugin.c b/properties/nm-openvpn-editor-plugin.c
index 223c602..051e43d 100644
--- a/properties/nm-openvpn-editor-plugin.c
+++ b/properties/nm-openvpn-editor-plugin.c
@@ -66,28 +66,13 @@ import (NMVpnEditorPlugin *iface, const char *path, GError **error)
{
NMConnection *connection = NULL;
char *contents = NULL;
- char *ext;
gsize contents_len;
- ext = strrchr (path, '.');
-
- if (!ext || ( !g_str_has_suffix (ext, ".ovpn")
- && !g_str_has_suffix (ext, ".conf")
- && !g_str_has_suffix (ext, ".cnf")
- && !g_str_has_suffix (ext, ".ovpntest"))) { /* Special extension for testcases */
- g_set_error_literal (error,
- NMV_EDITOR_PLUGIN_ERROR,
- NMV_EDITOR_PLUGIN_ERROR_FILE_NOT_VPN,
- _("unknown OpenVPN file extension"));
- goto out;
- }
-
if (!g_file_get_contents (path, &contents, &contents_len, error))
return NULL;
connection = do_import (path, contents, contents_len, error);
-out:
g_free (contents);
return connection;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]