From e217ec040d04835450c2de92cd2cf408e22f3fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8D=C3=B1igo=20Huguet?= Date: Wed, 29 May 2024 16:50:10 +0200 Subject: [PATCH] libnmc: don't strip prefix tags from secret names The daemon is now capable of understanding and removing these prefix tags by itself. It is better than this is not a responsibility of the secret agent because it requires changes in all secret agents to work properly (see https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1536). If the secret agent knows what these prefix tags are, it can remove them only in the text that is displayed in the UI, but maintaining the original string as the secret name that is returned to the daemon. Secret agents that doesn't know what these prefix tags are won't do anything with them, and they will also return the same string as secret name, as expected. The only drawback is that they might display the full string to the user, which is not a nice UX but it will at least work. Also, allow to translate the secret name for the UI in libnmc. (cherry picked from commit 18240bb72d191c987afe150d3a5023fe79d994dd) --- src/libnmc-base/nm-secret-agent-simple.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libnmc-base/nm-secret-agent-simple.c b/src/libnmc-base/nm-secret-agent-simple.c index 4bb77c9802..9d1a2ae962 100644 --- a/src/libnmc-base/nm-secret-agent-simple.c +++ b/src/libnmc-base/nm-secret-agent-simple.c @@ -431,7 +431,7 @@ add_vpn_secrets(RequestData *request, GPtrArray *secrets, char **msg) const NmcVpnPasswordName *p; const char *vpn_msg = NULL; char **iter; - char *secret_name; + char *ui_name; bool is_challenge = FALSE; bool force_echo; @@ -442,19 +442,19 @@ add_vpn_secrets(RequestData *request, GPtrArray *secrets, char **msg) vpn_msg = &(*iter)[NM_STRLEN(NM_SECRET_TAG_VPN_MSG)]; } else { if (NM_STR_HAS_PREFIX(*iter, NM_SECRET_TAG_DYNAMIC_CHALLENGE)) { - secret_name = &(*iter)[NM_STRLEN(NM_SECRET_TAG_DYNAMIC_CHALLENGE)]; + ui_name = &(*iter)[NM_STRLEN(NM_SECRET_TAG_DYNAMIC_CHALLENGE)]; is_challenge = TRUE; force_echo = FALSE; } else if (NM_STR_HAS_PREFIX(*iter, NM_SECRET_TAG_DYNAMIC_CHALLENGE_ECHO)) { - secret_name = &(*iter)[NM_STRLEN(NM_SECRET_TAG_DYNAMIC_CHALLENGE_ECHO)]; + ui_name = &(*iter)[NM_STRLEN(NM_SECRET_TAG_DYNAMIC_CHALLENGE_ECHO)]; is_challenge = TRUE; force_echo = TRUE; } else { - secret_name = *iter; - force_echo = FALSE; + ui_name = *iter; + force_echo = FALSE; } - add_vpn_secret_helper(secrets, s_vpn, secret_name, secret_name, force_echo); + add_vpn_secret_helper(secrets, s_vpn, *iter, ui_name, force_echo); } } }