Query identity/passphrase if one of them is empty, rather than
depending on service immutability. Do not cache agent provided
credentials in service struct (ask them every time user wants to
connect).
---
src/service.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 49 insertions(+), 5 deletions(-)
diff --git a/src/service.c b/src/service.c
index f18cd33..10fc887 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2028,7 +2028,8 @@ void __connman_service_set_pac(struct connman_service
*service,
void __connman_service_set_identity(struct connman_service *service,
const char *identity)
{
- if (service->immutable)
+ /* Allow setting immutable identy that is left empty */
+ if (service->immutable == TRUE && service->identity != NULL)
return;
g_free(service->identity);
@@ -2043,7 +2044,8 @@ void __connman_service_set_identity(struct
connman_service *service,
void __connman_service_set_passphrase(struct connman_service *service,
const char* passphrase)
{
- if (service->immutable == TRUE)
+ /* Allow setting immutable passphrase that is left empty */
+ if (service->immutable == TRUE && service->passphrase != NULL)
return;
g_free(service->passphrase);
@@ -2714,18 +2716,59 @@ static void request_input_cb (struct connman_service
*service,
const char *identity, const char *passphrase,
void *user_data)
{
+ connman_bool_t identity_altered = FALSE, passphrase_altered = FALSE;
+
DBG ("RequestInput return, %p", service);
if (identity == NULL && passphrase == NULL && service->wps == FALSE)
return;
- if (identity != NULL)
+ if (identity != NULL) {
+ if (service->immutable == FALSE || service->identity == NULL)
+ identity_altered = TRUE;
+
__connman_service_set_identity(service, identity);
+ }
+
+ if (passphrase != NULL) {
+ if (service->immutable == FALSE || service->passphrase == NULL)
+ passphrase_altered = TRUE;
- if (passphrase != NULL)
__connman_service_set_passphrase(service, passphrase);
+ }
__connman_service_connect(service);
+
+ /*
+ * Do not cache agent provided identity/passphrase into service
+ * struct; we want to ask them every time user wants to connect.
+ *
+ * Note: we need to bypass immutability here.
+ */
+
+ if (identity_altered) {
+ g_free(service->identity);
+ service->identity = NULL;
+
+ if (service->network != NULL)
+ connman_network_set_string(service->network,
+ "WiFi.Identity",
+ service->identity);
+ }
+
+ if (passphrase_altered) {
+ g_free(service->passphrase);
+ service->passphrase = NULL;
+
+ passphrase_changed(service);
+
+ if (service->network != NULL)
+ connman_network_set_string(service->network,
+ "WiFi.Passphrase",
+ service->passphrase);
+
+ __connman_storage_save_service(service);
+ }
}
static DBusMessage *connect_service(DBusConnection *conn,
@@ -3816,7 +3859,8 @@ static int service_connect(struct connman_service
*service)
if (g_str_equal(service->eap, "tls") == TRUE)
break;
- if (service->immutable != TRUE)
+ if (service->identity == NULL ||
+ service->passphrase == NULL)
return -ENOKEY;
break;
--
1.7.0.4
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman