2 * WPA Supplicant / Configuration backend: Windows registry
3 * Copyright (c) 2003-2008, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
8 * This file implements a configuration backend for Windows registry. All the
9 * configuration information is stored in the registry and the format for
10 * network configuration fields is same as described in the sample
11 * configuration file, wpa_supplicant.conf.
13 * Configuration data is in
14 * \a HKEY_LOCAL_MACHINE\\SOFTWARE\\%wpa_supplicant\\configs
15 * key. Each configuration profile has its own key under this. In terms of text
16 * files, each profile would map to a separate text file with possibly multiple
17 * networks. Under each profile, there is a networks key that lists all
18 * networks as a subkey. Each network has set of values in the same way as
19 * network block in the configuration file. In addition, blobs subkey has
20 * possible blobs as values.
22 * Example network configuration block:
24 HKEY_LOCAL_MACHINE\SOFTWARE\wpa_supplicant\configs\test\networks\0000
37 #define WPA_KEY_ROOT HKEY_LOCAL_MACHINE
39 #ifndef WPA_KEY_PREFIX
40 #define WPA_KEY_PREFIX TEXT("SOFTWARE\\wpa_supplicant")
50 static int wpa_config_read_blobs(struct wpa_config *config, HKEY hk)
52 struct wpa_config_blob *blob;
58 ret = RegOpenKeyEx(hk, TEXT("blobs"), 0, KEY_QUERY_VALUE, &bhk);
59 if (ret != ERROR_SUCCESS) {
60 wpa_printf(MSG_DEBUG, "Could not open wpa_supplicant config "
62 return 0; /* assume no blobs */
69 DWORD namelen, datalen, type;
72 datalen = sizeof(data);
73 ret = RegEnumValue(bhk, i, name, &namelen, NULL, &type,
74 (LPBYTE) data, &datalen);
76 if (ret == ERROR_NO_MORE_ITEMS)
79 if (ret != ERROR_SUCCESS) {
80 wpa_printf(MSG_DEBUG, "RegEnumValue failed: 0x%x",
85 if (namelen >= TNAMELEN)
86 namelen = TNAMELEN - 1;
87 name[namelen] = TEXT('\0');
88 wpa_unicode2ascii_inplace(name);
90 if (datalen >= sizeof(data))
91 datalen = sizeof(data) - 1;
93 wpa_printf(MSG_MSGDUMP, "blob %d: field='%s' len %d",
94 (int) i, name, (int) datalen);
96 blob = os_zalloc(sizeof(*blob));
101 blob->name = os_strdup((char *) name);
102 blob->data = os_malloc(datalen);
103 if (blob->name == NULL || blob->data == NULL) {
104 wpa_config_free_blob(blob);
108 os_memcpy(blob->data, data, datalen);
111 wpa_config_set_blob(config, blob);
116 return errors ? -1 : 0;
120 static int wpa_config_read_reg_dword(HKEY hk, const TCHAR *name, int *_val)
125 buflen = sizeof(val);
126 ret = RegQueryValueEx(hk, name, NULL, NULL, (LPBYTE) &val, &buflen);
127 if (ret == ERROR_SUCCESS && buflen == sizeof(val)) {
128 wpa_printf(MSG_DEBUG, TSTR "=%d", name, (int) val);
137 static char * wpa_config_read_reg_string(HKEY hk, const TCHAR *name)
144 ret = RegQueryValueEx(hk, name, NULL, NULL, NULL, &buflen);
145 if (ret != ERROR_SUCCESS)
147 val = os_malloc(buflen);
151 ret = RegQueryValueEx(hk, name, NULL, NULL, (LPBYTE) val, &buflen);
152 if (ret != ERROR_SUCCESS) {
157 wpa_unicode2ascii_inplace(val);
158 wpa_printf(MSG_DEBUG, TSTR "=%s", name, (char *) val);
164 static int wpa_config_read_global_uuid(struct wpa_config *config, HKEY hk)
169 str = wpa_config_read_reg_string(hk, TEXT("uuid"));
173 if (uuid_str2bin(str, config->uuid))
182 static int wpa_config_read_global_os_version(struct wpa_config *config,
188 str = wpa_config_read_reg_string(hk, TEXT("os_version"));
192 if (hexstr2bin(str, config->os_version, 4))
199 #endif /* CONFIG_WPS */
202 static int wpa_config_read_global(struct wpa_config *config, HKEY hk)
207 wpa_config_read_reg_dword(hk, TEXT("ap_scan"), &config->ap_scan);
208 wpa_config_read_reg_dword(hk, TEXT("fast_reauth"),
209 &config->fast_reauth);
210 wpa_config_read_reg_dword(hk, TEXT("dot11RSNAConfigPMKLifetime"),
211 (int *) &config->dot11RSNAConfigPMKLifetime);
212 wpa_config_read_reg_dword(hk,
213 TEXT("dot11RSNAConfigPMKReauthThreshold"),
215 &config->dot11RSNAConfigPMKReauthThreshold);
216 wpa_config_read_reg_dword(hk, TEXT("dot11RSNAConfigSATimeout"),
217 (int *) &config->dot11RSNAConfigSATimeout);
218 wpa_config_read_reg_dword(hk, TEXT("update_config"),
219 &config->update_config);
221 if (wpa_config_read_reg_dword(hk, TEXT("eapol_version"),
222 &config->eapol_version) == 0) {
223 if (config->eapol_version < 1 ||
224 config->eapol_version > 2) {
225 wpa_printf(MSG_ERROR, "Invalid EAPOL version (%d)",
226 config->eapol_version);
231 config->ctrl_interface = wpa_config_read_reg_string(
232 hk, TEXT("ctrl_interface"));
235 if (wpa_config_read_global_uuid(config, hk))
237 config->device_name = wpa_config_read_reg_string(
238 hk, TEXT("device_name"));
239 config->manufacturer = wpa_config_read_reg_string(
240 hk, TEXT("manufacturer"));
241 config->model_name = wpa_config_read_reg_string(
242 hk, TEXT("model_name"));
243 config->serial_number = wpa_config_read_reg_string(
244 hk, TEXT("serial_number"));
246 char *t = wpa_config_read_reg_string(
247 hk, TEXT("device_type"));
248 if (t && wps_dev_type_str2bin(t, config->device_type))
252 config->config_methods = wpa_config_read_reg_string(
253 hk, TEXT("config_methods"));
254 if (wpa_config_read_global_os_version(config, hk))
256 wpa_config_read_reg_dword(hk, TEXT("wps_cred_processing"),
257 &config->wps_cred_processing);
258 #endif /* CONFIG_WPS */
260 config->p2p_ssid_postfix = wpa_config_read_reg_string(
261 hk, TEXT("p2p_ssid_postfix"));
262 wpa_config_read_reg_dword(hk, TEXT("p2p_group_idle"),
263 (int *) &config->p2p_group_idle);
264 #endif /* CONFIG_P2P */
266 wpa_config_read_reg_dword(hk, TEXT("bss_max_count"),
267 (int *) &config->bss_max_count);
268 wpa_config_read_reg_dword(hk, TEXT("filter_ssids"),
269 &config->filter_ssids);
270 wpa_config_read_reg_dword(hk, TEXT("max_num_sta"),
271 (int *) &config->max_num_sta);
272 wpa_config_read_reg_dword(hk, TEXT("disassoc_low_ack"),
273 (int *) &config->disassoc_low_ack);
275 wpa_config_read_reg_dword(hk, TEXT("okc"), &config->okc);
276 wpa_config_read_reg_dword(hk, TEXT("pmf"), &val);
279 return errors ? -1 : 0;
283 static struct wpa_ssid * wpa_config_read_network(HKEY hk, const TCHAR *netw,
289 struct wpa_ssid *ssid;
292 ret = RegOpenKeyEx(hk, netw, 0, KEY_QUERY_VALUE, &nhk);
293 if (ret != ERROR_SUCCESS) {
294 wpa_printf(MSG_DEBUG, "Could not open wpa_supplicant config "
295 "network '" TSTR "'", netw);
299 wpa_printf(MSG_MSGDUMP, "Start of a new network '" TSTR "'", netw);
300 ssid = os_zalloc(sizeof(*ssid));
305 dl_list_init(&ssid->psk_list);
308 wpa_config_set_network_defaults(ssid);
311 TCHAR name[255], data[1024];
312 DWORD namelen, datalen, type;
315 datalen = sizeof(data);
316 ret = RegEnumValue(nhk, i, name, &namelen, NULL, &type,
317 (LPBYTE) data, &datalen);
319 if (ret == ERROR_NO_MORE_ITEMS)
322 if (ret != ERROR_SUCCESS) {
323 wpa_printf(MSG_ERROR, "RegEnumValue failed: 0x%x",
330 name[namelen] = TEXT('\0');
334 data[datalen] = TEXT('\0');
336 wpa_unicode2ascii_inplace(name);
337 wpa_unicode2ascii_inplace(data);
338 if (wpa_config_set(ssid, (char *) name, (char *) data, 0) < 0)
344 if (ssid->passphrase) {
346 wpa_printf(MSG_ERROR, "Both PSK and passphrase "
347 "configured for network '" TSTR "'.", netw);
350 wpa_config_update_psk(ssid);
353 if ((ssid->group_cipher & WPA_CIPHER_CCMP) &&
354 !(ssid->pairwise_cipher & WPA_CIPHER_CCMP) &&
355 !(ssid->pairwise_cipher & WPA_CIPHER_NONE)) {
356 /* Group cipher cannot be stronger than the pairwise cipher. */
357 wpa_printf(MSG_DEBUG, "Removed CCMP from group cipher "
358 "list since it was not allowed for pairwise "
359 "cipher for network '" TSTR "'.", netw);
360 ssid->group_cipher &= ~WPA_CIPHER_CCMP;
364 wpa_config_free_ssid(ssid);
372 static int wpa_config_read_networks(struct wpa_config *config, HKEY hk)
375 struct wpa_ssid *ssid, *tail = NULL, *head = NULL;
380 ret = RegOpenKeyEx(hk, TEXT("networks"), 0, KEY_ENUMERATE_SUB_KEYS,
382 if (ret != ERROR_SUCCESS) {
383 wpa_printf(MSG_ERROR, "Could not open wpa_supplicant networks "
393 ret = RegEnumKeyEx(nhk, i, name, &namelen, NULL, NULL, NULL,
396 if (ret == ERROR_NO_MORE_ITEMS)
399 if (ret != ERROR_SUCCESS) {
400 wpa_printf(MSG_DEBUG, "RegEnumKeyEx failed: 0x%x",
407 name[namelen] = '\0';
409 ssid = wpa_config_read_network(nhk, name, i);
411 wpa_printf(MSG_ERROR, "Failed to parse network "
412 "profile '%s'.", name);
422 if (wpa_config_add_prio_network(config, ssid)) {
423 wpa_printf(MSG_ERROR, "Failed to add network profile "
424 "'%s' to priority list.", name);
434 return errors ? -1 : 0;
438 struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp)
442 struct wpa_config *config;
451 config = wpa_config_alloc_empty(NULL, NULL);
454 wpa_printf(MSG_DEBUG, "Reading configuration profile '%s'", name);
457 _snwprintf(buf, 256, WPA_KEY_PREFIX TEXT("\\configs\\%S"), name);
459 os_snprintf(buf, 256, WPA_KEY_PREFIX TEXT("\\configs\\%s"), name);
462 ret = RegOpenKeyEx(WPA_KEY_ROOT, buf, 0, KEY_QUERY_VALUE, &hk);
463 if (ret != ERROR_SUCCESS) {
464 wpa_printf(MSG_ERROR, "Could not open wpa_supplicant "
465 "configuration registry HKLM\\" TSTR, buf);
470 if (wpa_config_read_global(config, hk))
473 if (wpa_config_read_networks(config, hk))
476 if (wpa_config_read_blobs(config, hk))
479 wpa_config_debug_dump_networks(config);
484 wpa_config_free(config);
492 static int wpa_config_write_reg_dword(HKEY hk, const TCHAR *name, int val,
499 RegDeleteValue(hk, name);
503 ret = RegSetValueEx(hk, name, 0, REG_DWORD, (LPBYTE) &_val,
505 if (ret != ERROR_SUCCESS) {
506 wpa_printf(MSG_ERROR, "WINREG: Failed to set %s=%d: error %d",
507 name, val, (int) GetLastError());
515 static int wpa_config_write_reg_string(HKEY hk, const char *name,
521 _name = wpa_strdup_tchar(name);
526 RegDeleteValue(hk, _name);
531 _val = wpa_strdup_tchar(val);
536 ret = RegSetValueEx(hk, _name, 0, REG_SZ, (BYTE *) _val,
537 (os_strlen(val) + 1) * sizeof(TCHAR));
538 if (ret != ERROR_SUCCESS) {
539 wpa_printf(MSG_ERROR, "WINREG: Failed to set %s='%s': "
540 "error %d", name, val, (int) GetLastError());
552 static int wpa_config_write_global(struct wpa_config *config, HKEY hk)
554 #ifdef CONFIG_CTRL_IFACE
555 wpa_config_write_reg_string(hk, "ctrl_interface",
556 config->ctrl_interface);
557 #endif /* CONFIG_CTRL_IFACE */
559 wpa_config_write_reg_dword(hk, TEXT("eapol_version"),
560 config->eapol_version,
561 DEFAULT_EAPOL_VERSION);
562 wpa_config_write_reg_dword(hk, TEXT("ap_scan"), config->ap_scan,
564 wpa_config_write_reg_dword(hk, TEXT("fast_reauth"),
565 config->fast_reauth, DEFAULT_FAST_REAUTH);
566 wpa_config_write_reg_dword(hk, TEXT("dot11RSNAConfigPMKLifetime"),
567 config->dot11RSNAConfigPMKLifetime, 0);
568 wpa_config_write_reg_dword(hk,
569 TEXT("dot11RSNAConfigPMKReauthThreshold"),
570 config->dot11RSNAConfigPMKReauthThreshold,
572 wpa_config_write_reg_dword(hk, TEXT("dot11RSNAConfigSATimeout"),
573 config->dot11RSNAConfigSATimeout, 0);
574 wpa_config_write_reg_dword(hk, TEXT("update_config"),
575 config->update_config,
578 if (!is_nil_uuid(config->uuid)) {
580 uuid_bin2str(config->uuid, buf, sizeof(buf));
581 wpa_config_write_reg_string(hk, "uuid", buf);
583 wpa_config_write_reg_string(hk, "device_name", config->device_name);
584 wpa_config_write_reg_string(hk, "manufacturer", config->manufacturer);
585 wpa_config_write_reg_string(hk, "model_name", config->model_name);
586 wpa_config_write_reg_string(hk, "model_number", config->model_number);
587 wpa_config_write_reg_string(hk, "serial_number",
588 config->serial_number);
590 char _buf[WPS_DEV_TYPE_BUFSIZE], *buf;
591 buf = wps_dev_type_bin2str(config->device_type,
593 wpa_config_write_reg_string(hk, "device_type", buf);
595 wpa_config_write_reg_string(hk, "config_methods",
596 config->config_methods);
597 if (WPA_GET_BE32(config->os_version)) {
599 os_snprintf(vbuf, sizeof(vbuf), "%08x",
600 WPA_GET_BE32(config->os_version));
601 wpa_config_write_reg_string(hk, "os_version", vbuf);
603 wpa_config_write_reg_dword(hk, TEXT("wps_cred_processing"),
604 config->wps_cred_processing, 0);
605 #endif /* CONFIG_WPS */
607 wpa_config_write_reg_string(hk, "p2p_ssid_postfix",
608 config->p2p_ssid_postfix);
609 wpa_config_write_reg_dword(hk, TEXT("p2p_group_idle"),
610 config->p2p_group_idle, 0);
611 #endif /* CONFIG_P2P */
613 wpa_config_write_reg_dword(hk, TEXT("bss_max_count"),
614 config->bss_max_count,
615 DEFAULT_BSS_MAX_COUNT);
616 wpa_config_write_reg_dword(hk, TEXT("filter_ssids"),
617 config->filter_ssids, 0);
618 wpa_config_write_reg_dword(hk, TEXT("max_num_sta"),
619 config->max_num_sta, DEFAULT_MAX_NUM_STA);
620 wpa_config_write_reg_dword(hk, TEXT("disassoc_low_ack"),
621 config->disassoc_low_ack, 0);
623 wpa_config_write_reg_dword(hk, TEXT("okc"), config->okc, 0);
624 wpa_config_write_reg_dword(hk, TEXT("pmf"), config->pmf, 0);
626 wpa_config_write_reg_dword(hk, TEXT("external_sim"),
627 config->external_sim, 0);
633 static int wpa_config_delete_subkeys(HKEY hk, const TCHAR *key)
639 ret = RegOpenKeyEx(hk, key, 0, KEY_ENUMERATE_SUB_KEYS | DELETE, &nhk);
640 if (ret != ERROR_SUCCESS) {
641 wpa_printf(MSG_DEBUG, "WINREG: Could not open key '" TSTR
642 "' for subkey deletion: error 0x%x (%d)", key,
643 (unsigned int) ret, (int) GetLastError());
652 ret = RegEnumKeyEx(nhk, i, name, &namelen, NULL, NULL, NULL,
655 if (ret == ERROR_NO_MORE_ITEMS)
658 if (ret != ERROR_SUCCESS) {
659 wpa_printf(MSG_DEBUG, "RegEnumKeyEx failed: 0x%x (%d)",
660 (unsigned int) ret, (int) GetLastError());
666 name[namelen] = TEXT('\0');
668 ret = RegDeleteKey(nhk, name);
669 if (ret != ERROR_SUCCESS) {
670 wpa_printf(MSG_DEBUG, "RegDeleteKey failed: 0x%x (%d)",
671 (unsigned int) ret, (int) GetLastError());
678 return errors ? -1 : 0;
682 static void write_str(HKEY hk, const char *field, struct wpa_ssid *ssid)
684 char *value = wpa_config_get(ssid, field);
687 wpa_config_write_reg_string(hk, field, value);
692 static void write_int(HKEY hk, const char *field, int value, int def)
697 os_snprintf(val, sizeof(val), "%d", value);
698 wpa_config_write_reg_string(hk, field, val);
702 static void write_bssid(HKEY hk, struct wpa_ssid *ssid)
704 char *value = wpa_config_get(ssid, "bssid");
707 wpa_config_write_reg_string(hk, "bssid", value);
712 static void write_psk(HKEY hk, struct wpa_ssid *ssid)
714 char *value = wpa_config_get(ssid, "psk");
717 wpa_config_write_reg_string(hk, "psk", value);
722 static void write_proto(HKEY hk, struct wpa_ssid *ssid)
726 if (ssid->proto == DEFAULT_PROTO)
729 value = wpa_config_get(ssid, "proto");
733 wpa_config_write_reg_string(hk, "proto", value);
738 static void write_key_mgmt(HKEY hk, struct wpa_ssid *ssid)
742 if (ssid->key_mgmt == DEFAULT_KEY_MGMT)
745 value = wpa_config_get(ssid, "key_mgmt");
749 wpa_config_write_reg_string(hk, "key_mgmt", value);
754 static void write_pairwise(HKEY hk, struct wpa_ssid *ssid)
758 if (ssid->pairwise_cipher == DEFAULT_PAIRWISE)
761 value = wpa_config_get(ssid, "pairwise");
765 wpa_config_write_reg_string(hk, "pairwise", value);
770 static void write_group(HKEY hk, struct wpa_ssid *ssid)
774 if (ssid->group_cipher == DEFAULT_GROUP)
777 value = wpa_config_get(ssid, "group");
781 wpa_config_write_reg_string(hk, "group", value);
786 static void write_auth_alg(HKEY hk, struct wpa_ssid *ssid)
790 if (ssid->auth_alg == 0)
793 value = wpa_config_get(ssid, "auth_alg");
797 wpa_config_write_reg_string(hk, "auth_alg", value);
802 #ifdef IEEE8021X_EAPOL
803 static void write_eap(HKEY hk, struct wpa_ssid *ssid)
807 value = wpa_config_get(ssid, "eap");
812 wpa_config_write_reg_string(hk, "eap", value);
815 #endif /* IEEE8021X_EAPOL */
818 static void write_wep_key(HKEY hk, int idx, struct wpa_ssid *ssid)
820 char field[20], *value;
822 os_snprintf(field, sizeof(field), "wep_key%d", idx);
823 value = wpa_config_get(ssid, field);
825 wpa_config_write_reg_string(hk, field, value);
831 static int wpa_config_write_network(HKEY hk, struct wpa_ssid *ssid, int id)
838 ret = RegOpenKeyEx(hk, TEXT("networks"), 0, KEY_CREATE_SUB_KEY, &nhk);
839 if (ret != ERROR_SUCCESS) {
840 wpa_printf(MSG_DEBUG, "WINREG: Could not open networks key "
841 "for subkey addition: error 0x%x (%d)",
842 (unsigned int) ret, (int) GetLastError());
847 wsprintf(name, L"%04d", id);
849 os_snprintf(name, sizeof(name), "%04d", id);
851 ret = RegCreateKeyEx(nhk, name, 0, NULL, 0, KEY_WRITE, NULL, &netw,
854 if (ret != ERROR_SUCCESS) {
855 wpa_printf(MSG_DEBUG, "WINREG: Could not add network key '%s':"
857 name, (unsigned int) ret, (int) GetLastError());
861 #define STR(t) write_str(netw, #t, ssid)
862 #define INT(t) write_int(netw, #t, ssid->t, 0)
863 #define INTe(t) write_int(netw, #t, ssid->eap.t, 0)
864 #define INT_DEF(t, def) write_int(netw, #t, ssid->t, def)
865 #define INT_DEFe(t, def) write_int(netw, #t, ssid->eap.t, def)
869 write_bssid(netw, ssid);
870 write_psk(netw, ssid);
871 write_proto(netw, ssid);
872 write_key_mgmt(netw, ssid);
873 write_pairwise(netw, ssid);
874 write_group(netw, ssid);
875 write_auth_alg(netw, ssid);
876 #ifdef IEEE8021X_EAPOL
877 write_eap(netw, ssid);
879 STR(anonymous_identity);
885 STR(private_key_passwd);
888 STR(altsubject_match);
893 STR(private_key2_passwd);
896 STR(altsubject_match2);
912 INT_DEF(eapol_flags, DEFAULT_EAPOL_FLAGS);
913 #endif /* IEEE8021X_EAPOL */
914 for (i = 0; i < 4; i++)
915 write_wep_key(netw, i, ssid);
918 #ifdef IEEE8021X_EAPOL
919 INT_DEF(eap_workaround, DEFAULT_EAP_WORKAROUND);
921 INT_DEFe(fragment_size, DEFAULT_FRAGMENT_SIZE);
922 #endif /* IEEE8021X_EAPOL */
924 write_int(netw, "proactive_key_caching", ssid->proactive_key_caching,
928 #ifdef CONFIG_IEEE80211W
929 write_int(netw, "ieee80211w", ssid->ieee80211w,
930 MGMT_FRAME_PROTECTION_DEFAULT);
931 #endif /* CONFIG_IEEE80211W */
940 return errors ? -1 : 0;
944 static int wpa_config_write_blob(HKEY hk, struct wpa_config_blob *blob)
950 ret = RegCreateKeyEx(hk, TEXT("blobs"), 0, NULL, 0, KEY_WRITE, NULL,
952 if (ret != ERROR_SUCCESS) {
953 wpa_printf(MSG_DEBUG, "WINREG: Could not add blobs key: "
955 (unsigned int) ret, (int) GetLastError());
959 name = wpa_strdup_tchar(blob->name);
960 ret = RegSetValueEx(bhk, name, 0, REG_BINARY, blob->data,
962 if (ret != ERROR_SUCCESS) {
963 wpa_printf(MSG_ERROR, "WINREG: Failed to set blob %s': "
964 "error 0x%x (%d)", blob->name, (unsigned int) ret,
965 (int) GetLastError());
978 int wpa_config_write(const char *name, struct wpa_config *config)
984 struct wpa_ssid *ssid;
985 struct wpa_config_blob *blob;
988 wpa_printf(MSG_DEBUG, "Writing configuration file '%s'", name);
991 _snwprintf(buf, 256, WPA_KEY_PREFIX TEXT("\\configs\\%S"), name);
993 os_snprintf(buf, 256, WPA_KEY_PREFIX TEXT("\\configs\\%s"), name);
996 ret = RegOpenKeyEx(WPA_KEY_ROOT, buf, 0, KEY_SET_VALUE | DELETE, &hk);
997 if (ret != ERROR_SUCCESS) {
998 wpa_printf(MSG_ERROR, "Could not open wpa_supplicant "
999 "configuration registry %s: error %d", buf,
1000 (int) GetLastError());
1004 if (wpa_config_write_global(config, hk)) {
1005 wpa_printf(MSG_ERROR, "Failed to write global configuration "
1010 wpa_config_delete_subkeys(hk, TEXT("networks"));
1011 for (ssid = config->ssid, id = 0; ssid; ssid = ssid->next, id++) {
1012 if (ssid->key_mgmt == WPA_KEY_MGMT_WPS)
1013 continue; /* do not save temporary WPS networks */
1014 if (wpa_config_write_network(hk, ssid, id))
1018 RegDeleteKey(hk, TEXT("blobs"));
1019 for (blob = config->blobs; blob; blob = blob->next) {
1020 if (wpa_config_write_blob(hk, blob))
1026 wpa_printf(MSG_DEBUG, "Configuration '%s' written %ssuccessfully",
1027 name, errors ? "un" : "");
1028 return errors ? -1 : 0;