Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * | 2 * |
| 3 * Connection Manager | 3 * Connection Manager |
| 4 * | 4 * |
| 5 * Copyright (C) 2007-2009 Intel Corporation. All rights reserved. | 5 * Copyright (C) 2007-2009 Intel Corporation. All rights reserved. |
| 6 * | 6 * |
| 7 * This program is free software; you can redistribute it and/or modify | 7 * This program is free software; you can redistribute it and/or modify |
| 8 * it under the terms of the GNU General Public License version 2 as | 8 * it under the terms of the GNU General Public License version 2 as |
| 9 * published by the Free Software Foundation. | 9 * published by the Free Software Foundation. |
| 10 * | 10 * |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 * If securities are assigned the same priority we fall back to | 172 * If securities are assigned the same priority we fall back to |
| 173 * other attributes (e.g. signal strength) to prioritize. | 173 * other attributes (e.g. signal strength) to prioritize. |
| 174 */ | 174 */ |
| 175 static int security_priority[CONNMAN_SERVICE_SECURITY_MAX] = { | 175 static int security_priority[CONNMAN_SERVICE_SECURITY_MAX] = { |
| 176 [CONNMAN_SERVICE_SECURITY_UNKNOWN] = 3, | 176 [CONNMAN_SERVICE_SECURITY_UNKNOWN] = 3, |
| 177 [CONNMAN_SERVICE_SECURITY_NONE] = 3, | 177 [CONNMAN_SERVICE_SECURITY_NONE] = 3, |
| 178 [CONNMAN_SERVICE_SECURITY_WEP] = 2, | 178 [CONNMAN_SERVICE_SECURITY_WEP] = 2, |
| 179 [CONNMAN_SERVICE_SECURITY_WPA] = 1, | 179 [CONNMAN_SERVICE_SECURITY_WPA] = 1, |
| 180 [CONNMAN_SERVICE_SECURITY_RSN] = 1, | 180 [CONNMAN_SERVICE_SECURITY_RSN] = 1, |
| 181 [CONNMAN_SERVICE_SECURITY_802_1X] = 0, | 181 [CONNMAN_SERVICE_SECURITY_802_1X] = 0, |
| 182 [CONNMAN_SERVICE_SECURITY_PSK] = 1, | |
| 182 }; | 183 }; |
| 183 | 184 |
| 184 static const char *__statename(enum connman_service_state state) | 185 static const char *__statename(enum connman_service_state state) |
| 185 { | 186 { |
| 186 static const char *statenames[] = { | 187 static const char *statenames[] = { |
| 187 [CONNMAN_SERVICE_STATE_UNKNOWN] = "UNKNOWN", | 188 [CONNMAN_SERVICE_STATE_UNKNOWN] = "UNKNOWN", |
| 188 [CONNMAN_SERVICE_STATE_IDLE] = "IDLE", | 189 [CONNMAN_SERVICE_STATE_IDLE] = "IDLE", |
| 189 [CONNMAN_SERVICE_STATE_CARRIER] = "CARRIER", | 190 [CONNMAN_SERVICE_STATE_CARRIER] = "CARRIER", |
| 190 [CONNMAN_SERVICE_STATE_ASSOCIATION] = "ASSOCIATION", | 191 [CONNMAN_SERVICE_STATE_ASSOCIATION] = "ASSOCIATION", |
| 191 [CONNMAN_SERVICE_STATE_CONFIGURATION] = "CONFIGURATION", | 192 [CONNMAN_SERVICE_STATE_CONFIGURATION] = "CONFIGURATION", |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 460 case CONNMAN_SERVICE_SECURITY_NONE: | 461 case CONNMAN_SERVICE_SECURITY_NONE: |
| 461 return "none"; | 462 return "none"; |
| 462 case CONNMAN_SERVICE_SECURITY_WEP: | 463 case CONNMAN_SERVICE_SECURITY_WEP: |
| 463 return "wep"; | 464 return "wep"; |
| 464 case CONNMAN_SERVICE_SECURITY_WPA: | 465 case CONNMAN_SERVICE_SECURITY_WPA: |
| 465 return "wpa"; | 466 return "wpa"; |
| 466 case CONNMAN_SERVICE_SECURITY_RSN: | 467 case CONNMAN_SERVICE_SECURITY_RSN: |
| 467 return "rsn"; | 468 return "rsn"; |
| 468 case CONNMAN_SERVICE_SECURITY_802_1X: | 469 case CONNMAN_SERVICE_SECURITY_802_1X: |
| 469 return "802_1x"; | 470 return "802_1x"; |
| 471 case CONNMAN_SERVICE_SECURITY_PSK: | |
| 472 return "psk"; | |
| 470 default: | 473 default: |
| 471 break; | 474 break; |
| 472 } | 475 } |
| 473 | 476 |
| 474 return NULL; | 477 return NULL; |
| 475 } | 478 } |
| 476 | 479 |
| 477 const char *connman_service_get_state(const struct connman_service *service) | 480 const char *connman_service_get_state(const struct connman_service *service) |
| 478 { | 481 { |
| 479 switch (service->state) { | 482 switch (service->state) { |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 699 /* | 702 /* |
| 700 * Return TRUE if a passphrase is required to use the service. | 703 * Return TRUE if a passphrase is required to use the service. |
| 701 */ | 704 */ |
| 702 static connman_bool_t is_passphrase_required( | 705 static connman_bool_t is_passphrase_required( |
| 703 const struct connman_service *service) | 706 const struct connman_service *service) |
| 704 { | 707 { |
| 705 switch (service->security) { | 708 switch (service->security) { |
| 706 case CONNMAN_SERVICE_SECURITY_WEP: | 709 case CONNMAN_SERVICE_SECURITY_WEP: |
| 707 case CONNMAN_SERVICE_SECURITY_WPA: | 710 case CONNMAN_SERVICE_SECURITY_WPA: |
| 708 case CONNMAN_SERVICE_SECURITY_RSN: | 711 case CONNMAN_SERVICE_SECURITY_RSN: |
| 712 case CONNMAN_SERVICE_SECURITY_PSK: | |
| 709 if (service->passphrase == NULL) | 713 if (service->passphrase == NULL) |
| 710 return TRUE; /* must have a passphrase */ | 714 return TRUE; /* must have a passphrase */ |
| 711 if (service->favorite == TRUE) | 715 if (service->favorite == TRUE) |
| 712 return FALSE; /* successfully used before */ | 716 return FALSE; /* successfully used before */ |
| 713 /* if passphrase was never used, assume it is correct */ | 717 /* if passphrase was never used, assume it is correct */ |
| 714 return is_timeset(&service->last_attempt); | 718 return is_timeset(&service->last_attempt); |
| 715 | 719 |
| 716 case CONNMAN_SERVICE_SECURITY_802_1X: | 720 case CONNMAN_SERVICE_SECURITY_802_1X: |
| 717 /* | 721 /* |
| 718 * Passphrases are not mandatory for 802.1x - private | 722 * Passphrases are not mandatory for 802.1x - private |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1491 | 1495 |
| 1492 dbus_message_iter_get_basic(&value, &passphrase); | 1496 dbus_message_iter_get_basic(&value, &passphrase); |
| 1493 | 1497 |
| 1494 if (service->security == CONNMAN_SERVICE_SECURITY_WEP && | 1498 if (service->security == CONNMAN_SERVICE_SECURITY_WEP && |
| 1495 __connman_service_parse_wep_key(passphrase, | 1499 __connman_service_parse_wep_key(passphrase, |
| 1496 &service->wifi.wep_key_idx, | 1500 &service->wifi.wep_key_idx, |
| 1497 &service->wifi.wep_key_len, | 1501 &service->wifi.wep_key_len, |
| 1498 service->wifi.wep_key_matter) == FALSE) | 1502 service->wifi.wep_key_matter) == FALSE) |
| 1499 return __connman_error_invalid_passphrase(msg); | 1503 return __connman_error_invalid_passphrase(msg); |
| 1500 | 1504 |
| 1501 » » if ((service->security == CONNMAN_SERVICE_SECURITY_WPA || | 1505 |
| 1502 » » service->security == CONNMAN_SERVICE_SECURITY_RSN) && | 1506 » » if ((service->security == CONNMAN_SERVICE_SECURITY_PSK || |
| 1507 » » service->security == CONNMAN_SERVICE_SECURITY_RSN || | |
| 1508 » » service->security == CONNMAN_SERVICE_SECURITY_WPA) && | |
| 1503 __connman_service_validate_passphrase(passphrase) == FALSE) | 1509 __connman_service_validate_passphrase(passphrase) == FALSE) |
| 1504 return __connman_error_invalid_passphrase(msg); | 1510 return __connman_error_invalid_passphrase(msg); |
| 1505 | 1511 |
| 1506 g_free(service->passphrase); | 1512 g_free(service->passphrase); |
| 1507 service->passphrase = g_strdup(passphrase); | 1513 service->passphrase = g_strdup(passphrase); |
| 1508 | 1514 |
| 1509 /* | 1515 /* |
| 1510 * NB: Reset last attempt since this new | 1516 * NB: Reset last attempt since this new |
| 1511 * passphrase has never been tried. | 1517 * passphrase has never been tried. |
| 1512 */ | 1518 */ |
| (...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3204 case CONNMAN_SERVICE_TYPE_VPN: | 3210 case CONNMAN_SERVICE_TYPE_VPN: |
| 3205 break; | 3211 break; |
| 3206 case CONNMAN_SERVICE_TYPE_WIFI: | 3212 case CONNMAN_SERVICE_TYPE_WIFI: |
| 3207 switch (service->security) { | 3213 switch (service->security) { |
| 3208 case CONNMAN_SERVICE_SECURITY_UNKNOWN: | 3214 case CONNMAN_SERVICE_SECURITY_UNKNOWN: |
| 3209 case CONNMAN_SERVICE_SECURITY_NONE: | 3215 case CONNMAN_SERVICE_SECURITY_NONE: |
| 3210 break; | 3216 break; |
| 3211 case CONNMAN_SERVICE_SECURITY_WEP: | 3217 case CONNMAN_SERVICE_SECURITY_WEP: |
| 3212 case CONNMAN_SERVICE_SECURITY_WPA: | 3218 case CONNMAN_SERVICE_SECURITY_WPA: |
| 3213 case CONNMAN_SERVICE_SECURITY_RSN: | 3219 case CONNMAN_SERVICE_SECURITY_RSN: |
| 3220 case CONNMAN_SERVICE_SECURITY_PSK: | |
| 3214 if (service->passphrase == NULL) { | 3221 if (service->passphrase == NULL) { |
| 3215 _DBG_SERVICE("service %p missing passphrase", | 3222 _DBG_SERVICE("service %p missing passphrase", |
| 3216 service); | 3223 service); |
| 3217 return -ENOKEY; | 3224 return -ENOKEY; |
| 3218 } | 3225 } |
| 3219 /* TODO(sleffler) validate wep key matter? */ | 3226 /* TODO(sleffler) validate wep key matter? */ |
| 3220 break; | 3227 break; |
| 3221 case CONNMAN_SERVICE_SECURITY_802_1X: | 3228 case CONNMAN_SERVICE_SECURITY_802_1X: |
| 3222 if (is_connectable(service) == FALSE) | 3229 if (is_connectable(service) == FALSE) |
| 3223 return -ENOKEY; | 3230 return -ENOKEY; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3401 g_free(*service_property); | 3408 g_free(*service_property); |
| 3402 /* TODO(sleffler) hack until entd uses ClearProperty */ | 3409 /* TODO(sleffler) hack until entd uses ClearProperty */ |
| 3403 if (value[0] != '\0') | 3410 if (value[0] != '\0') |
| 3404 *service_property = g_strdup(value); | 3411 *service_property = g_strdup(value); |
| 3405 else | 3412 else |
| 3406 *service_property = NULL; | 3413 *service_property = NULL; |
| 3407 *modified = TRUE; | 3414 *modified = TRUE; |
| 3408 } | 3415 } |
| 3409 } | 3416 } |
| 3410 | 3417 |
| 3418 static inline gboolean ispsk(const char *security) | |
| 3419 { | |
| 3420 return (g_strcmp0(security, "wpa") == 0 || | |
| 3421 g_strcmp0(security, "rsn") == 0 || | |
| 3422 g_strcmp0(security, "psk") == 0); | |
| 3423 } | |
| 3424 | |
| 3411 /** | 3425 /** |
| 3412 * __connman_get_wifi_service_int: | 3426 * __connman_get_wifi_service_int: |
| 3413 * | 3427 * |
| 3414 * Obtain a pointer to a service with the SSID and security type | 3428 * Obtain a pointer to a service with the SSID and security type |
| 3415 * specified in the DBus message, creating one (backed by a | 3429 * specified in the DBus message, creating one (backed by a |
| 3416 * hidden-SSID network) if necessary. | 3430 * hidden-SSID network) if necessary. |
| 3417 * If a service is created, set its HiddenSSID property to HiddenSSID in | 3431 * If a service is created, set its HiddenSSID property to HiddenSSID in |
| 3418 * DBus message, if present. If not present, set HiddenSSID = TRUE if | 3432 * DBus message, if present. If not present, set HiddenSSID = TRUE if |
| 3419 * set_hidden_ssid == TRUE. | 3433 * set_hidden_ssid == TRUE. |
| 3420 */ | 3434 */ |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3569 } | 3583 } |
| 3570 | 3584 |
| 3571 ssid_len = strlen(ssid); | 3585 ssid_len = strlen(ssid); |
| 3572 if (ssid_len < 1 || ssid_len > MAX_SSID_LENGTH) { | 3586 if (ssid_len < 1 || ssid_len > MAX_SSID_LENGTH) { |
| 3573 connman_error("%s: invalid ssid, len %d", __func__, ssid_len); | 3587 connman_error("%s: invalid ssid, len %d", __func__, ssid_len); |
| 3574 return __connman_error_invalid_network_name(msg); | 3588 return __connman_error_invalid_network_name(msg); |
| 3575 } | 3589 } |
| 3576 | 3590 |
| 3577 if (g_strcmp0(security, "none") != 0 && | 3591 if (g_strcmp0(security, "none") != 0 && |
| 3578 g_strcmp0(security, "wep") != 0 && | 3592 g_strcmp0(security, "wep") != 0 && |
| 3579 » g_strcmp0(security, "wpa") != 0 && | 3593 » g_strcmp0(security, "802_1x") != 0 && |
| 3580 » g_strcmp0(security, "rsn") != 0 && | 3594 » !ispsk(security)) { |
| 3581 » g_strcmp0(security, "802_1x") != 0) { | |
| 3582 connman_error("%s: invalid security %s", __func__, security); | 3595 connman_error("%s: invalid security %s", __func__, security); |
| 3583 return __connman_error_invalid_arguments(msg); | 3596 return __connman_error_invalid_arguments(msg); |
| 3584 } | 3597 } |
| 3585 | 3598 |
| 3586 wep_key_idx = -1; | 3599 wep_key_idx = -1; |
| 3587 if (g_strcmp0(security, "wep") == 0 && passphrase != NULL) { | 3600 if (g_strcmp0(security, "wep") == 0 && passphrase != NULL) { |
| 3588 connman_uint8_t u8_idx; | 3601 connman_uint8_t u8_idx; |
| 3589 /* validate any wep key */ | 3602 /* validate any wep key */ |
| 3590 if (__connman_service_parse_wep_key(passphrase, &u8_idx, | 3603 if (__connman_service_parse_wep_key(passphrase, &u8_idx, |
| 3591 &wep_key_len, wep_key_matter) == FALSE) | 3604 &wep_key_len, wep_key_matter) == FALSE) |
| 3592 return __connman_error_invalid_passphrase(msg); | 3605 return __connman_error_invalid_passphrase(msg); |
| 3593 wep_key_idx = u8_idx; | 3606 wep_key_idx = u8_idx; |
| 3594 } | 3607 } |
| 3595 | 3608 |
| 3596 » if ((g_strcmp0(security, "wpa") == 0 || | 3609 » if (ispsk(security) && passphrase != NULL && |
| 3597 » g_strcmp0(security, "rsn") == 0) && passphrase != NULL && | |
| 3598 __connman_service_validate_passphrase(passphrase) == FALSE) | 3610 __connman_service_validate_passphrase(passphrase) == FALSE) |
| 3599 return __connman_error_invalid_passphrase(msg); | 3611 return __connman_error_invalid_passphrase(msg); |
| 3600 | 3612 |
| 3601 device = __connman_element_find_device(CONNMAN_DEVICE_TYPE_WIFI); | 3613 device = __connman_element_find_device(CONNMAN_DEVICE_TYPE_WIFI); |
| 3602 if (device == NULL) { | 3614 if (device == NULL) { |
| 3603 connman_error("%s: no wifi device", __func__); | 3615 connman_error("%s: no wifi device", __func__); |
| 3604 return __connman_error_invalid_arguments(msg); | 3616 return __connman_error_invalid_arguments(msg); |
| 3605 } | 3617 } |
| 3606 | 3618 |
| 3607 ident = __connman_device_get_ident(device); | 3619 ident = __connman_device_get_ident(device); |
| 3608 if (ident == NULL) { | 3620 if (ident == NULL) { |
| 3609 connman_error("%s: no device identifier", __func__); | 3621 connman_error("%s: no device identifier", __func__); |
| 3610 return __connman_error_invalid_arguments(msg); | 3622 return __connman_error_invalid_arguments(msg); |
| 3611 } | 3623 } |
| 3612 | 3624 |
| 3613 » group = connman_wifi_build_group_name((unsigned char *) ssid, | 3625 » group = connman_wifi_build_group_name((unsigned char *) ssid, ssid_len, |
| 3614 » » » » » » ssid_len, mode, security); | 3626 » » » » » mode, security); |
| 3615 if (group == NULL) { | 3627 if (group == NULL) { |
| 3616 connman_error("%s: cannot build group name", __func__); | 3628 connman_error("%s: cannot build group name", __func__); |
| 3617 return __connman_error_invalid_arguments(msg); | 3629 return __connman_error_invalid_arguments(msg); |
| 3618 } | 3630 } |
| 3619 | 3631 |
| 3620 name = g_strdup_printf("%s_%s_%s", type_str, ident, group); | 3632 name = g_strdup_printf("%s_%s_%s", type_str, ident, group); |
| 3621 | 3633 |
| 3622 service = __connman_service_lookup(name); | 3634 service = __connman_service_lookup(name); |
| 3623 modified = FALSE; | 3635 modified = FALSE; |
| 3624 created = FALSE; | 3636 created = FALSE; |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4149 } | 4161 } |
| 4150 | 4162 |
| 4151 static enum connman_service_mode convert_wifi_security(const char *security) | 4163 static enum connman_service_mode convert_wifi_security(const char *security) |
| 4152 { | 4164 { |
| 4153 if (security == NULL) | 4165 if (security == NULL) |
| 4154 return CONNMAN_SERVICE_SECURITY_UNKNOWN; | 4166 return CONNMAN_SERVICE_SECURITY_UNKNOWN; |
| 4155 else if (g_str_equal(security, "none") == TRUE) | 4167 else if (g_str_equal(security, "none") == TRUE) |
| 4156 return CONNMAN_SERVICE_SECURITY_NONE; | 4168 return CONNMAN_SERVICE_SECURITY_NONE; |
| 4157 else if (g_str_equal(security, "wep") == TRUE) | 4169 else if (g_str_equal(security, "wep") == TRUE) |
| 4158 return CONNMAN_SERVICE_SECURITY_WEP; | 4170 return CONNMAN_SERVICE_SECURITY_WEP; |
| 4171 else if (g_str_equal(security, "psk") == TRUE) | |
| 4172 return CONNMAN_SERVICE_SECURITY_PSK; | |
| 4159 else if (g_str_equal(security, "wpa") == TRUE) | 4173 else if (g_str_equal(security, "wpa") == TRUE) |
| 4160 return CONNMAN_SERVICE_SECURITY_WPA; | 4174 return CONNMAN_SERVICE_SECURITY_WPA; |
| 4161 else if (g_str_equal(security, "rsn") == TRUE) | 4175 else if (g_str_equal(security, "rsn") == TRUE) |
| 4162 return CONNMAN_SERVICE_SECURITY_RSN; | 4176 return CONNMAN_SERVICE_SECURITY_RSN; |
| 4163 else if (g_str_equal(security, "802_1x") == TRUE) | 4177 else if (g_str_equal(security, "802_1x") == TRUE) |
| 4164 return CONNMAN_SERVICE_SECURITY_802_1X; | 4178 return CONNMAN_SERVICE_SECURITY_802_1X; |
| 4165 else | 4179 else |
| 4166 return CONNMAN_SERVICE_SECURITY_UNKNOWN; | 4180 return CONNMAN_SERVICE_SECURITY_UNKNOWN; |
| 4167 } | 4181 } |
| 4168 | 4182 |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4495 { | 4509 { |
| 4496 char *str; | 4510 char *str; |
| 4497 | 4511 |
| 4498 str = g_key_file_get_string(keyfile, service->identifier, key, NULL); | 4512 str = g_key_file_get_string(keyfile, service->identifier, key, NULL); |
| 4499 if (str != NULL) { | 4513 if (str != NULL) { |
| 4500 g_free(*storage); | 4514 g_free(*storage); |
| 4501 *storage = str; | 4515 *storage = str; |
| 4502 } | 4516 } |
| 4503 } | 4517 } |
| 4504 | 4518 |
| 4519 /* | |
| 4520 * Construct old-style entries for wpa/rsn services. | |
| 4521 */ | |
| 4522 static char *__old_security(GKeyFile *keyfile, | |
| 4523 const struct connman_service *service) | |
| 4524 { | |
| 4525 char *group = NULL; | |
| 4526 | |
|
Paul Stewart
2011/03/03 19:55:04
I suggest a test (perhaps not an assert) that
g_st
| |
| 4527 if (service->security == CONNMAN_SERVICE_SECURITY_WPA) { | |
| 4528 group = g_strdup(service->identifier); | |
| 4529 g_strlcpy(group + strlen(group) - 3, "wpa", 4); | |
| 4530 } else if (service->security == CONNMAN_SERVICE_SECURITY_RSN) { | |
| 4531 group = g_strdup(service->identifier); | |
| 4532 g_strlcpy(group + strlen(group) - 3, "rsn", 4); | |
| 4533 } | |
| 4534 return group; | |
| 4535 } | |
| 4536 | |
| 4505 static int service_load(struct connman_service *service) | 4537 static int service_load(struct connman_service *service) |
| 4506 { | 4538 { |
| 4507 const char *ident = service->profile; | 4539 const char *ident = service->profile; |
| 4540 const char *group = service->identifier; | |
| 4508 GKeyFile *keyfile; | 4541 GKeyFile *keyfile; |
| 4509 GError *error = NULL; | 4542 GError *error = NULL; |
| 4510 gchar *pathname, *data = NULL; | 4543 gchar *pathname, *data = NULL; |
| 4511 gsize length; | 4544 gsize length; |
| 4512 gchar *str; | 4545 gchar *str; |
| 4513 connman_bool_t autoconnect; | 4546 connman_bool_t autoconnect; |
| 4514 unsigned int ssid_len; | 4547 unsigned int ssid_len; |
| 4515 struct connman_network_apn *apn; | 4548 struct connman_network_apn *apn; |
| 4516 int err = 0, pri; | 4549 int err = 0, pri; |
| 4517 | 4550 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 4534 g_free(pathname); | 4567 g_free(pathname); |
| 4535 | 4568 |
| 4536 if (g_key_file_load_from_data(keyfile, data, length, | 4569 if (g_key_file_load_from_data(keyfile, data, length, |
| 4537 0, NULL) == FALSE) { | 4570 0, NULL) == FALSE) { |
| 4538 g_free(data); | 4571 g_free(data); |
| 4539 return -EILSEQ; | 4572 return -EILSEQ; |
| 4540 } | 4573 } |
| 4541 | 4574 |
| 4542 g_free(data); | 4575 g_free(data); |
| 4543 | 4576 |
| 4577 /* | |
| 4578 * Handle upgrade of old-style entries for wpa/rsn services. | |
| 4579 */ | |
| 4580 if (g_key_file_has_group(keyfile, group) == FALSE) { | |
| 4581 char *old_group = __old_security(keyfile, service); | |
| 4582 if (old_group != NULL) { | |
| 4583 _DBG_SERVICE("check old entry %s", old_group); | |
| 4584 group = old_group; | |
| 4585 } | |
| 4586 } | |
| 4587 | |
| 4544 switch (service->type) { | 4588 switch (service->type) { |
| 4545 case CONNMAN_SERVICE_TYPE_UNKNOWN: | 4589 case CONNMAN_SERVICE_TYPE_UNKNOWN: |
| 4546 case CONNMAN_SERVICE_TYPE_ETHERNET: | 4590 case CONNMAN_SERVICE_TYPE_ETHERNET: |
| 4547 case CONNMAN_SERVICE_TYPE_VPN: | 4591 case CONNMAN_SERVICE_TYPE_VPN: |
| 4548 break; | 4592 break; |
| 4549 case CONNMAN_SERVICE_TYPE_WIFI: | 4593 case CONNMAN_SERVICE_TYPE_WIFI: |
| 4550 service->wifi.hidden_ssid = g_key_file_get_boolean(keyfile, | 4594 service->wifi.hidden_ssid = g_key_file_get_boolean(keyfile, |
| 4551 » » » » service->identifier, "WiFi.HiddenSSID", NULL); | 4595 » » » » group, "WiFi.HiddenSSID", NULL); |
| 4552 | 4596 |
| 4553 if (service->name == NULL) { | 4597 if (service->name == NULL) { |
| 4554 service->name = g_key_file_get_string(keyfile, | 4598 service->name = g_key_file_get_string(keyfile, |
| 4555 » » » » » service->identifier, "Name", NULL); | 4599 » » » » » group, "Name", NULL); |
| 4556 | 4600 |
| 4557 if (service->network != NULL && service->name != NULL) | 4601 if (service->network != NULL && service->name != NULL) |
| 4558 connman_network_set_name(service->network, | 4602 connman_network_set_name(service->network, |
| 4559 service->name); | 4603 service->name); |
| 4560 } | 4604 } |
| 4561 | 4605 |
| 4562 if (service->network && | 4606 if (service->network && |
| 4563 connman_network_get_blob(service->network, | 4607 connman_network_get_blob(service->network, |
| 4564 "WiFi.SSID", &ssid_len) == NULL) { | 4608 "WiFi.SSID", &ssid_len) == NULL) { |
| 4565 gchar *hex_ssid; | 4609 gchar *hex_ssid; |
| 4566 | 4610 |
| 4567 hex_ssid = g_key_file_get_string(keyfile, | 4611 hex_ssid = g_key_file_get_string(keyfile, |
| 4568 » » » » » » » service->identifier, | 4612 » » » » » » » group, "SSID", NULL); |
| 4569 » » » » » » » » "SSID", NULL); | |
| 4570 | 4613 |
| 4571 if (hex_ssid != NULL) { | 4614 if (hex_ssid != NULL) { |
| 4572 struct blob *ssid; | 4615 struct blob *ssid; |
| 4573 | 4616 |
| 4574 err = blob_new_from_hex(&ssid, hex_ssid); | 4617 err = blob_new_from_hex(&ssid, hex_ssid); |
| 4575 g_free(hex_ssid); | 4618 g_free(hex_ssid); |
| 4576 if (err < 0) { | 4619 if (err < 0) { |
| 4577 goto done; | 4620 goto done; |
| 4578 } | 4621 } |
| 4579 | 4622 |
| 4580 connman_network_set_blob(service->network, | 4623 connman_network_set_blob(service->network, |
| 4581 "WiFi.SSID", ssid->data, ssid->len); | 4624 "WiFi.SSID", ssid->data, ssid->len); |
| 4582 | 4625 |
| 4583 blob_free(ssid); | 4626 blob_free(ssid); |
| 4584 } | 4627 } |
| 4585 } | 4628 } |
| 4586 /* fall through */ | 4629 /* fall through */ |
| 4587 | 4630 |
| 4588 case CONNMAN_SERVICE_TYPE_WIMAX: | 4631 case CONNMAN_SERVICE_TYPE_WIMAX: |
| 4589 case CONNMAN_SERVICE_TYPE_BLUETOOTH: | 4632 case CONNMAN_SERVICE_TYPE_BLUETOOTH: |
| 4590 str = g_key_file_get_string(keyfile, | 4633 str = g_key_file_get_string(keyfile, |
| 4591 » » » » » service->identifier, | 4634 » » » » » group, "Failure", NULL); |
| 4592 » » » » » "Failure", NULL); | |
| 4593 if (str != NULL) { | 4635 if (str != NULL) { |
| 4594 service->error = string2error(str); | 4636 service->error = string2error(str); |
| 4595 state_change(service, | 4637 state_change(service, |
| 4596 CONNMAN_SERVICE_STATE_FAILURE, | 4638 CONNMAN_SERVICE_STATE_FAILURE, |
| 4597 FALSE); | 4639 FALSE); |
| 4598 } | 4640 } |
| 4599 /* fall through */ | 4641 /* fall through */ |
| 4600 | 4642 |
| 4601 case CONNMAN_SERVICE_TYPE_CELLULAR: | 4643 case CONNMAN_SERVICE_TYPE_CELLULAR: |
| 4602 service->favorite = g_key_file_get_boolean(keyfile, | 4644 service->favorite = g_key_file_get_boolean(keyfile, |
| 4603 » » » » service->identifier, "Favorite", NULL); | 4645 » » » » group, "Favorite", NULL); |
| 4604 | 4646 |
| 4605 autoconnect = g_key_file_get_boolean(keyfile, | 4647 autoconnect = g_key_file_get_boolean(keyfile, |
| 4606 » » » » service->identifier, "AutoConnect", &error); | 4648 » » » » group, "AutoConnect", &error); |
| 4607 if (error == NULL) | 4649 if (error == NULL) |
| 4608 service->autoconnect = autoconnect; | 4650 service->autoconnect = autoconnect; |
| 4609 g_clear_error(&error); | 4651 g_clear_error(&error); |
| 4610 break; | 4652 break; |
| 4611 default: | 4653 default: |
| 4612 break; | 4654 break; |
| 4613 } | 4655 } |
| 4614 | 4656 |
| 4615 str = g_key_file_get_string(keyfile, | 4657 str = g_key_file_get_string(keyfile, |
| 4616 » » » » service->identifier, "Modified", NULL); | 4658 » » » » group, "Modified", NULL); |
| 4617 if (str != NULL) { | 4659 if (str != NULL) { |
| 4618 g_time_val_from_iso8601(str, &service->modified); | 4660 g_time_val_from_iso8601(str, &service->modified); |
| 4619 g_free(str); | 4661 g_free(str); |
| 4620 } | 4662 } |
| 4621 | 4663 |
| 4622 str = g_key_file_get_string(keyfile, | 4664 str = g_key_file_get_string(keyfile, |
| 4623 » » » » service->identifier, "LastAttempt", NULL); | 4665 » » » » group, "LastAttempt", NULL); |
| 4624 if (str != NULL) { | 4666 if (str != NULL) { |
| 4625 g_time_val_from_iso8601(str, &service->last_attempt); | 4667 g_time_val_from_iso8601(str, &service->last_attempt); |
| 4626 g_free(str); | 4668 g_free(str); |
| 4627 } | 4669 } |
| 4628 | 4670 |
| 4629 str = __connman_storage_get_encrypted_value(keyfile, service->profile, | 4671 str = __connman_storage_get_encrypted_value(keyfile, service->profile, |
| 4630 » service->identifier, "Passphrase"); | 4672 » group, "Passphrase"); |
| 4631 if (str != NULL) { | 4673 if (str != NULL) { |
| 4632 connman_bool_t valid_pass = TRUE; | 4674 connman_bool_t valid_pass = TRUE; |
| 4633 g_free(service->passphrase); | 4675 g_free(service->passphrase); |
| 4634 service->passphrase = NULL; | 4676 service->passphrase = NULL; |
| 4635 | 4677 |
| 4636 switch (service->security) { | 4678 switch (service->security) { |
| 4637 case CONNMAN_SERVICE_SECURITY_WEP: | 4679 case CONNMAN_SERVICE_SECURITY_WEP: |
| 4638 valid_pass = __connman_service_parse_wep_key(str, | 4680 valid_pass = __connman_service_parse_wep_key(str, |
| 4639 &service->wifi.wep_key_idx, | 4681 &service->wifi.wep_key_idx, |
| 4640 &service->wifi.wep_key_len, | 4682 &service->wifi.wep_key_len, |
| 4641 service->wifi.wep_key_matter); | 4683 service->wifi.wep_key_matter); |
| 4642 break; | 4684 break; |
| 4643 case CONNMAN_SERVICE_SECURITY_WPA: | 4685 case CONNMAN_SERVICE_SECURITY_WPA: |
| 4644 case CONNMAN_SERVICE_SECURITY_RSN: | 4686 case CONNMAN_SERVICE_SECURITY_RSN: |
| 4687 case CONNMAN_SERVICE_SECURITY_PSK: | |
| 4645 valid_pass = __connman_service_validate_passphrase(str); | 4688 valid_pass = __connman_service_validate_passphrase(str); |
| 4646 break; | 4689 break; |
| 4647 default: | 4690 default: |
| 4648 break; | 4691 break; |
| 4649 } | 4692 } |
| 4650 if (valid_pass == TRUE) | 4693 if (valid_pass == TRUE) |
| 4651 service->passphrase = str; | 4694 service->passphrase = str; |
| 4652 else | 4695 else |
| 4653 g_free(str); | 4696 g_free(str); |
| 4654 } | 4697 } |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 4676 populate_service_from_keyfile(keyfile, service, | 4719 populate_service_from_keyfile(keyfile, service, |
| 4677 kEAPCACertID, &service->eap.cert_id); | 4720 kEAPCACertID, &service->eap.cert_id); |
| 4678 populate_service_from_keyfile(keyfile, service, | 4721 populate_service_from_keyfile(keyfile, service, |
| 4679 kEAPPIN, &service->eap.pin); | 4722 kEAPPIN, &service->eap.pin); |
| 4680 populate_service_from_keyfile(keyfile, service, | 4723 populate_service_from_keyfile(keyfile, service, |
| 4681 kEAPPassword, &service->eap.password); | 4724 kEAPPassword, &service->eap.password); |
| 4682 populate_service_from_keyfile(keyfile, service, | 4725 populate_service_from_keyfile(keyfile, service, |
| 4683 kEAPKeyMgmt, &service->eap.key_mgmt); | 4726 kEAPKeyMgmt, &service->eap.key_mgmt); |
| 4684 | 4727 |
| 4685 str = g_key_file_get_string(keyfile, | 4728 str = g_key_file_get_string(keyfile, |
| 4686 » » » » service->identifier, "ProxyConfig", NULL); | 4729 » » » » group, "ProxyConfig", NULL); |
| 4687 if (str != NULL) { | 4730 if (str != NULL) { |
| 4688 g_free(service->proxy_config); | 4731 g_free(service->proxy_config); |
| 4689 service->proxy_config = str; | 4732 service->proxy_config = str; |
| 4690 } | 4733 } |
| 4691 | 4734 |
| 4692 pri = g_key_file_get_integer(keyfile, | 4735 pri = g_key_file_get_integer(keyfile, |
| 4693 » » » » service->identifier, "Priority", &error); | 4736 » » » » group, "Priority", &error); |
| 4694 if (error == NULL) | 4737 if (error == NULL) |
| 4695 service->pri = pri; | 4738 service->pri = pri; |
| 4696 | 4739 |
| 4697 apn = &service->cellular.apn; | 4740 apn = &service->cellular.apn; |
| 4698 g_free(apn->apn); | 4741 g_free(apn->apn); |
| 4699 g_free(apn->username); | 4742 g_free(apn->username); |
| 4700 g_free(apn->password); | 4743 g_free(apn->password); |
| 4701 g_free(apn->network_id); | 4744 g_free(apn->network_id); |
| 4702 apn->apn = g_key_file_get_string(keyfile, | 4745 apn->apn = g_key_file_get_string(keyfile, |
| 4703 » » » » service->identifier, "Cellular.APN.apn", NULL); | 4746 » » » » group, "Cellular.APN.apn", NULL); |
| 4704 if (apn->apn != NULL) { | 4747 if (apn->apn != NULL) { |
| 4705 apn->username = g_key_file_get_string(keyfile, | 4748 apn->username = g_key_file_get_string(keyfile, |
| 4706 » » » » » service->identifier, | 4749 » » » » » group, |
| 4707 "Cellular.APN.username", NULL); | 4750 "Cellular.APN.username", NULL); |
| 4708 apn->password = g_key_file_get_string(keyfile, | 4751 apn->password = g_key_file_get_string(keyfile, |
| 4709 » » » » » service->identifier, | 4752 » » » » » group, |
| 4710 "Cellular.APN.password", NULL); | 4753 "Cellular.APN.password", NULL); |
| 4711 apn->network_id = g_key_file_get_string(keyfile, | 4754 apn->network_id = g_key_file_get_string(keyfile, |
| 4712 » » » » » service->identifier, | 4755 » » » » » group, |
| 4713 "Cellular.APN.network_id", NULL); | 4756 "Cellular.APN.network_id", NULL); |
| 4714 } else { | 4757 } else { |
| 4715 apn->username = NULL; | 4758 apn->username = NULL; |
| 4716 apn->password = NULL; | 4759 apn->password = NULL; |
| 4717 apn->network_id = NULL; | 4760 apn->network_id = NULL; |
| 4718 } | 4761 } |
| 4719 done: | 4762 done: |
| 4720 g_key_file_free(keyfile); | 4763 g_key_file_free(keyfile); |
| 4721 | 4764 |
| 4765 if (group != service->identifier) | |
| 4766 g_free((char *)group); | |
| 4767 | |
| 4722 return err; | 4768 return err; |
| 4723 } | 4769 } |
| 4724 | 4770 |
| 4725 static void save_property(GKeyFile *keyfile, struct connman_service *service, | 4771 static void save_property(GKeyFile *keyfile, struct connman_service *service, |
| 4726 const char *key, const char *value) | 4772 const char *key, const char *value) |
| 4727 { | 4773 { |
| 4728 if (value != NULL && strlen(value) > 0) | 4774 if (value != NULL && strlen(value) > 0) |
| 4729 g_key_file_set_string(keyfile, service->identifier, key, value); | 4775 g_key_file_set_string(keyfile, service->identifier, key, value); |
| 4730 else | 4776 else |
| 4731 g_key_file_remove_key(keyfile, service->identifier, key, NULL); | 4777 g_key_file_remove_key(keyfile, service->identifier, key, NULL); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4959 service_list = NULL; | 5005 service_list = NULL; |
| 4960 | 5006 |
| 4961 g_hash_table_destroy(service_hash); | 5007 g_hash_table_destroy(service_hash); |
| 4962 service_hash = NULL; | 5008 service_hash = NULL; |
| 4963 | 5009 |
| 4964 connman_storage_unregister(&service_storage); | 5010 connman_storage_unregister(&service_storage); |
| 4965 connman_notifier_unregister(&service_notifier); | 5011 connman_notifier_unregister(&service_notifier); |
| 4966 | 5012 |
| 4967 dbus_connection_unref(connection); | 5013 dbus_connection_unref(connection); |
| 4968 } | 5014 } |
| OLD | NEW |