| 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  | 
 |  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             g_str_has_suffix(group, "_psk") == TRUE) { | 
 |  4582                 char *old_group = __old_security(keyfile, service); | 
 |  4583                 if (old_group != NULL) { | 
 |  4584                         _DBG_SERVICE("check old entry %s", old_group); | 
 |  4585                         group = old_group; | 
 |  4586                 } | 
 |  4587         } | 
 |  4588  | 
|  4544         switch (service->type) { |  4589         switch (service->type) { | 
|  4545         case CONNMAN_SERVICE_TYPE_UNKNOWN: |  4590         case CONNMAN_SERVICE_TYPE_UNKNOWN: | 
|  4546         case CONNMAN_SERVICE_TYPE_ETHERNET: |  4591         case CONNMAN_SERVICE_TYPE_ETHERNET: | 
|  4547         case CONNMAN_SERVICE_TYPE_VPN: |  4592         case CONNMAN_SERVICE_TYPE_VPN: | 
|  4548                 break; |  4593                 break; | 
|  4549         case CONNMAN_SERVICE_TYPE_WIFI: |  4594         case CONNMAN_SERVICE_TYPE_WIFI: | 
|  4550                 service->wifi.hidden_ssid = g_key_file_get_boolean(keyfile, |  4595                 service->wifi.hidden_ssid = g_key_file_get_boolean(keyfile, | 
|  4551 »       »       »       »       service->identifier, "WiFi.HiddenSSID", NULL); |  4596 »       »       »       »       group, "WiFi.HiddenSSID", NULL); | 
|  4552  |  4597  | 
|  4553                 if (service->name == NULL) { |  4598                 if (service->name == NULL) { | 
|  4554                         service->name = g_key_file_get_string(keyfile, |  4599                         service->name = g_key_file_get_string(keyfile, | 
|  4555 »       »       »       »       »       service->identifier, "Name", NULL); |  4600 »       »       »       »       »       group, "Name", NULL); | 
|  4556  |  4601  | 
|  4557                         if (service->network != NULL && service->name != NULL) |  4602                         if (service->network != NULL && service->name != NULL) | 
|  4558                                 connman_network_set_name(service->network, |  4603                                 connman_network_set_name(service->network, | 
|  4559                                                 service->name); |  4604                                                 service->name); | 
|  4560                 } |  4605                 } | 
|  4561  |  4606  | 
|  4562                 if (service->network && |  4607                 if (service->network && | 
|  4563                                 connman_network_get_blob(service->network, |  4608                                 connman_network_get_blob(service->network, | 
|  4564                                         "WiFi.SSID", &ssid_len) == NULL) { |  4609                                         "WiFi.SSID", &ssid_len) == NULL) { | 
|  4565                         gchar *hex_ssid; |  4610                         gchar *hex_ssid; | 
|  4566  |  4611  | 
|  4567                         hex_ssid = g_key_file_get_string(keyfile, |  4612                         hex_ssid = g_key_file_get_string(keyfile, | 
|  4568 »       »       »       »       »       »       »       service->identifier, |  4613 »       »       »       »       »       »       »       group, "SSID", NULL); | 
|  4569 »       »       »       »       »       »       »       »       "SSID", NULL); |  | 
|  4570  |  4614  | 
|  4571                         if (hex_ssid != NULL) { |  4615                         if (hex_ssid != NULL) { | 
|  4572                                 struct blob *ssid; |  4616                                 struct blob *ssid; | 
|  4573  |  4617  | 
|  4574                                 err = blob_new_from_hex(&ssid, hex_ssid); |  4618                                 err = blob_new_from_hex(&ssid, hex_ssid); | 
|  4575                                 g_free(hex_ssid); |  4619                                 g_free(hex_ssid); | 
|  4576                                 if (err < 0) { |  4620                                 if (err < 0) { | 
|  4577                                         goto done; |  4621                                         goto done; | 
|  4578                                 } |  4622                                 } | 
|  4579  |  4623  | 
|  4580                                 connman_network_set_blob(service->network, |  4624                                 connman_network_set_blob(service->network, | 
|  4581                                         "WiFi.SSID", ssid->data, ssid->len); |  4625                                         "WiFi.SSID", ssid->data, ssid->len); | 
|  4582  |  4626  | 
|  4583                                 blob_free(ssid); |  4627                                 blob_free(ssid); | 
|  4584                         } |  4628                         } | 
|  4585                 } |  4629                 } | 
|  4586                 /* fall through */ |  4630                 /* fall through */ | 
|  4587  |  4631  | 
|  4588         case CONNMAN_SERVICE_TYPE_WIMAX: |  4632         case CONNMAN_SERVICE_TYPE_WIMAX: | 
|  4589         case CONNMAN_SERVICE_TYPE_BLUETOOTH: |  4633         case CONNMAN_SERVICE_TYPE_BLUETOOTH: | 
|  4590                 str = g_key_file_get_string(keyfile, |  4634                 str = g_key_file_get_string(keyfile, | 
|  4591 »       »       »       »       »           service->identifier, |  4635 »       »       »       »       »           group, "Failure", NULL); | 
|  4592 »       »       »       »       »           "Failure", NULL); |  | 
|  4593                 if (str != NULL) { |  4636                 if (str != NULL) { | 
|  4594                         service->error = string2error(str); |  4637                         service->error = string2error(str); | 
|  4595                         state_change(service, |  4638                         state_change(service, | 
|  4596                                      CONNMAN_SERVICE_STATE_FAILURE, |  4639                                      CONNMAN_SERVICE_STATE_FAILURE, | 
|  4597                                      FALSE); |  4640                                      FALSE); | 
|  4598                 } |  4641                 } | 
|  4599                 /* fall through */ |  4642                 /* fall through */ | 
|  4600  |  4643  | 
|  4601         case CONNMAN_SERVICE_TYPE_CELLULAR: |  4644         case CONNMAN_SERVICE_TYPE_CELLULAR: | 
|  4602                 service->favorite = g_key_file_get_boolean(keyfile, |  4645                 service->favorite = g_key_file_get_boolean(keyfile, | 
|  4603 »       »       »       »       service->identifier, "Favorite", NULL); |  4646 »       »       »       »       group, "Favorite", NULL); | 
|  4604  |  4647  | 
|  4605                 autoconnect = g_key_file_get_boolean(keyfile, |  4648                 autoconnect = g_key_file_get_boolean(keyfile, | 
|  4606 »       »       »       »       service->identifier, "AutoConnect", &error); |  4649 »       »       »       »       group, "AutoConnect", &error); | 
|  4607                 if (error == NULL) |  4650                 if (error == NULL) | 
|  4608                         service->autoconnect = autoconnect; |  4651                         service->autoconnect = autoconnect; | 
|  4609                 g_clear_error(&error); |  4652                 g_clear_error(&error); | 
|  4610                 break; |  4653                 break; | 
|  4611         default: |  4654         default: | 
|  4612                 break; |  4655                 break; | 
|  4613         } |  4656         } | 
|  4614  |  4657  | 
|  4615         str = g_key_file_get_string(keyfile, |  4658         str = g_key_file_get_string(keyfile, | 
|  4616 »       »       »       »       service->identifier, "Modified", NULL); |  4659 »       »       »       »       group, "Modified", NULL); | 
|  4617         if (str != NULL) { |  4660         if (str != NULL) { | 
|  4618                 g_time_val_from_iso8601(str, &service->modified); |  4661                 g_time_val_from_iso8601(str, &service->modified); | 
|  4619                 g_free(str); |  4662                 g_free(str); | 
|  4620         } |  4663         } | 
|  4621  |  4664  | 
|  4622         str = g_key_file_get_string(keyfile, |  4665         str = g_key_file_get_string(keyfile, | 
|  4623 »       »       »       »       service->identifier, "LastAttempt", NULL); |  4666 »       »       »       »       group, "LastAttempt", NULL); | 
|  4624         if (str != NULL) { |  4667         if (str != NULL) { | 
|  4625                 g_time_val_from_iso8601(str, &service->last_attempt); |  4668                 g_time_val_from_iso8601(str, &service->last_attempt); | 
|  4626                 g_free(str); |  4669                 g_free(str); | 
|  4627         } |  4670         } | 
|  4628  |  4671  | 
|  4629         str = __connman_storage_get_encrypted_value(keyfile, service->profile, |  4672         str = __connman_storage_get_encrypted_value(keyfile, service->profile, | 
|  4630 »           service->identifier, "Passphrase"); |  4673 »           group, "Passphrase"); | 
|  4631         if (str != NULL) { |  4674         if (str != NULL) { | 
|  4632                 connman_bool_t valid_pass = TRUE; |  4675                 connman_bool_t valid_pass = TRUE; | 
|  4633                 g_free(service->passphrase); |  4676                 g_free(service->passphrase); | 
|  4634                 service->passphrase = NULL; |  4677                 service->passphrase = NULL; | 
|  4635  |  4678  | 
|  4636                 switch (service->security) { |  4679                 switch (service->security) { | 
|  4637                 case CONNMAN_SERVICE_SECURITY_WEP: |  4680                 case CONNMAN_SERVICE_SECURITY_WEP: | 
|  4638                         valid_pass = __connman_service_parse_wep_key(str, |  4681                         valid_pass = __connman_service_parse_wep_key(str, | 
|  4639                             &service->wifi.wep_key_idx, |  4682                             &service->wifi.wep_key_idx, | 
|  4640                             &service->wifi.wep_key_len, |  4683                             &service->wifi.wep_key_len, | 
|  4641                             service->wifi.wep_key_matter); |  4684                             service->wifi.wep_key_matter); | 
|  4642                         break; |  4685                         break; | 
|  4643                 case CONNMAN_SERVICE_SECURITY_WPA: |  4686                 case CONNMAN_SERVICE_SECURITY_WPA: | 
|  4644                 case CONNMAN_SERVICE_SECURITY_RSN: |  4687                 case CONNMAN_SERVICE_SECURITY_RSN: | 
 |  4688                 case CONNMAN_SERVICE_SECURITY_PSK: | 
|  4645                         valid_pass = __connman_service_validate_passphrase(str); |  4689                         valid_pass = __connman_service_validate_passphrase(str); | 
|  4646                         break; |  4690                         break; | 
|  4647                 default: |  4691                 default: | 
|  4648                         break; |  4692                         break; | 
|  4649                 } |  4693                 } | 
|  4650                 if (valid_pass == TRUE) |  4694                 if (valid_pass == TRUE) | 
|  4651                         service->passphrase = str; |  4695                         service->passphrase = str; | 
|  4652                 else |  4696                 else | 
|  4653                         g_free(str); |  4697                         g_free(str); | 
|  4654         } |  4698         } | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
|  4676         populate_service_from_keyfile(keyfile, service, |  4720         populate_service_from_keyfile(keyfile, service, | 
|  4677                  kEAPCACertID, &service->eap.cert_id); |  4721                  kEAPCACertID, &service->eap.cert_id); | 
|  4678         populate_service_from_keyfile(keyfile, service, |  4722         populate_service_from_keyfile(keyfile, service, | 
|  4679                  kEAPPIN, &service->eap.pin); |  4723                  kEAPPIN, &service->eap.pin); | 
|  4680         populate_service_from_keyfile(keyfile, service, |  4724         populate_service_from_keyfile(keyfile, service, | 
|  4681                  kEAPPassword, &service->eap.password); |  4725                  kEAPPassword, &service->eap.password); | 
|  4682         populate_service_from_keyfile(keyfile, service, |  4726         populate_service_from_keyfile(keyfile, service, | 
|  4683                  kEAPKeyMgmt, &service->eap.key_mgmt); |  4727                  kEAPKeyMgmt, &service->eap.key_mgmt); | 
|  4684  |  4728  | 
|  4685         str = g_key_file_get_string(keyfile, |  4729         str = g_key_file_get_string(keyfile, | 
|  4686 »       »       »       »       service->identifier, "ProxyConfig", NULL); |  4730 »       »       »       »       group, "ProxyConfig", NULL); | 
|  4687         if (str != NULL) { |  4731         if (str != NULL) { | 
|  4688                 g_free(service->proxy_config); |  4732                 g_free(service->proxy_config); | 
|  4689                 service->proxy_config = str; |  4733                 service->proxy_config = str; | 
|  4690         } |  4734         } | 
|  4691  |  4735  | 
|  4692         pri = g_key_file_get_integer(keyfile, |  4736         pri = g_key_file_get_integer(keyfile, | 
|  4693 »       »       »       »       service->identifier, "Priority", &error); |  4737 »       »       »       »       group, "Priority", &error); | 
|  4694         if (error == NULL) |  4738         if (error == NULL) | 
|  4695                 service->pri = pri; |  4739                 service->pri = pri; | 
|  4696  |  4740  | 
|  4697         apn = &service->cellular.apn; |  4741         apn = &service->cellular.apn; | 
|  4698         g_free(apn->apn); |  4742         g_free(apn->apn); | 
|  4699         g_free(apn->username); |  4743         g_free(apn->username); | 
|  4700         g_free(apn->password); |  4744         g_free(apn->password); | 
|  4701         g_free(apn->network_id); |  4745         g_free(apn->network_id); | 
|  4702         apn->apn = g_key_file_get_string(keyfile, |  4746         apn->apn = g_key_file_get_string(keyfile, | 
|  4703 »       »       »       »       service->identifier, "Cellular.APN.apn", NULL); |  4747 »       »       »       »       group, "Cellular.APN.apn", NULL); | 
|  4704         if (apn->apn != NULL) { |  4748         if (apn->apn != NULL) { | 
|  4705                 apn->username = g_key_file_get_string(keyfile, |  4749                 apn->username = g_key_file_get_string(keyfile, | 
|  4706 »       »       »       »       »             service->identifier, |  4750 »       »       »       »       »             group, | 
|  4707                                               "Cellular.APN.username", NULL); |  4751                                               "Cellular.APN.username", NULL); | 
|  4708                 apn->password = g_key_file_get_string(keyfile, |  4752                 apn->password = g_key_file_get_string(keyfile, | 
|  4709 »       »       »       »       »             service->identifier, |  4753 »       »       »       »       »             group, | 
|  4710                                               "Cellular.APN.password", NULL); |  4754                                               "Cellular.APN.password", NULL); | 
|  4711                 apn->network_id = g_key_file_get_string(keyfile, |  4755                 apn->network_id = g_key_file_get_string(keyfile, | 
|  4712 »       »       »       »       »             service->identifier, |  4756 »       »       »       »       »             group, | 
|  4713                                               "Cellular.APN.network_id", NULL); |  4757                                               "Cellular.APN.network_id", NULL); | 
|  4714         } else { |  4758         } else { | 
|  4715                 apn->username = NULL; |  4759                 apn->username = NULL; | 
|  4716                 apn->password = NULL; |  4760                 apn->password = NULL; | 
|  4717                 apn->network_id = NULL; |  4761                 apn->network_id = NULL; | 
|  4718         } |  4762         } | 
|  4719 done: |  4763 done: | 
|  4720         g_key_file_free(keyfile); |  4764         g_key_file_free(keyfile); | 
|  4721  |  4765  | 
 |  4766         if (group != service->identifier) | 
 |  4767                 g_free((char *)group); | 
 |  4768  | 
|  4722         return err; |  4769         return err; | 
|  4723 } |  4770 } | 
|  4724  |  4771  | 
|  4725 static void save_property(GKeyFile *keyfile, struct connman_service *service, |  4772 static void save_property(GKeyFile *keyfile, struct connman_service *service, | 
|  4726                           const char *key, const char *value) |  4773                           const char *key, const char *value) | 
|  4727 { |  4774 { | 
|  4728         if (value != NULL && strlen(value) > 0) |  4775         if (value != NULL && strlen(value) > 0) | 
|  4729                 g_key_file_set_string(keyfile, service->identifier, key, value); |  4776                 g_key_file_set_string(keyfile, service->identifier, key, value); | 
|  4730         else |  4777         else | 
|  4731                 g_key_file_remove_key(keyfile, service->identifier, key, NULL); |  4778                 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; |  5006         service_list = NULL; | 
|  4960  |  5007  | 
|  4961         g_hash_table_destroy(service_hash); |  5008         g_hash_table_destroy(service_hash); | 
|  4962         service_hash = NULL; |  5009         service_hash = NULL; | 
|  4963  |  5010  | 
|  4964         connman_storage_unregister(&service_storage); |  5011         connman_storage_unregister(&service_storage); | 
|  4965         connman_notifier_unregister(&service_notifier); |  5012         connman_notifier_unregister(&service_notifier); | 
|  4966  |  5013  | 
|  4967         dbus_connection_unref(connection); |  5014         dbus_connection_unref(connection); | 
|  4968 } |  5015 } | 
| OLD | NEW |