| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 char *private_key; | 88 char *private_key; |
| 89 char *private_key_passwd; | 89 char *private_key_passwd; |
| 90 char *key_id; | 90 char *key_id; |
| 91 char *ca_cert; /* formerly authpath */ | 91 char *ca_cert; /* formerly authpath */ |
| 92 char *ca_cert_id; | 92 char *ca_cert_id; |
| 93 char *pin; | 93 char *pin; |
| 94 char *password; | 94 char *password; |
| 95 char *key_mgmt; | 95 char *key_mgmt; |
| 96 } eap; | 96 } eap; |
| 97 | 97 |
| 98 » char *profile; | 98 » const struct connman_storage_ident *profile; |
| 99 char *proxy_config; | 99 char *proxy_config; |
| 100 | 100 |
| 101 /* TODO(sleffler) overlay storage */ | 101 /* TODO(sleffler) overlay storage */ |
| 102 struct { | 102 struct { |
| 103 char *operator_name; | 103 char *operator_name; |
| 104 char *operator_code; | 104 char *operator_code; |
| 105 char *olp_url; | 105 char *olp_url; |
| 106 char *usage_url; | 106 char *usage_url; |
| 107 enum connman_network_activation_state activation_state; | 107 enum connman_network_activation_state activation_state; |
| 108 enum connman_network_cellular_technology network_technology; | 108 enum connman_network_cellular_technology network_technology; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 static const char* kEAPCertID = "EAP.CertID"; | 206 static const char* kEAPCertID = "EAP.CertID"; |
| 207 static const char* kEAPPrivateKey = "EAP.PrivateKey"; | 207 static const char* kEAPPrivateKey = "EAP.PrivateKey"; |
| 208 static const char* kEAPPrivateKeyPassword = "EAP.PrivateKeyPassword"; | 208 static const char* kEAPPrivateKeyPassword = "EAP.PrivateKeyPassword"; |
| 209 static const char* kEAPKeyID = "EAP.KeyID"; | 209 static const char* kEAPKeyID = "EAP.KeyID"; |
| 210 static const char* kEAPCACert = "EAP.CACert"; | 210 static const char* kEAPCACert = "EAP.CACert"; |
| 211 static const char* kEAPCACertID = "EAP.CACertID"; | 211 static const char* kEAPCACertID = "EAP.CACertID"; |
| 212 static const char* kEAPPIN = "EAP.PIN"; | 212 static const char* kEAPPIN = "EAP.PIN"; |
| 213 static const char* kEAPPassword = "EAP.Password"; | 213 static const char* kEAPPassword = "EAP.Password"; |
| 214 static const char* kEAPKeyMgmt = "EAP.KeyMgmt"; | 214 static const char* kEAPKeyMgmt = "EAP.KeyMgmt"; |
| 215 | 215 |
| 216 static void service_clear_passphrase(struct connman_service *service); |
| 216 static void service_modified(struct connman_service *service); | 217 static void service_modified(struct connman_service *service); |
| 218 static void service_clear_eap(struct connman_service *service); |
| 217 static void __service_resort(struct connman_service *service); | 219 static void __service_resort(struct connman_service *service); |
| 220 static void set_reconnect_state(struct connman_service *service, |
| 221 connman_bool_t onoff); |
| 218 | 222 |
| 219 static connman_bool_t is_timeset(const GTimeVal *tv) | 223 static connman_bool_t is_timeset(const GTimeVal *tv) |
| 220 { | 224 { |
| 221 return !(tv->tv_sec == 0 && tv->tv_usec == 0); | 225 return !(tv->tv_sec == 0 && tv->tv_usec == 0); |
| 222 } | 226 } |
| 223 | 227 |
| 224 static void append_path(gpointer value, gpointer user_data) | 228 static void append_path(gpointer value, gpointer user_data) |
| 225 { | 229 { |
| 226 struct connman_service *service = value; | 230 struct connman_service *service = value; |
| 227 DBusMessageIter *iter = user_data; | 231 DBusMessageIter *iter = user_data; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 { | 386 { |
| 383 struct find_data data = { .path = path, .service = NULL }; | 387 struct find_data data = { .path = path, .service = NULL }; |
| 384 | 388 |
| 385 _DBG_SERVICE("path %s", path); | 389 _DBG_SERVICE("path %s", path); |
| 386 | 390 |
| 387 g_sequence_foreach(service_list, compare_path, &data); | 391 g_sequence_foreach(service_list, compare_path, &data); |
| 388 | 392 |
| 389 return data.service; | 393 return data.service; |
| 390 } | 394 } |
| 391 | 395 |
| 396 static void invalidate_profile(gpointer value, gpointer user_data) |
| 397 { |
| 398 struct connman_service *service = value; |
| 399 const struct connman_storage_ident *profile = user_data; |
| 400 |
| 401 if (service->profile == profile) { |
| 402 /* |
| 403 * Invalidate profile-related data and force a re-load |
| 404 * the next time the service is to be used (so it can |
| 405 * come from the active profile). |
| 406 */ |
| 407 service->profile = NULL; |
| 408 |
| 409 /* |
| 410 * network_disconnect may drop the last reference to the |
| 411 * service and cause it to be freed, so take a reference |
| 412 * temporarily until we are done with it. |
| 413 */ |
| 414 set_reconnect_state(service, FALSE); |
| 415 connman_service_ref(service); |
| 416 __connman_service_disconnect(service); |
| 417 service_clear_passphrase(service); |
| 418 service_clear_eap(service); |
| 419 connman_service_unref(service); |
| 420 } |
| 421 } |
| 422 |
| 423 void __connman_service_invalidate_profile(const struct connman_storage_ident *id
ent) |
| 424 { |
| 425 _DBG_SERVICE("ident %s/%s", ident->user, ident->ident); |
| 426 |
| 427 g_sequence_foreach(service_list, invalidate_profile, (gpointer) ident); |
| 428 } |
| 429 |
| 392 static const char *identifier(struct connman_service *service) | 430 static const char *identifier(struct connman_service *service) |
| 393 { | 431 { |
| 394 return service ? service->identifier : "<nil>"; | 432 return service ? service->identifier : "<nil>"; |
| 395 } | 433 } |
| 396 | 434 |
| 397 static const char *type2string(enum connman_service_type type) | 435 static const char *type2string(enum connman_service_type type) |
| 398 { | 436 { |
| 399 switch (type) { | 437 switch (type) { |
| 400 case CONNMAN_SERVICE_TYPE_UNKNOWN: | 438 case CONNMAN_SERVICE_TYPE_UNKNOWN: |
| 401 break; | 439 break; |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 * @hidden_ssids: pointer to a list of hidden SSIDs | 801 * @hidden_ssids: pointer to a list of hidden SSIDs |
| 764 * | 802 * |
| 765 * Append the list of SSIDs whose services whose WiFi.HiddenSSID property is | 803 * Append the list of SSIDs whose services whose WiFi.HiddenSSID property is |
| 766 * TRUE. These SSIDs should be directly probed whenever performing a WiFi | 804 * TRUE. These SSIDs should be directly probed whenever performing a WiFi |
| 767 * network scan. | 805 * network scan. |
| 768 * | 806 * |
| 769 * Return -EINVAL if profile could not be parsed cleanly | 807 * Return -EINVAL if profile could not be parsed cleanly |
| 770 */ | 808 */ |
| 771 int connman_service_append_hidden_ssids(GSList **hidden_ssids) | 809 int connman_service_append_hidden_ssids(GSList **hidden_ssids) |
| 772 { | 810 { |
| 773 » const char *ident = __connman_profile_active_ident(); | 811 » const struct connman_storage_ident *ident = |
| 812 » __connman_profile_active_ident(); |
| 774 GKeyFile *keyfile; | 813 GKeyFile *keyfile; |
| 775 gchar **keys; | 814 gchar **keys; |
| 776 int ret = 0; | 815 int ret = 0; |
| 777 | 816 |
| 778 » _DBG_SERVICE("ident %s", ident); | 817 » _DBG_SERVICE("ident %s:%s", ident->user, ident->ident); |
| 779 | 818 |
| 780 keyfile = __connman_storage_open(ident); | 819 keyfile = __connman_storage_open(ident); |
| 781 if (keyfile == NULL) | 820 if (keyfile == NULL) |
| 782 return -EINVAL; | 821 return -EINVAL; |
| 783 | 822 |
| 784 keys = g_key_file_get_groups(keyfile, NULL); | 823 keys = g_key_file_get_groups(keyfile, NULL); |
| 785 if (keys == NULL) { | 824 if (keys == NULL) { |
| 786 ret = -EINVAL; | 825 ret = -EINVAL; |
| 787 goto done; | 826 goto done; |
| 788 } | 827 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 808 ret = blob_new_from_hex(&ssid, hex_ssid); | 847 ret = blob_new_from_hex(&ssid, hex_ssid); |
| 809 g_free(hex_ssid); | 848 g_free(hex_ssid); |
| 810 if (ret < 0) | 849 if (ret < 0) |
| 811 goto done; | 850 goto done; |
| 812 | 851 |
| 813 _DBG_SERVICE("ssid %.*s", ssid->len, ssid->data); | 852 _DBG_SERVICE("ssid %.*s", ssid->len, ssid->data); |
| 814 *hidden_ssids = g_slist_prepend(*hidden_ssids, ssid); | 853 *hidden_ssids = g_slist_prepend(*hidden_ssids, ssid); |
| 815 } | 854 } |
| 816 | 855 |
| 817 done: | 856 done: |
| 818 » g_key_file_free(keyfile); | 857 » __connman_storage_close(ident, keyfile, FALSE); |
| 819 | 858 |
| 820 return ret; | 859 return ret; |
| 821 } | 860 } |
| 822 | 861 |
| 823 static connman_bool_t is_connectable(const struct connman_service *service) | 862 static connman_bool_t is_connectable(const struct connman_service *service) |
| 824 { | 863 { |
| 825 | 864 |
| 826 if (service->security == CONNMAN_SERVICE_SECURITY_802_1X) { | 865 if (service->security == CONNMAN_SERVICE_SECURITY_802_1X) { |
| 827 /* Identity is required for EAP. */ | 866 /* Identity is required for EAP. */ |
| 828 if (service->eap.identity == NULL) { | 867 if (service->eap.identity == NULL) { |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 | 1466 |
| 1428 if (service->network != NULL) | 1467 if (service->network != NULL) |
| 1429 prepare_network_string(service, networkname, | 1468 prepare_network_string(service, networkname, |
| 1430 *storage); | 1469 *storage); |
| 1431 | 1470 |
| 1432 if (service->path != NULL) | 1471 if (service->path != NULL) |
| 1433 connman_dbus_send_property_changed_variant(service->path, | 1472 connman_dbus_send_property_changed_variant(service->path, |
| 1434 CONNMAN_SERVICE_INTERFACE, servicename, | 1473 CONNMAN_SERVICE_INTERFACE, servicename, |
| 1435 DBUS_TYPE_STRING, storage); | 1474 DBUS_TYPE_STRING, storage); |
| 1436 | 1475 |
| 1437 » __connman_storage_save_service(service); | 1476 » service_modified(service); |
| 1438 | 1477 |
| 1439 return NULL; | 1478 return NULL; |
| 1440 } | 1479 } |
| 1441 | 1480 |
| 1442 static DBusMessage *set_property(DBusConnection *conn, | 1481 static DBusMessage *set_property(DBusConnection *conn, |
| 1443 DBusMessage *msg, void *user_data) | 1482 DBusMessage *msg, void *user_data) |
| 1444 { | 1483 { |
| 1445 struct connman_service *service = user_data; | 1484 struct connman_service *service = user_data; |
| 1446 DBusMessageIter iter, value; | 1485 DBusMessageIter iter, value; |
| 1447 DBusMessage *returnmsg; | 1486 DBusMessage *returnmsg; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1474 | 1513 |
| 1475 dbus_message_iter_get_basic(&value, &hidden_ssid); | 1514 dbus_message_iter_get_basic(&value, &hidden_ssid); |
| 1476 | 1515 |
| 1477 if (service->wifi.hidden_ssid == hidden_ssid) | 1516 if (service->wifi.hidden_ssid == hidden_ssid) |
| 1478 return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); | 1517 return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); |
| 1479 | 1518 |
| 1480 service->wifi.hidden_ssid = hidden_ssid; | 1519 service->wifi.hidden_ssid = hidden_ssid; |
| 1481 | 1520 |
| 1482 hidden_ssid_changed(service); | 1521 hidden_ssid_changed(service); |
| 1483 | 1522 |
| 1484 » » __connman_storage_save_service(service); | 1523 » » service_modified(service); |
| 1485 | |
| 1486 } else if (g_str_equal(name, "Passphrase") == TRUE) { | 1524 } else if (g_str_equal(name, "Passphrase") == TRUE) { |
| 1487 const char *passphrase; | 1525 const char *passphrase; |
| 1488 | 1526 |
| 1489 if (type != DBUS_TYPE_STRING) | 1527 if (type != DBUS_TYPE_STRING) |
| 1490 return __connman_error_invalid_arguments(msg); | 1528 return __connman_error_invalid_arguments(msg); |
| 1491 | 1529 |
| 1492 if (__connman_security_check_privilege(msg, | 1530 if (__connman_security_check_privilege(msg, |
| 1493 CONNMAN_SECURITY_PRIVILEGE_SECRET) < 0) | 1531 CONNMAN_SECURITY_PRIVILEGE_SECRET) < 0) |
| 1494 return __connman_error_permission_denied(msg); | 1532 return __connman_error_permission_denied(msg); |
| 1495 | 1533 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1517 * passphrase has never been tried. | 1555 * passphrase has never been tried. |
| 1518 */ | 1556 */ |
| 1519 service->last_attempt.tv_sec = 0; | 1557 service->last_attempt.tv_sec = 0; |
| 1520 service->last_attempt.tv_usec = 0; | 1558 service->last_attempt.tv_usec = 0; |
| 1521 | 1559 |
| 1522 passphrase_required_changed(service); | 1560 passphrase_required_changed(service); |
| 1523 | 1561 |
| 1524 if (service->network != NULL) | 1562 if (service->network != NULL) |
| 1525 prepare_network_passphrase(service); | 1563 prepare_network_passphrase(service); |
| 1526 | 1564 |
| 1527 » » __connman_storage_save_service(service); | 1565 » » service_modified(service); |
| 1528 } else if (g_str_equal(name, kEAPIdentity) == TRUE) { | 1566 } else if (g_str_equal(name, kEAPIdentity) == TRUE) { |
| 1529 returnmsg = set_eap_string(service, msg, type, value, | 1567 returnmsg = set_eap_string(service, msg, type, value, |
| 1530 &service->eap.identity, | 1568 &service->eap.identity, |
| 1531 kEAPIdentity, CONNMAN_WIFI_EAP_IDENTITY); | 1569 kEAPIdentity, CONNMAN_WIFI_EAP_IDENTITY); |
| 1532 if (returnmsg != NULL) | 1570 if (returnmsg != NULL) |
| 1533 return returnmsg; | 1571 return returnmsg; |
| 1534 } else if (g_str_equal(name, kEAPEAP) == TRUE) { | 1572 } else if (g_str_equal(name, kEAPEAP) == TRUE) { |
| 1535 returnmsg = set_eap_string(service, msg, type, value, | 1573 returnmsg = set_eap_string(service, msg, type, value, |
| 1536 &service->eap.eap, | 1574 &service->eap.eap, |
| 1537 kEAPEAP, CONNMAN_WIFI_EAP_EAP); | 1575 kEAPEAP, CONNMAN_WIFI_EAP_EAP); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1622 | 1660 |
| 1623 dbus_message_iter_get_basic(&value, &autoconnect); | 1661 dbus_message_iter_get_basic(&value, &autoconnect); |
| 1624 | 1662 |
| 1625 if (service->autoconnect == autoconnect) | 1663 if (service->autoconnect == autoconnect) |
| 1626 return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); | 1664 return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); |
| 1627 | 1665 |
| 1628 service->autoconnect = autoconnect; | 1666 service->autoconnect = autoconnect; |
| 1629 | 1667 |
| 1630 autoconnect_changed(service); | 1668 autoconnect_changed(service); |
| 1631 | 1669 |
| 1632 » » __connman_storage_save_service(service); | 1670 » » service_modified(service); |
| 1633 } else if (g_str_equal(name, "ProxyConfig") == TRUE) { | 1671 } else if (g_str_equal(name, "ProxyConfig") == TRUE) { |
| 1634 const char *proxy_config; | 1672 const char *proxy_config; |
| 1635 | 1673 |
| 1636 if (type != DBUS_TYPE_STRING) | 1674 if (type != DBUS_TYPE_STRING) |
| 1637 return __connman_error_invalid_arguments(msg); | 1675 return __connman_error_invalid_arguments(msg); |
| 1638 | 1676 |
| 1639 dbus_message_iter_get_basic(&value, &proxy_config); | 1677 dbus_message_iter_get_basic(&value, &proxy_config); |
| 1640 | 1678 |
| 1641 g_free(service->proxy_config); | 1679 g_free(service->proxy_config); |
| 1642 service->proxy_config = g_strdup(proxy_config); | 1680 service->proxy_config = g_strdup(proxy_config); |
| 1643 | 1681 |
| 1644 proxy_configuration_changed(service); | 1682 proxy_configuration_changed(service); |
| 1645 | 1683 |
| 1646 » » __connman_storage_save_service(service); | 1684 » » service_modified(service); |
| 1647 } else if (g_str_has_prefix(name, "Priority") == TRUE) { | 1685 } else if (g_str_has_prefix(name, "Priority") == TRUE) { |
| 1648 int pri; | 1686 int pri; |
| 1649 | 1687 |
| 1650 if (type != DBUS_TYPE_INT32) | 1688 if (type != DBUS_TYPE_INT32) |
| 1651 return __connman_error_invalid_arguments(msg); | 1689 return __connman_error_invalid_arguments(msg); |
| 1652 | 1690 |
| 1653 dbus_message_iter_get_basic(&value, &pri); | 1691 dbus_message_iter_get_basic(&value, &pri); |
| 1654 | 1692 |
| 1655 if (!(CONNMAN_SERVICE_PRI_MIN <= pri && | 1693 if (!(CONNMAN_SERVICE_PRI_MIN <= pri && |
| 1656 pri <= CONNMAN_SERVICE_PRI_MAX)) { | 1694 pri <= CONNMAN_SERVICE_PRI_MAX)) { |
| 1657 _DBG_SERVICE("service priority %d out of range", pri); | 1695 _DBG_SERVICE("service priority %d out of range", pri); |
| 1658 return __connman_error_invalid_arguments(msg); | 1696 return __connman_error_invalid_arguments(msg); |
| 1659 } | 1697 } |
| 1660 | 1698 |
| 1661 if (service->pri != pri) { | 1699 if (service->pri != pri) { |
| 1662 service->pri = pri; | 1700 service->pri = pri; |
| 1663 __service_resort(service); | 1701 __service_resort(service); |
| 1664 | 1702 |
| 1665 service_priority_changed(service); | 1703 service_priority_changed(service); |
| 1666 | 1704 |
| 1667 » » » __connman_storage_save_service(service); | 1705 » » » service_modified(service); |
| 1668 } | 1706 } |
| 1669 } else | 1707 } else |
| 1670 return __connman_error_invalid_property(msg); | 1708 return __connman_error_invalid_property(msg); |
| 1671 | 1709 |
| 1672 return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); | 1710 return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); |
| 1673 } | 1711 } |
| 1674 | 1712 |
| 1675 static void state_change(struct connman_service *service, | 1713 static void state_change(struct connman_service *service, |
| 1676 enum connman_service_state state, int notify) | 1714 enum connman_service_state state, int notify) |
| 1677 { | 1715 { |
| 1678 _DBG_SERVICE("service state change (%p) %s -> %s", service, | 1716 _DBG_SERVICE("service state change (%p) %s -> %s", service, |
| 1679 __statename(service->state), __statename(state)); | 1717 __statename(service->state), __statename(state)); |
| 1680 service->state = state; | 1718 service->state = state; |
| 1681 g_get_current_time(&service->last_state[state]); | 1719 g_get_current_time(&service->last_state[state]); |
| 1682 if (notify == TRUE) | 1720 if (notify == TRUE) |
| 1683 __connman_notifier_service_state_changed(service); | 1721 __connman_notifier_service_state_changed(service); |
| 1684 } | 1722 } |
| 1685 | 1723 |
| 1686 static void set_idle(struct connman_service *service) | 1724 static void set_idle(struct connman_service *service) |
| 1687 { | 1725 { |
| 1688 service->error = CONNMAN_SERVICE_ERROR_UNKNOWN; | 1726 service->error = CONNMAN_SERVICE_ERROR_UNKNOWN; |
| 1689 state_change(service, CONNMAN_SERVICE_STATE_IDLE, TRUE); | 1727 state_change(service, CONNMAN_SERVICE_STATE_IDLE, TRUE); |
| 1690 } | 1728 } |
| 1691 | 1729 |
| 1692 static void __connman_service_clear_passphrase(struct connman_service *service) | 1730 static void service_clear_passphrase(struct connman_service *service) |
| 1693 { | 1731 { |
| 1694 g_free(service->passphrase); | 1732 g_free(service->passphrase); |
| 1695 service->passphrase = NULL; | 1733 service->passphrase = NULL; |
| 1696 | 1734 |
| 1697 memset(&service->wifi, 0, sizeof(service->wifi)); | 1735 memset(&service->wifi, 0, sizeof(service->wifi)); |
| 1736 } |
| 1737 |
| 1738 static void __connman_service_clear_passphrase(struct connman_service *service) |
| 1739 { |
| 1740 service_clear_passphrase(service); |
| 1698 | 1741 |
| 1699 passphrase_required_changed(service); | 1742 passphrase_required_changed(service); |
| 1700 } | 1743 } |
| 1701 | 1744 |
| 1702 static void service_modified(struct connman_service *service) | 1745 static void service_modified(struct connman_service *service) |
| 1703 { | 1746 { |
| 1704 g_get_current_time(&service->modified); | 1747 g_get_current_time(&service->modified); |
| 1705 » __connman_storage_save_service(service); | 1748 |
| 1749 » service->profile = __connman_profile_active_ident(); |
| 1750 » __connman_profile_save_service(service); |
| 1706 } | 1751 } |
| 1707 | 1752 |
| 1708 void __connman_service_reset(struct connman_service *service) | 1753 static void service_clear_eap(struct connman_service *service) |
| 1709 { | 1754 { |
| 1710 connman_service_set_favorite(service, FALSE); | |
| 1711 __connman_service_clear_passphrase(service); | |
| 1712 | |
| 1713 g_free(service->eap.identity); | 1755 g_free(service->eap.identity); |
| 1714 service->eap.identity = NULL; | 1756 service->eap.identity = NULL; |
| 1715 | 1757 |
| 1716 g_free(service->eap.eap); | 1758 g_free(service->eap.eap); |
| 1717 service->eap.eap = NULL; | 1759 service->eap.eap = NULL; |
| 1718 | 1760 |
| 1719 g_free(service->eap.inner_eap); | 1761 g_free(service->eap.inner_eap); |
| 1720 service->eap.inner_eap = NULL; | 1762 service->eap.inner_eap = NULL; |
| 1721 | 1763 |
| 1722 g_free(service->eap.anonymous_identity); | 1764 g_free(service->eap.anonymous_identity); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1741 service->eap.ca_cert = NULL; | 1783 service->eap.ca_cert = NULL; |
| 1742 | 1784 |
| 1743 g_free(service->eap.ca_cert_id); | 1785 g_free(service->eap.ca_cert_id); |
| 1744 service->eap.ca_cert_id = NULL; | 1786 service->eap.ca_cert_id = NULL; |
| 1745 | 1787 |
| 1746 g_free(service->eap.pin); | 1788 g_free(service->eap.pin); |
| 1747 service->eap.pin = NULL; | 1789 service->eap.pin = NULL; |
| 1748 | 1790 |
| 1749 g_free(service->eap.password); | 1791 g_free(service->eap.password); |
| 1750 service->eap.password = NULL; | 1792 service->eap.password = NULL; |
| 1793 } |
| 1794 |
| 1795 void __connman_service_reset(struct connman_service *service) |
| 1796 { |
| 1797 connman_service_set_favorite(service, FALSE); |
| 1798 __connman_service_clear_passphrase(service); |
| 1799 service_clear_eap(service); |
| 1751 | 1800 |
| 1752 service_modified(service); | 1801 service_modified(service); |
| 1753 } | 1802 } |
| 1754 | 1803 |
| 1755 static DBusMessage *clear_property(DBusConnection *conn, | 1804 static DBusMessage *clear_property(DBusConnection *conn, |
| 1756 DBusMessage *msg, void *user_data) | 1805 DBusMessage *msg, void *user_data) |
| 1757 { | 1806 { |
| 1758 struct connman_service *service = user_data; | 1807 struct connman_service *service = user_data; |
| 1759 const char *name; | 1808 const char *name; |
| 1760 | 1809 |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2648 if (apn != NULL) { | 2697 if (apn != NULL) { |
| 2649 apn_info->apn = g_strdup(apn); | 2698 apn_info->apn = g_strdup(apn); |
| 2650 if (network_id != NULL) | 2699 if (network_id != NULL) |
| 2651 apn_info->network_id = g_strdup(network_id); | 2700 apn_info->network_id = g_strdup(network_id); |
| 2652 if (username != NULL) | 2701 if (username != NULL) |
| 2653 apn_info->username = g_strdup(username); | 2702 apn_info->username = g_strdup(username); |
| 2654 if (password != NULL) | 2703 if (password != NULL) |
| 2655 apn_info->password = g_strdup(password); | 2704 apn_info->password = g_strdup(password); |
| 2656 } | 2705 } |
| 2657 | 2706 |
| 2658 » __connman_storage_save_service(service); | 2707 » service_modified(service); |
| 2659 return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); | 2708 return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); |
| 2660 } | 2709 } |
| 2661 | 2710 |
| 2662 static GDBusMethodTable service_methods[] = { | 2711 static GDBusMethodTable service_methods[] = { |
| 2663 { "GetProperties", "", "a{sv}", get_properties }, | 2712 { "GetProperties", "", "a{sv}", get_properties }, |
| 2664 { "SetProperty", "sv", "", set_property }, | 2713 { "SetProperty", "sv", "", set_property }, |
| 2665 { "ClearProperty", "s", "", clear_property }, | 2714 { "ClearProperty", "s", "", clear_property }, |
| 2666 { "Connect", "", "", connect_service, }, | 2715 { "Connect", "", "", connect_service, }, |
| 2667 { "Disconnect", "", "", disconnect_service }, | 2716 { "Disconnect", "", "", disconnect_service }, |
| 2668 { "Remove", "", "", remove_service }, | 2717 { "Remove", "", "", remove_service }, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2702 g_dbus_unregister_interface(connection, path, | 2751 g_dbus_unregister_interface(connection, path, |
| 2703 CONNMAN_SERVICE_INTERFACE); | 2752 CONNMAN_SERVICE_INTERFACE); |
| 2704 g_free(path); | 2753 g_free(path); |
| 2705 } | 2754 } |
| 2706 | 2755 |
| 2707 if (service->network != NULL) | 2756 if (service->network != NULL) |
| 2708 connman_network_unref(service->network); | 2757 connman_network_unref(service->network); |
| 2709 if (service->provider != NULL) | 2758 if (service->provider != NULL) |
| 2710 connman_provider_unref(service->provider); | 2759 connman_provider_unref(service->provider); |
| 2711 | 2760 |
| 2712 g_free(service->profile); | |
| 2713 g_free(service->name); | 2761 g_free(service->name); |
| 2714 g_free(service->passphrase); | 2762 g_free(service->passphrase); |
| 2715 g_free(service->eap.identity); | 2763 g_free(service->eap.identity); |
| 2716 g_free(service->eap.eap); | 2764 g_free(service->eap.eap); |
| 2717 g_free(service->eap.inner_eap); | 2765 g_free(service->eap.inner_eap); |
| 2718 g_free(service->eap.anonymous_identity); | 2766 g_free(service->eap.anonymous_identity); |
| 2719 g_free(service->eap.client_cert); | 2767 g_free(service->eap.client_cert); |
| 2720 g_free(service->eap.cert_id); | 2768 g_free(service->eap.cert_id); |
| 2721 g_free(service->eap.private_key); | 2769 g_free(service->eap.private_key); |
| 2722 g_free(service->eap.private_key_passwd); | 2770 g_free(service->eap.private_key_passwd); |
| (...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3770 | 3818 |
| 3771 /* NB: Set HiddenSSID = FALSE when creating service not in scan list */ | 3819 /* NB: Set HiddenSSID = FALSE when creating service not in scan list */ |
| 3772 reply = __connman_get_wifi_service_int(msg, &service, &created, FALSE); | 3820 reply = __connman_get_wifi_service_int(msg, &service, &created, FALSE); |
| 3773 if (reply != NULL) | 3821 if (reply != NULL) |
| 3774 return reply; | 3822 return reply; |
| 3775 else if (service == NULL) | 3823 else if (service == NULL) |
| 3776 return __connman_error_internal_error(msg); | 3824 return __connman_error_internal_error(msg); |
| 3777 | 3825 |
| 3778 _DBG_SERVICE("service %p created %d", service, created); | 3826 _DBG_SERVICE("service %p created %d", service, created); |
| 3779 | 3827 |
| 3780 » __connman_storage_save_service(service); | 3828 » service_modified(service); |
| 3781 | 3829 |
| 3782 /* | 3830 /* |
| 3783 * If __connman_get_wifi_service_int created the network object | 3831 * If __connman_get_wifi_service_int created the network object |
| 3784 * because the service didn't already exist, then we need to | 3832 * because the service didn't already exist, then we need to |
| 3785 * get rid of it and the associated service. Removing the network | 3833 * get rid of it and the associated service. Removing the network |
| 3786 * from the device will do this; this will be the only reference | 3834 * from the device will do this; this will be the only reference |
| 3787 * to the network and when it's reclaimed the service will also | 3835 * to the network and when it's reclaimed the service will also |
| 3788 * go away because the network layer calls up into the service | 3836 * go away because the network layer calls up into the service |
| 3789 * layer to clear the (unreferenced) pointer. | 3837 * layer to clear the (unreferenced) pointer. |
| 3790 */ | 3838 */ |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3817 } | 3865 } |
| 3818 | 3866 |
| 3819 service = connman_service_create(); | 3867 service = connman_service_create(); |
| 3820 if (service == NULL) | 3868 if (service == NULL) |
| 3821 return NULL; | 3869 return NULL; |
| 3822 | 3870 |
| 3823 _DBG_SERVICE("service %p", service); | 3871 _DBG_SERVICE("service %p", service); |
| 3824 | 3872 |
| 3825 service->identifier = g_strdup(identifier); | 3873 service->identifier = g_strdup(identifier); |
| 3826 | 3874 |
| 3827 » service->profile = g_strdup(__connman_profile_active_ident()); | 3875 » service->profile = __connman_profile_active_ident(); |
| 3828 | 3876 |
| 3829 » __connman_storage_load_service(service); | 3877 » __connman_profile_load_service(service); |
| 3830 | 3878 |
| 3831 iter = g_sequence_insert_sorted(service_list, service, | 3879 iter = g_sequence_insert_sorted(service_list, service, |
| 3832 service_compare, NULL); | 3880 service_compare, NULL); |
| 3833 | 3881 |
| 3834 g_hash_table_insert(service_hash, service->identifier, iter); | 3882 g_hash_table_insert(service_hash, service->identifier, iter); |
| 3835 | 3883 |
| 3836 return service; | 3884 return service; |
| 3837 } | 3885 } |
| 3838 | 3886 |
| 3839 static int service_register(struct connman_service *service) | 3887 static int service_register(struct connman_service *service) |
| 3840 { | 3888 { |
| 3841 const char *path = __connman_profile_active_path(); | 3889 const char *path = __connman_profile_active_path(); |
| 3842 | 3890 |
| 3843 _DBG_SERVICE("service %p", service); | 3891 _DBG_SERVICE("service %p", service); |
| 3844 | 3892 |
| 3845 if (service->path != NULL) | 3893 if (service->path != NULL) |
| 3846 return -EALREADY; | 3894 return -EALREADY; |
| 3847 | 3895 |
| 3848 service->path = g_strdup_printf("%s/%s", path, service->identifier); | 3896 service->path = g_strdup_printf("%s/%s", path, service->identifier); |
| 3849 | 3897 |
| 3850 _DBG_SERVICE("path %s", service->path); | 3898 _DBG_SERVICE("path %s", service->path); |
| 3851 | 3899 |
| 3852 g_dbus_register_interface(connection, service->path, | 3900 g_dbus_register_interface(connection, service->path, |
| 3853 CONNMAN_SERVICE_INTERFACE, | 3901 CONNMAN_SERVICE_INTERFACE, |
| 3854 service_methods, service_signals, | 3902 service_methods, service_signals, |
| 3855 NULL, service, NULL); | 3903 NULL, service, NULL); |
| 3856 | 3904 |
| 3857 » __connman_storage_load_service(service); | 3905 » __connman_profile_load_service(service); |
| 3858 | 3906 |
| 3859 __service_resort(service); | 3907 __service_resort(service); |
| 3860 | 3908 |
| 3861 __connman_profile_changed(TRUE); | 3909 __connman_profile_changed(TRUE); |
| 3862 | 3910 |
| 3863 return 0; | 3911 return 0; |
| 3864 } | 3912 } |
| 3865 | 3913 |
| 3866 /** | 3914 /** |
| 3867 * __connman_service_lookup_from_device: | 3915 * __connman_service_lookup_from_device: |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3916 __connman_profile_changed(TRUE); | 3964 __connman_profile_changed(TRUE); |
| 3917 return service; | 3965 return service; |
| 3918 } | 3966 } |
| 3919 | 3967 |
| 3920 service->type = __connman_device_get_service_type(device); | 3968 service->type = __connman_device_get_service_type(device); |
| 3921 | 3969 |
| 3922 service->autoconnect = FALSE; | 3970 service->autoconnect = FALSE; |
| 3923 | 3971 |
| 3924 service->device = device; | 3972 service->device = device; |
| 3925 | 3973 |
| 3926 » __connman_storage_load_service(service); | 3974 » __connman_profile_load_service(service); |
| 3927 | 3975 |
| 3928 service_register(service); | 3976 service_register(service); |
| 3929 | 3977 |
| 3930 __connman_profile_changed(TRUE); | 3978 __connman_profile_changed(TRUE); |
| 3931 | 3979 |
| 3932 if (service->favorite == TRUE) | 3980 if (service->favorite == TRUE) |
| 3933 connman_service_auto_connect(service); | 3981 connman_service_auto_connect(service); |
| 3934 | 3982 |
| 3935 return service; | 3983 return service; |
| 3936 } | 3984 } |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4318 } | 4366 } |
| 4319 | 4367 |
| 4320 str = connman_network_get_string(network, "WiFi.Mode"); | 4368 str = connman_network_get_string(network, "WiFi.Mode"); |
| 4321 service->mode = convert_wifi_mode(str); | 4369 service->mode = convert_wifi_mode(str); |
| 4322 | 4370 |
| 4323 str = connman_network_get_string(network, "WiFi.Security"); | 4371 str = connman_network_get_string(network, "WiFi.Security"); |
| 4324 service->security = convert_wifi_security(str); | 4372 service->security = convert_wifi_security(str); |
| 4325 | 4373 |
| 4326 update_from_network(service, network, FALSE); | 4374 update_from_network(service, network, FALSE); |
| 4327 | 4375 |
| 4328 » __connman_storage_load_service(service); | 4376 » __connman_profile_load_service(service); |
| 4329 | 4377 |
| 4330 service_register(service); | 4378 service_register(service); |
| 4331 | 4379 |
| 4332 __connman_profile_changed(TRUE); | 4380 __connman_profile_changed(TRUE); |
| 4333 | 4381 |
| 4334 if (service->favorite == TRUE) | 4382 if (service->favorite == TRUE) |
| 4335 connman_service_auto_connect(service); | 4383 connman_service_auto_connect(service); |
| 4336 | 4384 |
| 4337 return service; | 4385 return service; |
| 4338 } | 4386 } |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4520 * Construct old-style entries for wpa/rsn services. | 4568 * Construct old-style entries for wpa/rsn services. |
| 4521 */ | 4569 */ |
| 4522 static char *__old_security(GKeyFile *keyfile, | 4570 static char *__old_security(GKeyFile *keyfile, |
| 4523 const struct connman_service *service) | 4571 const struct connman_service *service) |
| 4524 { | 4572 { |
| 4525 char *group = NULL; | 4573 char *group = NULL; |
| 4526 | 4574 |
| 4527 if (service->security == CONNMAN_SERVICE_SECURITY_WPA) { | 4575 if (service->security == CONNMAN_SERVICE_SECURITY_WPA) { |
| 4528 group = g_strdup(service->identifier); | 4576 group = g_strdup(service->identifier); |
| 4529 g_strlcpy(group + strlen(group) - 3, "wpa", 4); | 4577 g_strlcpy(group + strlen(group) - 3, "wpa", 4); |
| 4578 if (g_key_file_has_group(keyfile, group) == FALSE) { |
| 4579 g_free(group); |
| 4580 group = NULL; |
| 4581 } |
| 4530 } else if (service->security == CONNMAN_SERVICE_SECURITY_RSN) { | 4582 } else if (service->security == CONNMAN_SERVICE_SECURITY_RSN) { |
| 4531 group = g_strdup(service->identifier); | 4583 group = g_strdup(service->identifier); |
| 4532 g_strlcpy(group + strlen(group) - 3, "rsn", 4); | 4584 g_strlcpy(group + strlen(group) - 3, "rsn", 4); |
| 4585 if (g_key_file_has_group(keyfile, group) == FALSE) { |
| 4586 g_free(group); |
| 4587 group = NULL; |
| 4588 } |
| 4533 } | 4589 } |
| 4534 return group; | 4590 return group; |
| 4535 } | 4591 } |
| 4536 | 4592 |
| 4537 static int service_load(struct connman_service *service) | 4593 static int service_load(struct connman_service *service, GKeyFile *keyfile) |
| 4538 { | 4594 { |
| 4539 const char *ident = service->profile; | |
| 4540 const char *group = service->identifier; | 4595 const char *group = service->identifier; |
| 4541 GKeyFile *keyfile; | |
| 4542 GError *error = NULL; | 4596 GError *error = NULL; |
| 4543 gchar *pathname, *data = NULL; | |
| 4544 gsize length; | |
| 4545 gchar *str; | 4597 gchar *str; |
| 4546 connman_bool_t autoconnect; | 4598 connman_bool_t autoconnect; |
| 4547 unsigned int ssid_len; | 4599 unsigned int ssid_len; |
| 4548 struct connman_network_apn *apn; | 4600 struct connman_network_apn *apn; |
| 4549 int err = 0, pri; | 4601 int err = 0, pri; |
| 4550 | 4602 |
| 4551 _DBG_SERVICE("service %p", service); | 4603 _DBG_SERVICE("service %p", service); |
| 4552 | 4604 |
| 4553 » if (ident == NULL) | 4605 » if (g_key_file_has_group(keyfile, group) == FALSE) { |
| 4554 » » return -EINVAL; | 4606 » » char *old_group; |
| 4555 | 4607 » » /* |
| 4556 » pathname = g_strdup_printf("%s/%s.profile", STORAGEDIR, ident); | 4608 » » * Handle upgrade of old-style entries for wpa/rsn services. |
| 4557 » if (pathname == NULL) | 4609 » » */ |
| 4558 » » return -ENOMEM; | 4610 » » if (g_str_has_suffix(group, "_psk") == FALSE) { |
| 4559 | 4611 » » » err = -ESRCH; |
| 4560 » keyfile = g_key_file_new(); | 4612 » » » goto done; |
| 4561 | |
| 4562 » if (g_file_get_contents(pathname, &data, &length, NULL) == FALSE) { | |
| 4563 » » g_free(pathname); | |
| 4564 » » return -ENOENT; | |
| 4565 » } | |
| 4566 | |
| 4567 » g_free(pathname); | |
| 4568 | |
| 4569 » if (g_key_file_load_from_data(keyfile, data, length, | |
| 4570 » » » » » » » 0, NULL) == FALSE) { | |
| 4571 » » g_free(data); | |
| 4572 » » return -EILSEQ; | |
| 4573 » } | |
| 4574 | |
| 4575 » g_free(data); | |
| 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 } | 4613 } |
| 4614 old_group = __old_security(keyfile, service); |
| 4615 if (old_group == NULL) { |
| 4616 err = -ESRCH; |
| 4617 goto done; |
| 4618 } |
| 4619 _DBG_SERVICE("check old entry %s", old_group); |
| 4620 group = old_group; |
| 4587 } | 4621 } |
| 4588 | 4622 |
| 4589 switch (service->type) { | 4623 switch (service->type) { |
| 4590 case CONNMAN_SERVICE_TYPE_UNKNOWN: | 4624 case CONNMAN_SERVICE_TYPE_UNKNOWN: |
| 4591 case CONNMAN_SERVICE_TYPE_ETHERNET: | 4625 case CONNMAN_SERVICE_TYPE_ETHERNET: |
| 4592 case CONNMAN_SERVICE_TYPE_VPN: | 4626 case CONNMAN_SERVICE_TYPE_VPN: |
| 4593 break; | 4627 break; |
| 4594 case CONNMAN_SERVICE_TYPE_WIFI: | 4628 case CONNMAN_SERVICE_TYPE_WIFI: |
| 4595 service->wifi.hidden_ssid = g_key_file_get_boolean(keyfile, | 4629 service->wifi.hidden_ssid = g_key_file_get_boolean(keyfile, |
| 4596 group, "WiFi.HiddenSSID", NULL); | 4630 group, "WiFi.HiddenSSID", NULL); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4662 g_free(str); | 4696 g_free(str); |
| 4663 } | 4697 } |
| 4664 | 4698 |
| 4665 str = g_key_file_get_string(keyfile, | 4699 str = g_key_file_get_string(keyfile, |
| 4666 group, "LastAttempt", NULL); | 4700 group, "LastAttempt", NULL); |
| 4667 if (str != NULL) { | 4701 if (str != NULL) { |
| 4668 g_time_val_from_iso8601(str, &service->last_attempt); | 4702 g_time_val_from_iso8601(str, &service->last_attempt); |
| 4669 g_free(str); | 4703 g_free(str); |
| 4670 } | 4704 } |
| 4671 | 4705 |
| 4672 » str = __connman_storage_get_encrypted_value(keyfile, service->profile, | 4706 » str = __connman_storage_get_encrypted_value(keyfile, group, |
| 4673 » group, "Passphrase"); | 4707 » "Passphrase"); |
| 4674 if (str != NULL) { | 4708 if (str != NULL) { |
| 4675 connman_bool_t valid_pass = TRUE; | 4709 connman_bool_t valid_pass = TRUE; |
| 4676 g_free(service->passphrase); | 4710 g_free(service->passphrase); |
| 4677 service->passphrase = NULL; | 4711 service->passphrase = NULL; |
| 4678 | 4712 |
| 4679 switch (service->security) { | 4713 switch (service->security) { |
| 4680 case CONNMAN_SERVICE_SECURITY_WEP: | 4714 case CONNMAN_SERVICE_SECURITY_WEP: |
| 4681 valid_pass = __connman_service_parse_wep_key(str, | 4715 valid_pass = __connman_service_parse_wep_key(str, |
| 4682 &service->wifi.wep_key_idx, | 4716 &service->wifi.wep_key_idx, |
| 4683 &service->wifi.wep_key_len, | 4717 &service->wifi.wep_key_len, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4754 "Cellular.APN.password", NULL); | 4788 "Cellular.APN.password", NULL); |
| 4755 apn->network_id = g_key_file_get_string(keyfile, | 4789 apn->network_id = g_key_file_get_string(keyfile, |
| 4756 group, | 4790 group, |
| 4757 "Cellular.APN.network_id", NULL); | 4791 "Cellular.APN.network_id", NULL); |
| 4758 } else { | 4792 } else { |
| 4759 apn->username = NULL; | 4793 apn->username = NULL; |
| 4760 apn->password = NULL; | 4794 apn->password = NULL; |
| 4761 apn->network_id = NULL; | 4795 apn->network_id = NULL; |
| 4762 } | 4796 } |
| 4763 done: | 4797 done: |
| 4764 g_key_file_free(keyfile); | |
| 4765 | |
| 4766 if (group != service->identifier) | 4798 if (group != service->identifier) |
| 4767 g_free((char *)group); | 4799 g_free((char *)group); |
| 4768 | 4800 |
| 4769 return err; | 4801 return err; |
| 4770 } | 4802 } |
| 4771 | 4803 |
| 4772 static void save_property(GKeyFile *keyfile, struct connman_service *service, | 4804 static void save_property(GKeyFile *keyfile, struct connman_service *service, |
| 4773 const char *key, const char *value) | 4805 const char *key, const char *value) |
| 4774 { | 4806 { |
| 4775 if (value != NULL && strlen(value) > 0) | 4807 if (value != NULL && strlen(value) > 0) |
| 4776 g_key_file_set_string(keyfile, service->identifier, key, value); | 4808 g_key_file_set_string(keyfile, service->identifier, key, value); |
| 4777 else | 4809 else |
| 4778 g_key_file_remove_key(keyfile, service->identifier, key, NULL); | 4810 g_key_file_remove_key(keyfile, service->identifier, key, NULL); |
| 4779 } | 4811 } |
| 4780 | 4812 |
| 4781 static int service_save(struct connman_service *service) | 4813 static int service_save(struct connman_service *service, GKeyFile *keyfile) |
| 4782 { | 4814 { |
| 4783 const char *ident = service->profile; | |
| 4784 struct connman_network_apn *apn = &service->cellular.apn; | 4815 struct connman_network_apn *apn = &service->cellular.apn; |
| 4785 GKeyFile *keyfile; | |
| 4786 gchar *pathname, *data = NULL; | |
| 4787 gsize length; | |
| 4788 gchar *str; | 4816 gchar *str; |
| 4789 int err = 0; | |
| 4790 | 4817 |
| 4791 _DBG_SERVICE("service %p", service); | 4818 _DBG_SERVICE("service %p", service); |
| 4792 | 4819 |
| 4793 if (ident == NULL) | |
| 4794 return -EINVAL; | |
| 4795 | |
| 4796 pathname = g_strdup_printf("%s/%s.profile", STORAGEDIR, ident); | |
| 4797 if (pathname == NULL) | |
| 4798 return -ENOMEM; | |
| 4799 | |
| 4800 keyfile = g_key_file_new(); | |
| 4801 | |
| 4802 if (g_file_get_contents(pathname, &data, &length, NULL) == FALSE) | |
| 4803 goto update; | |
| 4804 | |
| 4805 if (length > 0) { | |
| 4806 if (g_key_file_load_from_data(keyfile, data, length, | |
| 4807 0, NULL) == FALSE) | |
| 4808 goto done; | |
| 4809 } | |
| 4810 | |
| 4811 g_free(data); | |
| 4812 | |
| 4813 update: | |
| 4814 if (service->name != NULL) | 4820 if (service->name != NULL) |
| 4815 g_key_file_set_string(keyfile, service->identifier, | 4821 g_key_file_set_string(keyfile, service->identifier, |
| 4816 "Name", service->name); | 4822 "Name", service->name); |
| 4817 | 4823 |
| 4818 switch (service->type) { | 4824 switch (service->type) { |
| 4819 case CONNMAN_SERVICE_TYPE_UNKNOWN: | 4825 case CONNMAN_SERVICE_TYPE_UNKNOWN: |
| 4820 case CONNMAN_SERVICE_TYPE_ETHERNET: | 4826 case CONNMAN_SERVICE_TYPE_ETHERNET: |
| 4821 case CONNMAN_SERVICE_TYPE_VPN: | 4827 case CONNMAN_SERVICE_TYPE_VPN: |
| 4822 break; | 4828 break; |
| 4823 case CONNMAN_SERVICE_TYPE_WIFI: | 4829 case CONNMAN_SERVICE_TYPE_WIFI: |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4873 if (is_timeset(&service->last_attempt)) { | 4879 if (is_timeset(&service->last_attempt)) { |
| 4874 str = g_time_val_to_iso8601(&service->last_attempt); | 4880 str = g_time_val_to_iso8601(&service->last_attempt); |
| 4875 if (str != NULL) { | 4881 if (str != NULL) { |
| 4876 g_key_file_set_string(keyfile, service->identifier, | 4882 g_key_file_set_string(keyfile, service->identifier, |
| 4877 "LastAttempt", str); | 4883 "LastAttempt", str); |
| 4878 g_free(str); | 4884 g_free(str); |
| 4879 } | 4885 } |
| 4880 } | 4886 } |
| 4881 | 4887 |
| 4882 if (service->passphrase != NULL && strlen(service->passphrase) > 0) { | 4888 if (service->passphrase != NULL && strlen(service->passphrase) > 0) { |
| 4883 __connman_storage_set_encrypted_value(keyfile, service->profile, | 4889 __connman_storage_set_encrypted_value(keyfile, |
| 4884 service->identifier, "Passphrase", service->passphrase); | 4890 service->identifier, "Passphrase", service->passphrase); |
| 4885 } else { | 4891 } else { |
| 4886 g_key_file_remove_key(keyfile, service->identifier, | 4892 g_key_file_remove_key(keyfile, service->identifier, |
| 4887 "Passphrase", NULL); | 4893 "Passphrase", NULL); |
| 4888 } | 4894 } |
| 4889 | 4895 |
| 4890 save_property(keyfile, service, kEAPIdentity, service->eap.identity); | 4896 save_property(keyfile, service, kEAPIdentity, service->eap.identity); |
| 4891 save_property(keyfile, service, kEAPEAP, service->eap.eap); | 4897 save_property(keyfile, service, kEAPEAP, service->eap.eap); |
| 4892 save_property(keyfile, service, kEAPInnerEAP, service->eap.inner_eap); | 4898 save_property(keyfile, service, kEAPInnerEAP, service->eap.inner_eap); |
| 4893 save_property(keyfile, service, kEAPAnonymousIdentity, | 4899 save_property(keyfile, service, kEAPAnonymousIdentity, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4933 g_key_file_remove_key(keyfile, service->identifier, | 4939 g_key_file_remove_key(keyfile, service->identifier, |
| 4934 "Cellular.APN.apn", NULL); | 4940 "Cellular.APN.apn", NULL); |
| 4935 g_key_file_remove_key(keyfile, service->identifier, | 4941 g_key_file_remove_key(keyfile, service->identifier, |
| 4936 "Cellular.APN.username", NULL); | 4942 "Cellular.APN.username", NULL); |
| 4937 g_key_file_remove_key(keyfile, service->identifier, | 4943 g_key_file_remove_key(keyfile, service->identifier, |
| 4938 "Cellular.APN.password", NULL); | 4944 "Cellular.APN.password", NULL); |
| 4939 g_key_file_remove_key(keyfile, service->identifier, | 4945 g_key_file_remove_key(keyfile, service->identifier, |
| 4940 "Cellular.APN.network_id", NULL); | 4946 "Cellular.APN.network_id", NULL); |
| 4941 } | 4947 } |
| 4942 | 4948 |
| 4943 » data = g_key_file_to_data(keyfile, &length, NULL); | 4949 » return 0; |
| 4944 | |
| 4945 » if (g_file_set_contents(pathname, data, length, NULL) == FALSE) | |
| 4946 » » connman_error("Failed to store service information"); | |
| 4947 | |
| 4948 done: | |
| 4949 » g_free(data); | |
| 4950 | |
| 4951 » g_key_file_free(keyfile); | |
| 4952 | |
| 4953 » g_free(pathname); | |
| 4954 | |
| 4955 » return err; | |
| 4956 } | 4950 } |
| 4957 | 4951 |
| 4958 static struct connman_storage service_storage = { | 4952 static struct connman_storage service_storage = { |
| 4959 .name = "service", | 4953 .name = "service", |
| 4960 .priority = CONNMAN_STORAGE_PRIORITY_LOW, | 4954 .priority = CONNMAN_STORAGE_PRIORITY_LOW, |
| 4961 .service_load = service_load, | 4955 .service_load = service_load, |
| 4962 .service_save = service_save, | 4956 .service_save = service_save, |
| 4963 }; | 4957 }; |
| 4964 | 4958 |
| 4965 static struct connman_notifier service_notifier = { | 4959 static struct connman_notifier service_notifier = { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5006 service_list = NULL; | 5000 service_list = NULL; |
| 5007 | 5001 |
| 5008 g_hash_table_destroy(service_hash); | 5002 g_hash_table_destroy(service_hash); |
| 5009 service_hash = NULL; | 5003 service_hash = NULL; |
| 5010 | 5004 |
| 5011 connman_storage_unregister(&service_storage); | 5005 connman_storage_unregister(&service_storage); |
| 5012 connman_notifier_unregister(&service_notifier); | 5006 connman_notifier_unregister(&service_notifier); |
| 5013 | 5007 |
| 5014 dbus_connection_unref(connection); | 5008 dbus_connection_unref(connection); |
| 5015 } | 5009 } |
| OLD | NEW |