summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Blanquicet <blanquicet@gmail.com>2016-04-15 09:47:30 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2016-04-15 12:45:51 +0300
commita7af1919a74a7b520584685e560a98a33b894b25 (patch)
tree5750b13a300d56799d9185deebaadc9612e77835
parent496afe6f6ddb3a65c9ed300d74485789a1269207 (diff)
downloadconnman-a7af1919a74a7b520584685e560a98a33b894b25.tar.gz
technology: Allow raw key for tethering
Although the gsupplicant component allows to use a raw key when a new network is being created through the function add_network_security_psk, the technology component does not allow it because in order to set the property TetheringPassphrase the string's length must be within the range [8, 63], otherwise it will be taken as wrong value without check if it is a raw key. This patch uses Wi-Fi passphrase/password checking already implemented in service.c, check_passphrase(), exporting it in src/connman.h. The connman_service_security argument is hard-coded to CONNMAN_SERVICE_SECURITY_PSK because it is the only Wi-Fi security type currently supported for thethering.
-rw-r--r--src/connman.h2
-rw-r--r--src/service.c4
-rw-r--r--src/technology.c6
3 files changed, 8 insertions, 4 deletions
diff --git a/src/connman.h b/src/connman.h
index c74ab911..e849ed86 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -781,6 +781,8 @@ void __connman_service_set_agent_identity(struct connman_service *service,
int __connman_service_set_passphrase(struct connman_service *service,
const char *passphrase);
const char *__connman_service_get_passphrase(struct connman_service *service);
+int __connman_service_check_passphrase(enum connman_service_security security,
+ const char *passphrase);
int __connman_service_reset_ipconfig(struct connman_service *service,
enum connman_ipconfig_type type, DBusMessageIter *array,
enum connman_service_state *new_state);
diff --git a/src/service.c b/src/service.c
index a54e4da4..768426b1 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2831,7 +2831,7 @@ void __connman_service_set_agent_identity(struct connman_service *service,
service->agent_identity);
}
-static int check_passphrase(enum connman_service_security security,
+int __connman_service_check_passphrase(enum connman_service_security security,
const char *passphrase)
{
guint i;
@@ -2898,7 +2898,7 @@ int __connman_service_set_passphrase(struct connman_service *service,
service->security != CONNMAN_SERVICE_SECURITY_8021X)
return -EINVAL;
- err = check_passphrase(service->security, passphrase);
+ err = __connman_service_check_passphrase(service->security, passphrase);
if (err < 0)
return err;
diff --git a/src/technology.c b/src/technology.c
index 1891d063..660af52a 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -841,7 +841,7 @@ static DBusMessage *set_property(DBusConnection *conn,
struct connman_technology *technology = data;
DBusMessageIter iter, value;
const char *name;
- int type;
+ int type, err;
DBG("conn %p", conn);
@@ -923,7 +923,9 @@ static DBusMessage *set_property(DBusConnection *conn,
if (technology->type != CONNMAN_SERVICE_TYPE_WIFI)
return __connman_error_not_supported(msg);
- if (strlen(str) < 8 || strlen(str) > 63)
+ err = __connman_service_check_passphrase(CONNMAN_SERVICE_SECURITY_PSK,
+ str);
+ if (err < 0)
return __connman_error_passphrase_required(msg);
if (g_strcmp0(technology->tethering_passphrase, str) != 0) {