On error clear the passphrase without saving it permanently. This makes
it safe to reuse the passphrase checking function elsewhere as there
will not be any unintended side effects when the service is favorite.
---
src/service.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/src/service.c b/src/service.c
index f5c0a23..8131093 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2828,16 +2828,8 @@ static int check_passphrase(struct connman_service
*service,
guint i;
gsize length;
- if (!passphrase) {
- /*
- * This will prevent __connman_service_set_passphrase() to
- * wipe the passphrase out in case of -ENOKEY error for a
- * favorite service. */
- if (service->favorite)
- return 1;
- else
- return 0;
- }
+ if (!passphrase)
+ return 0;
length = strlen(passphrase);
@@ -2878,6 +2870,16 @@ static int check_passphrase(struct connman_service
*service,
return 0;
}
+static void service_clear_passphrase(struct connman_service *service)
+{
+ g_free(service->passphrase);
+ service->passphrase = NULL;
+
+ if (service->network)
+ connman_network_set_string(service->network, "WiFi.Passphrase",
+ service->passphrase);
+}
+
int __connman_service_set_passphrase(struct connman_service *service,
const char *passphrase)
{
@@ -5485,7 +5487,7 @@ int __connman_service_indicate_error(struct
connman_service *service,
*/
if (service->error == CONNMAN_SERVICE_ERROR_INVALID_KEY ||
service->security == CONNMAN_SERVICE_SECURITY_8021X)
- __connman_service_set_passphrase(service, NULL);
+ service_clear_passphrase(service);
__connman_service_set_agent_identity(service, NULL);
--
1.9.1
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman