When a wifi service is saved with invalid-key as last error, the default
behavior of connman when it reloads the service is that it does not
automatically reconnects to this service. This behavior can be overruled
with the IgnoreInvalidKey configuration option.
---
 doc/connman.conf.5 |  5 +++++
 src/main.c         | 16 +++++++++++++++-
 src/service.c      |  4 ++--
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/doc/connman.conf.5 b/doc/connman.conf.5
index 626edfd..bf2a1f7 100644
--- a/doc/connman.conf.5
+++ b/doc/connman.conf.5
@@ -126,5 +126,10 @@ really know what you are doing.
 Restore earlier tethering status when returning from offline mode,
 re-enabling a technology, and after restarts and reboots.
 Default value is false.
+.TP
+.B IgnoreInvalidKey=\fPtrue|false\fP
+When set to true, connman ignores previously stored invalid-key errors
+when connecting to a wifi service. 
+Default value is false.
 .SH "SEE ALSO"
 .BR Connman (8)
diff --git a/src/main.c b/src/main.c
index 7cf6c9a..3fda187 100644
--- a/src/main.c
+++ b/src/main.c
@@ -73,6 +73,7 @@ static struct {
        bool single_tech;
        char **tethering_technologies;
        bool persistent_tethering_mode;
+       bool ignore_invalid_key;
 } connman_settings  = {
        .bg_scan = true,
        .pref_timeservers = NULL,
@@ -86,6 +87,7 @@ static struct {
        .single_tech = false,
        .tethering_technologies = NULL,
        .persistent_tethering_mode = false,
+       .ignore_invalid_key = false,
 };
 
 #define CONF_BG_SCAN                    "BackgroundScanning"
@@ -98,8 +100,9 @@ static struct {
 #define CONF_BLACKLISTED_INTERFACES     "NetworkInterfaceBlacklist"
 #define CONF_ALLOW_HOSTNAME_UPDATES     "AllowHostnameUpdates"
 #define CONF_SINGLE_TECH                "SingleConnectedTechnology"
-#define CONF_TETHERING_TECHNOLOGIES      "TetheringTechnologies"
+#define CONF_TETHERING_TECHNOLOGIES     "TetheringTechnologies"
 #define CONF_PERSISTENT_TETHERING_MODE  "PersistentTetheringMode"
+#define CONF_IGNORE_INVALID_KEY         "IgnoreInvalidKey"
 
 static const char *supported_options[] = {
        CONF_BG_SCAN,
@@ -114,6 +117,7 @@ static const char *supported_options[] = {
        CONF_SINGLE_TECH,
        CONF_TETHERING_TECHNOLOGIES,
        CONF_PERSISTENT_TETHERING_MODE,
+       CONF_IGNORE_INVALID_KEY,
        NULL
 };
 
@@ -354,6 +358,13 @@ static void parse_config(GKeyFile *config)
                connman_settings.persistent_tethering_mode = boolean;
 
        g_clear_error(&error);
+
+       boolean = __connman_config_get_bool(config, "General",
+                       CONF_IGNORE_INVALID_KEY, &error);
+       if (!error)
+               connman_settings.ignore_invalid_key = boolean;
+
+       g_clear_error(&error);
 }
 
 static int config_init(const char *file)
@@ -528,6 +539,9 @@ bool connman_setting_get_bool(const char *key)
        if (g_str_equal(key, CONF_PERSISTENT_TETHERING_MODE))
                return connman_settings.persistent_tethering_mode;
 
+       if (g_str_equal(key, CONF_IGNORE_INVALID_KEY))
+               return connman_settings.ignore_invalid_key;
+
        return false;
 }
 
diff --git a/src/service.c b/src/service.c
index 895387d..70381c4 100644
--- a/src/service.c
+++ b/src/service.c
@@ -5842,8 +5842,8 @@ static int service_connect(struct connman_service 
*service)
                                if (!service->wps ||
                                        
!connman_network_get_bool(service->network, "WiFi.UseWPS"))
                                        return -ENOKEY;
-                       } else if (service->error ==
-                                       CONNMAN_SERVICE_ERROR_INVALID_KEY)
+                       } else if (service->error == 
CONNMAN_SERVICE_ERROR_INVALID_KEY &&
+                                       
!connman_setting_get_bool("IgnoreInvalidKey"))
                                return -ENOKEY;
                        break;
                case CONNMAN_SERVICE_SECURITY_8021X:
-- 
1.9.1

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to