summaryrefslogtreecommitdiff
path: root/src/config.c
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2011-04-09 02:20:09 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2011-04-11 12:02:44 +0200
commitb128c793ac38dd20a413f443de8a4a55c3efae31 (patch)
tree9c8ccbc53ec9b1d7b84f42f179f36da82fc7a61a /src/config.c
parent3f4d27ea71e6cdbffe363fb6b91c7cf710b9cb4a (diff)
downloadconnman-b128c793ac38dd20a413f443de8a4a55c3efae31.tar.gz
connman-b128c793ac38dd20a413f443de8a4a55c3efae31.tar.bz2
connman-b128c793ac38dd20a413f443de8a4a55c3efae31.zip
config: Do not overwrite protected services
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c
index 98da9d03..e099159c 100644
--- a/src/config.c
+++ b/src/config.c
@@ -59,6 +59,7 @@ struct connman_config {
};
static GHashTable *config_table = NULL;
+static GSList *protected_services = NULL;
static int inotify_wd = -1;
@@ -128,6 +129,8 @@ static void unregister_service(gpointer data)
connman_info("Removing service configuration %s", service->ident);
+ protected_services = g_slist_remove(protected_services, service);
+
g_free(service->ident);
g_free(service->type);
g_free(service->name);
@@ -171,6 +174,31 @@ static void check_keys(GKeyFile *keyfile, const char *group,
g_strfreev(avail_keys);
}
+static connman_bool_t
+is_protected_service(struct connman_config_service *service)
+{
+ GSList *list;
+
+ DBG("ident %s", service->ident);
+
+ for (list = protected_services; list; list = list->next) {
+ struct connman_config_service *s = list->data;
+
+ if (g_strcmp0(s->type, service->type) != 0)
+ continue;
+
+ if (s->ssid == NULL || service->ssid == NULL)
+ continue;
+
+ if (g_strcmp0(service->type, "wifi") == 0 &&
+ strncmp(s->ssid, service->ssid, s->ssid_len) == 0) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
static int load_service(GKeyFile *keyfile, const char *group,
struct connman_config *config)
{
@@ -249,6 +277,18 @@ static int load_service(GKeyFile *keyfile, const char *group,
service->ssid_len = ssid_len;
}
+ if (is_protected_service(service) == TRUE) {
+ connman_error("Trying to provision a protected service");
+
+ g_free(service->ident);
+ g_free(service->type);
+ g_free(service->name);
+ g_free(service->ssid);
+ g_free(service);
+
+ return -EACCES;
+ }
+
str = g_key_file_get_string(keyfile, group, SERVICE_KEY_EAP, NULL);
if (str != NULL) {
g_free(service->eap);
@@ -315,6 +355,10 @@ static int load_service(GKeyFile *keyfile, const char *group,
g_hash_table_insert(config->service_table, service->ident,
service);
+ if (config->protected == TRUE)
+ protected_services =
+ g_slist_append(protected_services, service);
+
connman_info("Adding service configuration %s", service->ident);
return 0;