|
|
2804ca |
From 948a03d2a28dae7bb975f6e64dc7b5a31f10d5b9 Mon Sep 17 00:00:00 2001
|
|
|
2804ca |
From: Thomas Haller <thaller@redhat.com>
|
|
|
2804ca |
Date: Fri, 14 Sep 2018 11:13:05 +0200
|
|
|
2804ca |
Subject: [PATCH 1/1] cli: fix reading "vpn.secrets.*" from passwd-file
|
|
|
2804ca |
|
|
|
2804ca |
Due to a bug, we required VPN secrets to be prefixed with
|
|
|
2804ca |
"vpn.secret." instead of "vpn.secrets.". This was a change
|
|
|
2804ca |
in behavior with 1.12.0 release.
|
|
|
2804ca |
|
|
|
2804ca |
Fix it, to restore the old behavior. For backward compatibility
|
|
|
2804ca |
to the broken behavior, adjust parse_passwords() to treat accept
|
|
|
2804ca |
that as well.
|
|
|
2804ca |
|
|
|
2804ca |
https://bugzilla.redhat.com/show_bug.cgi?id=1628833
|
|
|
2804ca |
https://github.com/NetworkManager/NetworkManager/pull/201
|
|
|
2804ca |
|
|
|
2804ca |
Fixes: 0601b5d725b072bd3ce4ec60be867898a16f85cd
|
|
|
2804ca |
(cherry picked from commit 5815ae8c60961f088e4e54b41ddf8254cb83574a)
|
|
|
2804ca |
(cherry picked from commit 6bfab6796f064c4f878e05476a60cd59fa8bf11e)
|
|
|
2804ca |
(cherry picked from commit 10888abe96fedd3d6c5b99faea76465522f8e8e9)
|
|
|
2804ca |
---
|
|
|
2804ca |
clients/cli/common.c | 6 +++---
|
|
|
2804ca |
clients/cli/connections.c | 10 +++++++++-
|
|
|
2804ca |
clients/common/nm-secret-agent-simple.c | 2 +-
|
|
|
2804ca |
clients/common/nm-secret-agent-simple.h | 2 +-
|
|
|
2804ca |
clients/tui/nmtui-connect.c | 6 +++---
|
|
|
2804ca |
5 files changed, 17 insertions(+), 9 deletions(-)
|
|
|
2804ca |
|
|
|
2804ca |
diff --git a/clients/cli/common.c b/clients/cli/common.c
|
|
|
2804ca |
index 09c86334a..4aea0d5b2 100644
|
|
|
2804ca |
--- a/clients/cli/common.c
|
|
|
2804ca |
+++ b/clients/cli/common.c
|
|
|
2804ca |
@@ -630,13 +630,13 @@ vpn_openconnect_get_secrets (NMConnection *connection, GPtrArray *secrets)
|
|
|
2804ca |
if (!nm_streq0 (secret->vpn_type, NM_SECRET_AGENT_VPN_TYPE_OPENCONNECT))
|
|
|
2804ca |
continue;
|
|
|
2804ca |
|
|
|
2804ca |
- if (nm_streq0 (secret->entry_id, NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRET "cookie")) {
|
|
|
2804ca |
+ if (nm_streq0 (secret->entry_id, NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRETS "cookie")) {
|
|
|
2804ca |
g_free (secret->value);
|
|
|
2804ca |
secret->value = g_steal_pointer (&cookie);
|
|
|
2804ca |
- } else if (nm_streq0 (secret->entry_id, NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRET "gateway")) {
|
|
|
2804ca |
+ } else if (nm_streq0 (secret->entry_id, NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRETS "gateway")) {
|
|
|
2804ca |
g_free (secret->value);
|
|
|
2804ca |
secret->value = g_steal_pointer (&gateway);
|
|
|
2804ca |
- } else if (nm_streq0 (secret->entry_id, NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRET "gwcert")) {
|
|
|
2804ca |
+ } else if (nm_streq0 (secret->entry_id, NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRETS "gwcert")) {
|
|
|
2804ca |
g_free (secret->value);
|
|
|
2804ca |
secret->value = g_steal_pointer (&gwcert);
|
|
|
2804ca |
}
|
|
|
2804ca |
diff --git a/clients/cli/connections.c b/clients/cli/connections.c
|
|
|
2804ca |
index 1563178de..b547e34ca 100644
|
|
|
2804ca |
--- a/clients/cli/connections.c
|
|
|
2804ca |
+++ b/clients/cli/connections.c
|
|
|
2804ca |
@@ -2565,7 +2565,15 @@ parse_passwords (const char *passwd_file, GError **error)
|
|
|
2804ca |
return NULL;
|
|
|
2804ca |
}
|
|
|
2804ca |
|
|
|
2804ca |
- pwd_spec = g_strdup_printf ("%s.%s", setting, prop);
|
|
|
2804ca |
+ if ( nm_streq (setting, "vpn")
|
|
|
2804ca |
+ && g_str_has_prefix (prop, "secret.")) {
|
|
|
2804ca |
+ /* in 1.12.0, we wrongly required the VPN secrets to be named
|
|
|
2804ca |
+ * "vpn.secret". It should be "vpn.secrets". Work around it
|
|
|
2804ca |
+ * (rh#1628833). */
|
|
|
2804ca |
+ pwd_spec = g_strdup_printf ("vpn.secrets.%s", &prop[NM_STRLEN ("secret.")]);
|
|
|
2804ca |
+ } else
|
|
|
2804ca |
+ pwd_spec = g_strdup_printf ("%s.%s", setting, prop);
|
|
|
2804ca |
+
|
|
|
2804ca |
g_hash_table_insert (pwds_hash, pwd_spec, g_strdup (pwd));
|
|
|
2804ca |
}
|
|
|
2804ca |
return g_steal_pointer (&pwds_hash);
|
|
|
2804ca |
diff --git a/clients/common/nm-secret-agent-simple.c b/clients/common/nm-secret-agent-simple.c
|
|
|
2804ca |
index 0856b51ff..3df8c0386 100644
|
|
|
2804ca |
--- a/clients/common/nm-secret-agent-simple.c
|
|
|
2804ca |
+++ b/clients/common/nm-secret-agent-simple.c
|
|
|
2804ca |
@@ -195,7 +195,7 @@ nm_secret_agent_simple_secret_new (NMSecretAgentSecretType secret_type,
|
|
|
2804ca |
real->base.is_secret = (secret_type != NM_SECRET_AGENT_SECRET_TYPE_PROPERTY);
|
|
|
2804ca |
break;
|
|
|
2804ca |
case NM_SECRET_AGENT_SECRET_TYPE_VPN_SECRET:
|
|
|
2804ca |
- vpn_prefix = NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRET;
|
|
|
2804ca |
+ vpn_prefix = NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRETS;
|
|
|
2804ca |
value = nm_setting_vpn_get_secret (NM_SETTING_VPN (setting), property);
|
|
|
2804ca |
real->base.entry_id = g_strdup_printf ("%s%s", vpn_prefix, property);
|
|
|
2804ca |
nm_assert (vpn_type);
|
|
|
2804ca |
diff --git a/clients/common/nm-secret-agent-simple.h b/clients/common/nm-secret-agent-simple.h
|
|
|
2804ca |
index 505987dfd..529aaeaca 100644
|
|
|
2804ca |
--- a/clients/common/nm-secret-agent-simple.h
|
|
|
2804ca |
+++ b/clients/common/nm-secret-agent-simple.h
|
|
|
2804ca |
@@ -56,7 +56,7 @@ typedef struct {
|
|
|
2804ca |
gboolean is_secret;
|
|
|
2804ca |
} NMSecretAgentSimpleSecret;
|
|
|
2804ca |
|
|
|
2804ca |
-#define NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRET "vpn.secret."
|
|
|
2804ca |
+#define NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRETS "vpn.secrets."
|
|
|
2804ca |
|
|
|
2804ca |
#define NM_SECRET_AGENT_VPN_TYPE_OPENCONNECT NM_DBUS_INTERFACE".openconnect"
|
|
|
2804ca |
|
|
|
2804ca |
diff --git a/clients/tui/nmtui-connect.c b/clients/tui/nmtui-connect.c
|
|
|
2804ca |
index 2a954fb8c..6f29e13e9 100644
|
|
|
2804ca |
--- a/clients/tui/nmtui-connect.c
|
|
|
2804ca |
+++ b/clients/tui/nmtui-connect.c
|
|
|
2804ca |
@@ -121,13 +121,13 @@ secrets_requested (NMSecretAgentSimple *agent,
|
|
|
2804ca |
continue;
|
|
|
2804ca |
if (!nm_streq0 (secret->vpn_type, NM_SECRET_AGENT_VPN_TYPE_OPENCONNECT))
|
|
|
2804ca |
continue;
|
|
|
2804ca |
- if (nm_streq0 (secret->entry_id, NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRET "cookie")) {
|
|
|
2804ca |
+ if (nm_streq0 (secret->entry_id, NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRETS "cookie")) {
|
|
|
2804ca |
g_free (secret->value);
|
|
|
2804ca |
secret->value = g_steal_pointer (&cookie);
|
|
|
2804ca |
- } else if (nm_streq0 (secret->entry_id, NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRET "gateway")) {
|
|
|
2804ca |
+ } else if (nm_streq0 (secret->entry_id, NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRETS "gateway")) {
|
|
|
2804ca |
g_free (secret->value);
|
|
|
2804ca |
secret->value = g_steal_pointer (&gateway);
|
|
|
2804ca |
- } else if (nm_streq0 (secret->entry_id, NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRET "gwcert")) {
|
|
|
2804ca |
+ } else if (nm_streq0 (secret->entry_id, NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRETS "gwcert")) {
|
|
|
2804ca |
g_free (secret->value);
|
|
|
2804ca |
secret->value = g_steal_pointer (&gwcert);
|
|
|
2804ca |
}
|
|
|
2804ca |
--
|
|
|
2804ca |
2.17.1
|
|
|
2804ca |
|