diff options
| author | Sebastien Bacher <seb128@ubuntu.com> | 2018-08-24 11:00:09 +0200 |
|---|---|---|
| committer | Sebastien Bacher <seb128@ubuntu.com> | 2018-08-24 11:06:47 +0200 |
| commit | b7db94545968c37886b7111d8c85f62eb063fbb4 (patch) | |
| tree | 7c2aedd497b1fdcb26bf9d49f98cc63a530baf2e /libnm/nm-vpn-plugin-old.c | |
| parent | 9d5cdc3adde9e7e57bf5a0e754e563b6a9e8e513 (diff) | |
| parent | caf1db9d6fbc056cc6c76a24574890f6c7895f3d (diff) | |
Import Debian changes 1.12.2-0ubuntu3
network-manager (1.12.2-0ubuntu3) cosmic; urgency=medium
* debian/rules:
- use --with-libnm-glib, the default reversed since that's a legacy
library but we still need it for unity-control-center
network-manager (1.12.2-0ubuntu2) cosmic; urgency=medium
* debian/patches/git-newglib-test.patch:
- backport upstream commit to fix the tests with the new glib
network-manager (1.12.2-0ubuntu1) cosmic; urgency=medium
* New upstream version
* d/p/libnm-register-empty-NMClient-and-NetworkManager-when-loa.patch,
d/p/e91f1a7d2a6b8400b6b331d5b72287dcb5164a39.patch,
d/p/git_thunderbolt_connect.patch:
- removed, those changes are in the new version
* Backport Debian changes
* Update symbols file for libnm0
* Enable iwd support
* Drop version requirements when oldstable ships a newer version
* Drop dh_strip override, the dbgsym migration is done
* Rebase patches
* Make sure the example server.conf is actually installed
* Update install path for plugins, it now includes a version number
* Drop libnl3 build dependency.
Upstream has copied the code directly from libnl3 for the few functions it
needs with a few small modifications.
* Drop libiw build dependency.
Hasn't been needed for a long time and was simply a left over from older
releases.
* Bump Standards-Version to 4.1.5
* Fix compile error due to NM_AVAILABLE_IN_1_12_2 macro (Closes: #905372)
Diffstat (limited to 'libnm/nm-vpn-plugin-old.c')
| -rw-r--r-- | libnm/nm-vpn-plugin-old.c | 124 |
1 files changed, 3 insertions, 121 deletions
diff --git a/libnm/nm-vpn-plugin-old.c b/libnm/nm-vpn-plugin-old.c index 897f6d40..bfafc7b7 100644 --- a/libnm/nm-vpn-plugin-old.c +++ b/libnm/nm-vpn-plugin-old.c @@ -33,6 +33,7 @@ #include "nm-dbus-helpers.h" #include "nm-core-internal.h" #include "nm-simple-connection.h" +#include "nm-vpn-service-plugin.h" #include "introspection/org.freedesktop.NetworkManager.VPN.Plugin.h" @@ -93,7 +94,6 @@ enum { static GSList *active_plugins = NULL; - static void nm_vpn_plugin_old_set_connection (NMVpnPluginOld *plugin, GDBusConnection *connection) @@ -683,20 +683,6 @@ nm_vpn_plugin_old_secrets_required (NMVpnPluginOld *plugin, /*****************************************************************************/ -#define DATA_KEY_TAG "DATA_KEY=" -#define DATA_VAL_TAG "DATA_VAL=" -#define SECRET_KEY_TAG "SECRET_KEY=" -#define SECRET_VAL_TAG "SECRET_VAL=" - -static void -free_secret (gpointer data) -{ - char *secret = data; - - memset (secret, 0, strlen (secret)); - g_free (secret); -} - /** * nm_vpn_plugin_old_read_vpn_details: * @fd: file descriptor to read from, usually stdin (0) @@ -717,87 +703,7 @@ nm_vpn_plugin_old_read_vpn_details (int fd, GHashTable **out_data, GHashTable **out_secrets) { - GHashTable *data, *secrets; - gboolean success = FALSE; - char *key = NULL, *val = NULL; - GString *line; - gchar c; - - if (out_data) - g_return_val_if_fail (*out_data == NULL, FALSE); - if (out_secrets) - g_return_val_if_fail (*out_secrets == NULL, FALSE); - - data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); - secrets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_secret); - - line = g_string_new (NULL); - - /* Read stdin for data and secret items until we get a DONE */ - while (1) { - ssize_t nr; - GHashTable *hash = NULL; - - errno = 0; - nr = read (fd, &c, 1); - if (nr == -1) { - if (errno == EAGAIN) { - g_usleep (100); - continue; - } - break; - } - - if (c != '\n') { - g_string_append_c (line, c); - continue; - } - - /* Check for the finish marker */ - if (strcmp (line->str, "DONE") == 0) - break; - - /* Otherwise it's a data/secret item */ - if (strncmp (line->str, DATA_KEY_TAG, strlen (DATA_KEY_TAG)) == 0) { - hash = data; - key = g_strdup (line->str + strlen (DATA_KEY_TAG)); - } else if (strncmp (line->str, DATA_VAL_TAG, strlen (DATA_VAL_TAG)) == 0) { - hash = data; - val = g_strdup (line->str + strlen (DATA_VAL_TAG)); - } else if (strncmp (line->str, SECRET_KEY_TAG, strlen (SECRET_KEY_TAG)) == 0) { - hash = secrets; - key = g_strdup (line->str + strlen (SECRET_KEY_TAG)); - } else if (strncmp (line->str, SECRET_VAL_TAG, strlen (SECRET_VAL_TAG)) == 0) { - hash = secrets; - val = g_strdup (line->str + strlen (SECRET_VAL_TAG)); - } - g_string_truncate (line, 0); - - if (key && val && hash) { - g_hash_table_insert (hash, key, val); - key = NULL; - val = NULL; - success = TRUE; /* Got at least one value */ - } - } - - if (success) { - if (out_data) - *out_data = data; - else - g_hash_table_destroy (data); - - if (out_secrets) - *out_secrets = secrets; - else - g_hash_table_destroy (secrets); - } else { - g_hash_table_destroy (data); - g_hash_table_destroy (secrets); - } - - g_string_free (line, TRUE); - return success; + return nm_vpn_service_plugin_read_vpn_details (fd, out_data, out_secrets); } /** @@ -820,31 +726,7 @@ nm_vpn_plugin_old_get_secret_flags (GHashTable *data, const char *secret_name, NMSettingSecretFlags *out_flags) { - char *flag_name; - const char *val; - unsigned long tmp; - gboolean success = FALSE; - - g_return_val_if_fail (data != NULL, FALSE); - g_return_val_if_fail (secret_name != NULL, FALSE); - g_return_val_if_fail (out_flags != NULL, FALSE); - g_return_val_if_fail (*out_flags == NM_SETTING_SECRET_FLAG_NONE, FALSE); - - flag_name = g_strdup_printf ("%s-flags", secret_name); - - /* Try new flags value first */ - val = g_hash_table_lookup (data, flag_name); - if (val) { - errno = 0; - tmp = strtoul (val, NULL, 10); - if (errno == 0 && tmp <= NM_SETTING_SECRET_FLAGS_ALL) { - *out_flags = (NMSettingSecretFlags) tmp; - success = TRUE; - } - } - - g_free (flag_name); - return success; + return nm_vpn_service_plugin_get_secret_flags (data, secret_name, out_flags); } /*****************************************************************************/ |