summaryrefslogtreecommitdiff
path: root/src/nmcli/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nmcli/common.c')
-rw-r--r--src/nmcli/common.c49
1 files changed, 2 insertions, 47 deletions
diff --git a/src/nmcli/common.c b/src/nmcli/common.c
index f31d09872d..fcf1ed81d0 100644
--- a/src/nmcli/common.c
+++ b/src/nmcli/common.c
@@ -635,12 +635,6 @@ vpn_openconnect_get_secrets(NMConnection *connection, GPtrArray *secrets)
{
GError *error = NULL;
NMSettingVpn *s_vpn;
- const char *gw, *port;
- gs_free char *cookie = NULL;
- gs_free char *gateway = NULL;
- gs_free char *gwcert = NULL;
- int status = 0;
- int i;
gboolean ret;
if (!connection)
@@ -653,54 +647,15 @@ vpn_openconnect_get_secrets(NMConnection *connection, GPtrArray *secrets)
if (!nm_streq0(nm_setting_vpn_get_service_type(s_vpn), NM_SECRET_AGENT_VPN_TYPE_OPENCONNECT))
return FALSE;
- /* Get gateway and port */
- gw = nm_setting_vpn_get_data_item(s_vpn, "gateway");
- port = gw ? strrchr(gw, ':') : NULL;
-
/* Interactively authenticate to OpenConnect server and get secrets */
- ret = nm_vpn_openconnect_authenticate_helper(gw, &cookie, &gateway, &gwcert, &status, &error);
+ ret = nm_vpn_openconnect_authenticate_helper(s_vpn, secrets, &error);
+
if (!ret) {
nmc_printerr(_("Error: openconnect failed: %s\n"), error->message);
g_clear_error(&error);
return FALSE;
}
- if (WIFEXITED(status)) {
- if (WEXITSTATUS(status) != 0)
- nmc_printerr(_("Error: openconnect failed with status %d\n"), WEXITSTATUS(status));
- } else if (WIFSIGNALED(status))
- nmc_printerr(_("Error: openconnect failed with signal %d\n"), WTERMSIG(status));
-
- /* Append port to the host value */
- if (gateway && port) {
- gs_free char *tmp = gateway;
-
- gateway = g_strdup_printf("%s%s", tmp, port);
- }
-
- /* Fill secrets to the array */
- for (i = 0; i < secrets->len; i++) {
- NMSecretAgentSimpleSecret *secret = secrets->pdata[i];
-
- if (secret->secret_type != NM_SECRET_AGENT_SECRET_TYPE_VPN_SECRET)
- continue;
- if (!nm_streq0(secret->vpn_type, NM_SECRET_AGENT_VPN_TYPE_OPENCONNECT))
- continue;
-
- if (nm_streq0(secret->entry_id, NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRETS "cookie")) {
- g_free(secret->value);
- secret->value = g_steal_pointer(&cookie);
- } else if (nm_streq0(secret->entry_id,
- NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRETS "gateway")) {
- g_free(secret->value);
- secret->value = g_steal_pointer(&gateway);
- } else if (nm_streq0(secret->entry_id,
- NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRETS "gwcert")) {
- g_free(secret->value);
- secret->value = g_steal_pointer(&gwcert);
- }
- }
-
return TRUE;
}