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)
206 wpa_config_read_reg_dword(hk, TEXT("ap_scan"), &config->ap_scan);
207 wpa_config_read_reg_dword(hk, TEXT("fast_reauth"),
208 &config->fast_reauth);
209 wpa_config_read_reg_dword(hk, TEXT("dot11RSNAConfigPMKLifetime"),
210 (int *) &config->dot11RSNAConfigPMKLifetime);
211 wpa_config_read_reg_dword(hk,
212 TEXT("dot11RSNAConfigPMKReauthThreshold"),
214 &config->dot11RSNAConfigPMKReauthThreshold);
215 wpa_config_read_reg_dword(hk, TEXT("dot11RSNAConfigSATimeout"),
216 (int *) &config->dot11RSNAConfigSATimeout);
217 wpa_config_read_reg_dword(hk, TEXT("update_config"),
218 &config->update_config);
220 if (wpa_config_read_reg_dword(hk, TEXT("eapol_version"),
221 &config->eapol_version) == 0) {
222 if (config->eapol_version < 1 ||
223 config->eapol_version > 2) {
224 wpa_printf(MSG_ERROR, "Invalid EAPOL version (%d)",
225 config->eapol_version);
230 config->ctrl_interface = wpa_config_read_reg_string(
231 hk, TEXT("ctrl_interface"));
234 if (wpa_config_read_global_uuid(config, hk))
236 config->device_name = wpa_config_read_reg_string(
237 hk, TEXT("device_name"));
238 config->manufacturer = wpa_config_read_reg_string(
239 hk, TEXT("manufacturer"));
240 config->model_name = wpa_config_read_reg_string(
241 hk, TEXT("model_name"));
242 config->serial_number = wpa_config_read_reg_string(
243 hk, TEXT("serial_number"));
245 char *t = wpa_config_read_reg_string(
246 hk, TEXT("device_type"));
247 if (t && wps_dev_type_str2bin(t, config->device_type))
251 config->config_methods = wpa_config_read_reg_string(
252 hk, TEXT("config_methods"));
253 if (wpa_config_read_global_os_version(config, hk))
255 wpa_config_read_reg_dword(hk, TEXT("wps_cred_processing"),
256 &config->wps_cred_processing);
257 #endif /* CONFIG_WPS */
259 config->p2p_ssid_postfix = wpa_config_read_reg_string(
260 hk, TEXT("p2p_ssid_postfix"));
261 wpa_config_read_reg_dword(hk, TEXT("p2p_group_idle"),
262 (int *) &config->p2p_group_idle);
263 #endif /* CONFIG_P2P */
265 wpa_config_read_reg_dword(hk, TEXT("bss_max_count"),
266 (int *) &config->bss_max_count);
267 wpa_config_read_reg_dword(hk, TEXT("filter_ssids"),
268 &config->filter_ssids);
269 wpa_config_read_reg_dword(hk, TEXT("max_num_sta"),
270 (int *) &config->max_num_sta);
271 wpa_config_read_reg_dword(hk, TEXT("disassoc_low_ack"),
272 (int *) &config->disassoc_low_ack);
274 return errors ? -1 : 0;
278 static struct wpa_ssid * wpa_config_read_network(HKEY hk, const TCHAR *netw,
284 struct wpa_ssid *ssid;
287 ret = RegOpenKeyEx(hk, netw, 0, KEY_QUERY_VALUE, &nhk);
288 if (ret != ERROR_SUCCESS) {
289 wpa_printf(MSG_DEBUG, "Could not open wpa_supplicant config "
290 "network '" TSTR "'", netw);
294 wpa_printf(MSG_MSGDUMP, "Start of a new network '" TSTR "'", netw);
295 ssid = os_zalloc(sizeof(*ssid));
302 wpa_config_set_network_defaults(ssid);
305 TCHAR name[255], data[1024];
306 DWORD namelen, datalen, type;
309 datalen = sizeof(data);
310 ret = RegEnumValue(nhk, i, name, &namelen, NULL, &type,
311 (LPBYTE) data, &datalen);
313 if (ret == ERROR_NO_MORE_ITEMS)
316 if (ret != ERROR_SUCCESS) {
317 wpa_printf(MSG_ERROR, "RegEnumValue failed: 0x%x",
324 name[namelen] = TEXT('\0');
328 data[datalen] = TEXT('\0');
330 wpa_unicode2ascii_inplace(name);
331 wpa_unicode2ascii_inplace(data);
332 if (wpa_config_set(ssid, (char *) name, (char *) data, 0) < 0)
338 if (ssid->passphrase) {
340 wpa_printf(MSG_ERROR, "Both PSK and passphrase "
341 "configured for network '" TSTR "'.", netw);
344 wpa_config_update_psk(ssid);
347 if ((ssid->group_cipher & WPA_CIPHER_CCMP) &&
348 !(ssid->pairwise_cipher & WPA_CIPHER_CCMP) &&
349 !(ssid->pairwise_cipher & WPA_CIPHER_NONE)) {
350 /* Group cipher cannot be stronger than the pairwise cipher. */
351 wpa_printf(MSG_DEBUG, "Removed CCMP from group cipher "
352 "list since it was not allowed for pairwise "
353 "cipher for network '" TSTR "'.", netw);
354 ssid->group_cipher &= ~WPA_CIPHER_CCMP;
358 wpa_config_free_ssid(ssid);
366 static int wpa_config_read_networks(struct wpa_config *config, HKEY hk)
369 struct wpa_ssid *ssid, *tail = NULL, *head = NULL;
374 ret = RegOpenKeyEx(hk, TEXT("networks"), 0, KEY_ENUMERATE_SUB_KEYS,
376 if (ret != ERROR_SUCCESS) {
377 wpa_printf(MSG_ERROR, "Could not open wpa_supplicant networks "
387 ret = RegEnumKeyEx(nhk, i, name, &namelen, NULL, NULL, NULL,
390 if (ret == ERROR_NO_MORE_ITEMS)
393 if (ret != ERROR_SUCCESS) {
394 wpa_printf(MSG_DEBUG, "RegEnumKeyEx failed: 0x%x",
401 name[namelen] = '\0';
403 ssid = wpa_config_read_network(nhk, name, i);
405 wpa_printf(MSG_ERROR, "Failed to parse network "
406 "profile '%s'.", name);
416 if (wpa_config_add_prio_network(config, ssid)) {
417 wpa_printf(MSG_ERROR, "Failed to add network profile "
418 "'%s' to priority list.", name);
428 return errors ? -1 : 0;
432 struct wpa_config * wpa_config_read(const char *name)
436 struct wpa_config *config;
440 config = wpa_config_alloc_empty(NULL, NULL);
443 wpa_printf(MSG_DEBUG, "Reading configuration profile '%s'", name);
446 _snwprintf(buf, 256, WPA_KEY_PREFIX TEXT("\\configs\\%S"), name);
448 os_snprintf(buf, 256, WPA_KEY_PREFIX TEXT("\\configs\\%s"), name);
451 ret = RegOpenKeyEx(WPA_KEY_ROOT, buf, 0, KEY_QUERY_VALUE, &hk);
452 if (ret != ERROR_SUCCESS) {
453 wpa_printf(MSG_ERROR, "Could not open wpa_supplicant "
454 "configuration registry HKLM\\" TSTR, buf);
459 if (wpa_config_read_global(config, hk))
462 if (wpa_config_read_networks(config, hk))
465 if (wpa_config_read_blobs(config, hk))
468 wpa_config_debug_dump_networks(config);
473 wpa_config_free(config);
481 static int wpa_config_write_reg_dword(HKEY hk, const TCHAR *name, int val,
488 RegDeleteValue(hk, name);
492 ret = RegSetValueEx(hk, name, 0, REG_DWORD, (LPBYTE) &_val,
494 if (ret != ERROR_SUCCESS) {
495 wpa_printf(MSG_ERROR, "WINREG: Failed to set %s=%d: error %d",
496 name, val, (int) GetLastError());
504 static int wpa_config_write_reg_string(HKEY hk, const char *name,
510 _name = wpa_strdup_tchar(name);
515 RegDeleteValue(hk, _name);
520 _val = wpa_strdup_tchar(val);
525 ret = RegSetValueEx(hk, _name, 0, REG_SZ, (BYTE *) _val,
526 (os_strlen(val) + 1) * sizeof(TCHAR));
527 if (ret != ERROR_SUCCESS) {
528 wpa_printf(MSG_ERROR, "WINREG: Failed to set %s='%s': "
529 "error %d", name, val, (int) GetLastError());
541 static int wpa_config_write_global(struct wpa_config *config, HKEY hk)
543 #ifdef CONFIG_CTRL_IFACE
544 wpa_config_write_reg_string(hk, "ctrl_interface",
545 config->ctrl_interface);
546 #endif /* CONFIG_CTRL_IFACE */
548 wpa_config_write_reg_dword(hk, TEXT("eapol_version"),
549 config->eapol_version,
550 DEFAULT_EAPOL_VERSION);
551 wpa_config_write_reg_dword(hk, TEXT("ap_scan"), config->ap_scan,
553 wpa_config_write_reg_dword(hk, TEXT("fast_reauth"),
554 config->fast_reauth, DEFAULT_FAST_REAUTH);
555 wpa_config_write_reg_dword(hk, TEXT("dot11RSNAConfigPMKLifetime"),
556 config->dot11RSNAConfigPMKLifetime, 0);
557 wpa_config_write_reg_dword(hk,
558 TEXT("dot11RSNAConfigPMKReauthThreshold"),
559 config->dot11RSNAConfigPMKReauthThreshold,
561 wpa_config_write_reg_dword(hk, TEXT("dot11RSNAConfigSATimeout"),
562 config->dot11RSNAConfigSATimeout, 0);
563 wpa_config_write_reg_dword(hk, TEXT("update_config"),
564 config->update_config,
567 if (!is_nil_uuid(config->uuid)) {
569 uuid_bin2str(config->uuid, buf, sizeof(buf));
570 wpa_config_write_reg_string(hk, "uuid", buf);
572 wpa_config_write_reg_string(hk, "device_name", config->device_name);
573 wpa_config_write_reg_string(hk, "manufacturer", config->manufacturer);
574 wpa_config_write_reg_string(hk, "model_name", config->model_name);
575 wpa_config_write_reg_string(hk, "model_number", config->model_number);
576 wpa_config_write_reg_string(hk, "serial_number",
577 config->serial_number);
579 char _buf[WPS_DEV_TYPE_BUFSIZE], *buf;
580 buf = wps_dev_type_bin2str(config->device_type,
582 wpa_config_write_reg_string(hk, "device_type", buf);
584 wpa_config_write_reg_string(hk, "config_methods",
585 config->config_methods);
586 if (WPA_GET_BE32(config->os_version)) {
588 os_snprintf(vbuf, sizeof(vbuf), "%08x",
589 WPA_GET_BE32(config->os_version));
590 wpa_config_write_reg_string(hk, "os_version", vbuf);
592 wpa_config_write_reg_dword(hk, TEXT("wps_cred_processing"),
593 config->wps_cred_processing, 0);
594 #endif /* CONFIG_WPS */
596 wpa_config_write_reg_string(hk, "p2p_ssid_postfix",
597 config->p2p_ssid_postfix);
598 wpa_config_write_reg_dword(hk, TEXT("p2p_group_idle"),
599 config->p2p_group_idle, 0);
600 #endif /* CONFIG_P2P */
602 wpa_config_write_reg_dword(hk, TEXT("bss_max_count"),
603 config->bss_max_count,
604 DEFAULT_BSS_MAX_COUNT);
605 wpa_config_write_reg_dword(hk, TEXT("filter_ssids"),
606 config->filter_ssids, 0);
607 wpa_config_write_reg_dword(hk, TEXT("max_num_sta"),
608 config->max_num_sta, DEFAULT_MAX_NUM_STA);
609 wpa_config_write_reg_dword(hk, TEXT("disassoc_low_ack"),
610 config->disassoc_low_ack, 0);
616 static int wpa_config_delete_subkeys(HKEY hk, const TCHAR *key)
622 ret = RegOpenKeyEx(hk, key, 0, KEY_ENUMERATE_SUB_KEYS | DELETE, &nhk);
623 if (ret != ERROR_SUCCESS) {
624 wpa_printf(MSG_DEBUG, "WINREG: Could not open key '" TSTR
625 "' for subkey deletion: error 0x%x (%d)", key,
626 (unsigned int) ret, (int) GetLastError());
635 ret = RegEnumKeyEx(nhk, i, name, &namelen, NULL, NULL, NULL,
638 if (ret == ERROR_NO_MORE_ITEMS)
641 if (ret != ERROR_SUCCESS) {
642 wpa_printf(MSG_DEBUG, "RegEnumKeyEx failed: 0x%x (%d)",
643 (unsigned int) ret, (int) GetLastError());
649 name[namelen] = TEXT('\0');
651 ret = RegDeleteKey(nhk, name);
652 if (ret != ERROR_SUCCESS) {
653 wpa_printf(MSG_DEBUG, "RegDeleteKey failed: 0x%x (%d)",
654 (unsigned int) ret, (int) GetLastError());
661 return errors ? -1 : 0;
665 static void write_str(HKEY hk, const char *field, struct wpa_ssid *ssid)
667 char *value = wpa_config_get(ssid, field);
670 wpa_config_write_reg_string(hk, field, value);
675 static void write_int(HKEY hk, const char *field, int value, int def)
680 os_snprintf(val, sizeof(val), "%d", value);
681 wpa_config_write_reg_string(hk, field, val);
685 static void write_bssid(HKEY hk, struct wpa_ssid *ssid)
687 char *value = wpa_config_get(ssid, "bssid");
690 wpa_config_write_reg_string(hk, "bssid", value);
695 static void write_psk(HKEY hk, struct wpa_ssid *ssid)
697 char *value = wpa_config_get(ssid, "psk");
700 wpa_config_write_reg_string(hk, "psk", value);
705 static void write_proto(HKEY hk, struct wpa_ssid *ssid)
709 if (ssid->proto == DEFAULT_PROTO)
712 value = wpa_config_get(ssid, "proto");
716 wpa_config_write_reg_string(hk, "proto", value);
721 static void write_key_mgmt(HKEY hk, struct wpa_ssid *ssid)
725 if (ssid->key_mgmt == DEFAULT_KEY_MGMT)
728 value = wpa_config_get(ssid, "key_mgmt");
732 wpa_config_write_reg_string(hk, "key_mgmt", value);
737 static void write_pairwise(HKEY hk, struct wpa_ssid *ssid)
741 if (ssid->pairwise_cipher == DEFAULT_PAIRWISE)
744 value = wpa_config_get(ssid, "pairwise");
748 wpa_config_write_reg_string(hk, "pairwise", value);
753 static void write_group(HKEY hk, struct wpa_ssid *ssid)
757 if (ssid->group_cipher == DEFAULT_GROUP)
760 value = wpa_config_get(ssid, "group");
764 wpa_config_write_reg_string(hk, "group", value);
769 static void write_auth_alg(HKEY hk, struct wpa_ssid *ssid)
773 if (ssid->auth_alg == 0)
776 value = wpa_config_get(ssid, "auth_alg");
780 wpa_config_write_reg_string(hk, "auth_alg", value);
785 #ifdef IEEE8021X_EAPOL
786 static void write_eap(HKEY hk, struct wpa_ssid *ssid)
790 value = wpa_config_get(ssid, "eap");
795 wpa_config_write_reg_string(hk, "eap", value);
798 #endif /* IEEE8021X_EAPOL */
801 static void write_wep_key(HKEY hk, int idx, struct wpa_ssid *ssid)
803 char field[20], *value;
805 os_snprintf(field, sizeof(field), "wep_key%d", idx);
806 value = wpa_config_get(ssid, field);
808 wpa_config_write_reg_string(hk, field, value);
814 static int wpa_config_write_network(HKEY hk, struct wpa_ssid *ssid, int id)
821 ret = RegOpenKeyEx(hk, TEXT("networks"), 0, KEY_CREATE_SUB_KEY, &nhk);
822 if (ret != ERROR_SUCCESS) {
823 wpa_printf(MSG_DEBUG, "WINREG: Could not open networks key "
824 "for subkey addition: error 0x%x (%d)",
825 (unsigned int) ret, (int) GetLastError());
830 wsprintf(name, L"%04d", id);
832 os_snprintf(name, sizeof(name), "%04d", id);
834 ret = RegCreateKeyEx(nhk, name, 0, NULL, 0, KEY_WRITE, NULL, &netw,
837 if (ret != ERROR_SUCCESS) {
838 wpa_printf(MSG_DEBUG, "WINREG: Could not add network key '%s':"
840 name, (unsigned int) ret, (int) GetLastError());
844 #define STR(t) write_str(netw, #t, ssid)
845 #define INT(t) write_int(netw, #t, ssid->t, 0)
846 #define INTe(t) write_int(netw, #t, ssid->eap.t, 0)
847 #define INT_DEF(t, def) write_int(netw, #t, ssid->t, def)
848 #define INT_DEFe(t, def) write_int(netw, #t, ssid->eap.t, def)
852 write_bssid(netw, ssid);
853 write_psk(netw, ssid);
854 write_proto(netw, ssid);
855 write_key_mgmt(netw, ssid);
856 write_pairwise(netw, ssid);
857 write_group(netw, ssid);
858 write_auth_alg(netw, ssid);
859 #ifdef IEEE8021X_EAPOL
860 write_eap(netw, ssid);
862 STR(anonymous_identity);
868 STR(private_key_passwd);
871 STR(altsubject_match);
876 STR(private_key2_passwd);
879 STR(altsubject_match2);
895 INT_DEF(eapol_flags, DEFAULT_EAPOL_FLAGS);
896 #endif /* IEEE8021X_EAPOL */
897 for (i = 0; i < 4; i++)
898 write_wep_key(netw, i, ssid);
901 #ifdef IEEE8021X_EAPOL
902 INT_DEF(eap_workaround, DEFAULT_EAP_WORKAROUND);
904 INT_DEFe(fragment_size, DEFAULT_FRAGMENT_SIZE);
905 #endif /* IEEE8021X_EAPOL */
907 INT(proactive_key_caching);
910 #ifdef CONFIG_IEEE80211W
912 #endif /* CONFIG_IEEE80211W */
921 return errors ? -1 : 0;
925 static int wpa_config_write_blob(HKEY hk, struct wpa_config_blob *blob)
931 ret = RegCreateKeyEx(hk, TEXT("blobs"), 0, NULL, 0, KEY_WRITE, NULL,
933 if (ret != ERROR_SUCCESS) {
934 wpa_printf(MSG_DEBUG, "WINREG: Could not add blobs key: "
936 (unsigned int) ret, (int) GetLastError());
940 name = wpa_strdup_tchar(blob->name);
941 ret = RegSetValueEx(bhk, name, 0, REG_BINARY, blob->data,
943 if (ret != ERROR_SUCCESS) {
944 wpa_printf(MSG_ERROR, "WINREG: Failed to set blob %s': "
945 "error 0x%x (%d)", blob->name, (unsigned int) ret,
946 (int) GetLastError());
959 int wpa_config_write(const char *name, struct wpa_config *config)
965 struct wpa_ssid *ssid;
966 struct wpa_config_blob *blob;
969 wpa_printf(MSG_DEBUG, "Writing configuration file '%s'", name);
972 _snwprintf(buf, 256, WPA_KEY_PREFIX TEXT("\\configs\\%S"), name);
974 os_snprintf(buf, 256, WPA_KEY_PREFIX TEXT("\\configs\\%s"), name);
977 ret = RegOpenKeyEx(WPA_KEY_ROOT, buf, 0, KEY_SET_VALUE | DELETE, &hk);
978 if (ret != ERROR_SUCCESS) {
979 wpa_printf(MSG_ERROR, "Could not open wpa_supplicant "
980 "configuration registry %s: error %d", buf,
981 (int) GetLastError());
985 if (wpa_config_write_global(config, hk)) {
986 wpa_printf(MSG_ERROR, "Failed to write global configuration "
991 wpa_config_delete_subkeys(hk, TEXT("networks"));
992 for (ssid = config->ssid, id = 0; ssid; ssid = ssid->next, id++) {
993 if (ssid->key_mgmt == WPA_KEY_MGMT_WPS)
994 continue; /* do not save temporary WPS networks */
995 if (wpa_config_write_network(hk, ssid, id))
999 RegDeleteKey(hk, TEXT("blobs"));
1000 for (blob = config->blobs; blob; blob = blob->next) {
1001 if (wpa_config_write_blob(hk, blob))
1007 wpa_printf(MSG_DEBUG, "Configuration '%s' written %ssuccessfully",
1008 name, errors ? "un" : "");
1009 return errors ? -1 : 0;