2 * WPA Supplicant / Configuration backend: text file
3 * Copyright (c) 2003-2012, 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 text files. All the
9 * configuration information is stored in a text file that uses a format
10 * described in the sample configuration file, wpa_supplicant.conf.
23 * wpa_config_get_line - Read the next configuration file line
24 * @s: Buffer for the line
25 * @size: The buffer length
26 * @stream: File stream to read from
27 * @line: Pointer to a variable storing the file line number
28 * @_pos: Buffer for the pointer to the beginning of data on the text line or
29 * %NULL if not needed (returned value used instead)
30 * Returns: Pointer to the beginning of data on the text line or %NULL if no
31 * more text lines are available.
33 * This function reads the next non-empty line from the configuration file and
34 * removes comments. The returned string is guaranteed to be null-terminated.
36 static char * wpa_config_get_line(char *s
, int size
, FILE *stream
, int *line
,
39 char *pos
, *end
, *sstart
;
41 while (fgets(s
, size
, stream
)) {
46 /* Skip white space from the beginning of line. */
47 while (*pos
== ' ' || *pos
== '\t' || *pos
== '\r')
50 /* Skip comment lines and empty lines */
51 if (*pos
== '#' || *pos
== '\n' || *pos
== '\0')
55 * Remove # comments unless they are within a double quoted
58 sstart
= os_strchr(pos
, '"');
60 sstart
= os_strrchr(sstart
+ 1, '"');
63 end
= os_strchr(sstart
, '#');
67 end
= pos
+ os_strlen(pos
) - 1;
69 /* Remove trailing white space. */
71 (*end
== '\n' || *end
== ' ' || *end
== '\t' ||
89 static int wpa_config_validate_network(struct wpa_ssid
*ssid
, int line
)
93 if (ssid
->passphrase
) {
95 wpa_printf(MSG_ERROR
, "Line %d: both PSK and "
96 "passphrase configured.", line
);
99 wpa_config_update_psk(ssid
);
102 if (wpa_key_mgmt_wpa_psk(ssid
->key_mgmt
) && !ssid
->psk_set
) {
103 wpa_printf(MSG_ERROR
, "Line %d: WPA-PSK accepted for key "
104 "management, but no PSK configured.", line
);
108 if ((ssid
->group_cipher
& WPA_CIPHER_CCMP
) &&
109 !(ssid
->pairwise_cipher
& WPA_CIPHER_CCMP
) &&
110 !(ssid
->pairwise_cipher
& WPA_CIPHER_NONE
)) {
111 /* Group cipher cannot be stronger than the pairwise cipher. */
112 wpa_printf(MSG_DEBUG
, "Line %d: removed CCMP from group cipher"
113 " list since it was not allowed for pairwise "
115 ssid
->group_cipher
&= ~WPA_CIPHER_CCMP
;
122 static struct wpa_ssid
* wpa_config_read_network(FILE *f
, int *line
, int id
)
124 struct wpa_ssid
*ssid
;
125 int errors
= 0, end
= 0;
126 char buf
[256], *pos
, *pos2
;
128 wpa_printf(MSG_MSGDUMP
, "Line: %d - start of a new network block",
130 ssid
= os_zalloc(sizeof(*ssid
));
135 wpa_config_set_network_defaults(ssid
);
137 while (wpa_config_get_line(buf
, sizeof(buf
), f
, line
, &pos
)) {
138 if (os_strcmp(pos
, "}") == 0) {
143 pos2
= os_strchr(pos
, '=');
145 wpa_printf(MSG_ERROR
, "Line %d: Invalid SSID line "
146 "'%s'.", *line
, pos
);
153 if (os_strchr(pos2
+ 1, '"') == NULL
) {
154 wpa_printf(MSG_ERROR
, "Line %d: invalid "
155 "quotation '%s'.", *line
, pos2
);
161 if (wpa_config_set(ssid
, pos
, pos2
, *line
) < 0)
166 wpa_printf(MSG_ERROR
, "Line %d: network block was not "
167 "terminated properly.", *line
);
171 errors
+= wpa_config_validate_network(ssid
, *line
);
174 wpa_config_free_ssid(ssid
);
182 static struct wpa_cred
* wpa_config_read_cred(FILE *f
, int *line
, int id
)
184 struct wpa_cred
*cred
;
185 int errors
= 0, end
= 0;
186 char buf
[256], *pos
, *pos2
;
188 wpa_printf(MSG_MSGDUMP
, "Line: %d - start of a new cred block", *line
);
189 cred
= os_zalloc(sizeof(*cred
));
194 while (wpa_config_get_line(buf
, sizeof(buf
), f
, line
, &pos
)) {
195 if (os_strcmp(pos
, "}") == 0) {
200 pos2
= os_strchr(pos
, '=');
202 wpa_printf(MSG_ERROR
, "Line %d: Invalid cred line "
203 "'%s'.", *line
, pos
);
210 if (os_strchr(pos2
+ 1, '"') == NULL
) {
211 wpa_printf(MSG_ERROR
, "Line %d: invalid "
212 "quotation '%s'.", *line
, pos2
);
218 if (wpa_config_set_cred(cred
, pos
, pos2
, *line
) < 0)
223 wpa_printf(MSG_ERROR
, "Line %d: cred block was not "
224 "terminated properly.", *line
);
229 wpa_config_free_cred(cred
);
237 #ifndef CONFIG_NO_CONFIG_BLOBS
238 static struct wpa_config_blob
* wpa_config_read_blob(FILE *f
, int *line
,
241 struct wpa_config_blob
*blob
;
243 unsigned char *encoded
= NULL
, *nencoded
;
245 size_t encoded_len
= 0, len
;
247 wpa_printf(MSG_MSGDUMP
, "Line: %d - start of a new named blob '%s'",
250 while (wpa_config_get_line(buf
, sizeof(buf
), f
, line
, &pos
)) {
251 if (os_strcmp(pos
, "}") == 0) {
256 len
= os_strlen(pos
);
257 nencoded
= os_realloc(encoded
, encoded_len
+ len
);
258 if (nencoded
== NULL
) {
259 wpa_printf(MSG_ERROR
, "Line %d: not enough memory for "
265 os_memcpy(encoded
+ encoded_len
, pos
, len
);
270 wpa_printf(MSG_ERROR
, "Line %d: blob was not terminated "
276 blob
= os_zalloc(sizeof(*blob
));
281 blob
->name
= os_strdup(name
);
282 blob
->data
= base64_decode(encoded
, encoded_len
, &blob
->len
);
285 if (blob
->name
== NULL
|| blob
->data
== NULL
) {
286 wpa_config_free_blob(blob
);
294 static int wpa_config_process_blob(struct wpa_config
*config
, FILE *f
,
295 int *line
, char *bname
)
298 struct wpa_config_blob
*blob
;
300 name_end
= os_strchr(bname
, '=');
301 if (name_end
== NULL
) {
302 wpa_printf(MSG_ERROR
, "Line %d: no blob name terminator",
308 blob
= wpa_config_read_blob(f
, line
, bname
);
310 wpa_printf(MSG_ERROR
, "Line %d: failed to read blob %s",
314 wpa_config_set_blob(config
, blob
);
317 #endif /* CONFIG_NO_CONFIG_BLOBS */
320 struct wpa_config
* wpa_config_read(const char *name
)
324 int errors
= 0, line
= 0;
325 struct wpa_ssid
*ssid
, *tail
= NULL
, *head
= NULL
;
326 struct wpa_cred
*cred
, *cred_tail
= NULL
, *cred_head
= NULL
;
327 struct wpa_config
*config
;
331 config
= wpa_config_alloc_empty(NULL
, NULL
);
334 wpa_printf(MSG_DEBUG
, "Reading configuration file '%s'", name
);
335 f
= fopen(name
, "r");
341 while (wpa_config_get_line(buf
, sizeof(buf
), f
, &line
, &pos
)) {
342 if (os_strcmp(pos
, "network={") == 0) {
343 ssid
= wpa_config_read_network(f
, &line
, id
++);
345 wpa_printf(MSG_ERROR
, "Line %d: failed to "
346 "parse network block.", line
);
356 if (wpa_config_add_prio_network(config
, ssid
)) {
357 wpa_printf(MSG_ERROR
, "Line %d: failed to add "
358 "network block to priority list.",
363 } else if (os_strcmp(pos
, "cred={") == 0) {
364 cred
= wpa_config_read_cred(f
, &line
, cred_id
++);
366 wpa_printf(MSG_ERROR
, "Line %d: failed to "
367 "parse cred block.", line
);
371 if (cred_head
== NULL
) {
372 cred_head
= cred_tail
= cred
;
374 cred_tail
->next
= cred
;
377 #ifndef CONFIG_NO_CONFIG_BLOBS
378 } else if (os_strncmp(pos
, "blob-base64-", 12) == 0) {
379 if (wpa_config_process_blob(config
, f
, &line
, pos
+ 12)
384 #endif /* CONFIG_NO_CONFIG_BLOBS */
385 } else if (wpa_config_process_global(config
, pos
, line
) < 0) {
386 wpa_printf(MSG_ERROR
, "Line %d: Invalid configuration "
387 "line '%s'.", line
, pos
);
396 wpa_config_debug_dump_networks(config
);
397 config
->cred
= cred_head
;
399 #ifndef WPA_IGNORE_CONFIG_ERRORS
401 wpa_config_free(config
);
405 #endif /* WPA_IGNORE_CONFIG_ERRORS */
411 #ifndef CONFIG_NO_CONFIG_WRITE
413 static void write_str(FILE *f
, const char *field
, struct wpa_ssid
*ssid
)
415 char *value
= wpa_config_get(ssid
, field
);
418 fprintf(f
, "\t%s=%s\n", field
, value
);
423 static void write_int(FILE *f
, const char *field
, int value
, int def
)
427 fprintf(f
, "\t%s=%d\n", field
, value
);
431 static void write_bssid(FILE *f
, struct wpa_ssid
*ssid
)
433 char *value
= wpa_config_get(ssid
, "bssid");
436 fprintf(f
, "\tbssid=%s\n", value
);
441 static void write_psk(FILE *f
, struct wpa_ssid
*ssid
)
443 char *value
= wpa_config_get(ssid
, "psk");
446 fprintf(f
, "\tpsk=%s\n", value
);
451 static void write_proto(FILE *f
, struct wpa_ssid
*ssid
)
455 if (ssid
->proto
== DEFAULT_PROTO
)
458 value
= wpa_config_get(ssid
, "proto");
462 fprintf(f
, "\tproto=%s\n", value
);
467 static void write_key_mgmt(FILE *f
, struct wpa_ssid
*ssid
)
471 if (ssid
->key_mgmt
== DEFAULT_KEY_MGMT
)
474 value
= wpa_config_get(ssid
, "key_mgmt");
478 fprintf(f
, "\tkey_mgmt=%s\n", value
);
483 static void write_pairwise(FILE *f
, struct wpa_ssid
*ssid
)
487 if (ssid
->pairwise_cipher
== DEFAULT_PAIRWISE
)
490 value
= wpa_config_get(ssid
, "pairwise");
494 fprintf(f
, "\tpairwise=%s\n", value
);
499 static void write_group(FILE *f
, struct wpa_ssid
*ssid
)
503 if (ssid
->group_cipher
== DEFAULT_GROUP
)
506 value
= wpa_config_get(ssid
, "group");
510 fprintf(f
, "\tgroup=%s\n", value
);
515 static void write_auth_alg(FILE *f
, struct wpa_ssid
*ssid
)
519 if (ssid
->auth_alg
== 0)
522 value
= wpa_config_get(ssid
, "auth_alg");
526 fprintf(f
, "\tauth_alg=%s\n", value
);
531 #ifdef IEEE8021X_EAPOL
532 static void write_eap(FILE *f
, struct wpa_ssid
*ssid
)
536 value
= wpa_config_get(ssid
, "eap");
541 fprintf(f
, "\teap=%s\n", value
);
544 #endif /* IEEE8021X_EAPOL */
547 static void write_wep_key(FILE *f
, int idx
, struct wpa_ssid
*ssid
)
549 char field
[20], *value
;
552 res
= os_snprintf(field
, sizeof(field
), "wep_key%d", idx
);
553 if (res
< 0 || (size_t) res
>= sizeof(field
))
555 value
= wpa_config_get(ssid
, field
);
557 fprintf(f
, "\t%s=%s\n", field
, value
);
564 static void write_p2p_client_list(FILE *f
, struct wpa_ssid
*ssid
)
566 char *value
= wpa_config_get(ssid
, "p2p_client_list");
569 fprintf(f
, "\tp2p_client_list=%s\n", value
);
572 #endif /* CONFIG_P2P */
575 static void wpa_config_write_network(FILE *f
, struct wpa_ssid
*ssid
)
579 #define STR(t) write_str(f, #t, ssid)
580 #define INT(t) write_int(f, #t, ssid->t, 0)
581 #define INTe(t) write_int(f, #t, ssid->eap.t, 0)
582 #define INT_DEF(t, def) write_int(f, #t, ssid->t, def)
583 #define INT_DEFe(t, def) write_int(f, #t, ssid->eap.t, def)
587 write_bssid(f
, ssid
);
589 write_proto(f
, ssid
);
590 write_key_mgmt(f
, ssid
);
592 write_pairwise(f
, ssid
);
593 write_group(f
, ssid
);
594 write_auth_alg(f
, ssid
);
596 #ifdef IEEE8021X_EAPOL
599 STR(anonymous_identity
);
605 STR(private_key_passwd
);
608 STR(altsubject_match
);
613 STR(private_key2_passwd
);
616 STR(altsubject_match2
);
632 INT_DEF(eapol_flags
, DEFAULT_EAPOL_FLAGS
);
633 #endif /* IEEE8021X_EAPOL */
634 for (i
= 0; i
< 4; i
++)
635 write_wep_key(f
, i
, ssid
);
638 #ifdef IEEE8021X_EAPOL
639 INT_DEF(eap_workaround
, DEFAULT_EAP_WORKAROUND
);
641 INT_DEFe(fragment_size
, DEFAULT_FRAGMENT_SIZE
);
642 #endif /* IEEE8021X_EAPOL */
644 INT(proactive_key_caching
);
647 #ifdef CONFIG_IEEE80211W
649 #endif /* CONFIG_IEEE80211W */
652 write_p2p_client_list(f
, ssid
);
653 #endif /* CONFIG_P2P */
661 static void wpa_config_write_cred(FILE *f
, struct wpa_cred
*cred
)
664 fprintf(f
, "\tpriority=%d\n", cred
->priority
);
666 fprintf(f
, "\tpcsc=%d\n", cred
->pcsc
);
668 fprintf(f
, "\trealm=\"%s\"\n", cred
->realm
);
670 fprintf(f
, "\tusername=\"%s\"\n", cred
->username
);
672 fprintf(f
, "\tpassword=\"%s\"\n", cred
->password
);
674 fprintf(f
, "\tca_cert=\"%s\"\n", cred
->ca_cert
);
676 fprintf(f
, "\timsi=\"%s\"\n", cred
->imsi
);
678 fprintf(f
, "\tmilenage=\"%s\"\n", cred
->milenage
);
680 fprintf(f
, "\tdomain=\"%s\"\n", cred
->domain
);
684 #ifndef CONFIG_NO_CONFIG_BLOBS
685 static int wpa_config_write_blob(FILE *f
, struct wpa_config_blob
*blob
)
687 unsigned char *encoded
;
689 encoded
= base64_encode(blob
->data
, blob
->len
, NULL
);
693 fprintf(f
, "\nblob-base64-%s={\n%s}\n", blob
->name
, encoded
);
697 #endif /* CONFIG_NO_CONFIG_BLOBS */
700 static void wpa_config_write_global(FILE *f
, struct wpa_config
*config
)
702 #ifdef CONFIG_CTRL_IFACE
703 if (config
->ctrl_interface
)
704 fprintf(f
, "ctrl_interface=%s\n", config
->ctrl_interface
);
705 if (config
->ctrl_interface_group
)
706 fprintf(f
, "ctrl_interface_group=%s\n",
707 config
->ctrl_interface_group
);
708 #endif /* CONFIG_CTRL_IFACE */
709 if (config
->eapol_version
!= DEFAULT_EAPOL_VERSION
)
710 fprintf(f
, "eapol_version=%d\n", config
->eapol_version
);
711 if (config
->ap_scan
!= DEFAULT_AP_SCAN
)
712 fprintf(f
, "ap_scan=%d\n", config
->ap_scan
);
713 if (config
->fast_reauth
!= DEFAULT_FAST_REAUTH
)
714 fprintf(f
, "fast_reauth=%d\n", config
->fast_reauth
);
715 if (config
->opensc_engine_path
)
716 fprintf(f
, "opensc_engine_path=%s\n",
717 config
->opensc_engine_path
);
718 if (config
->pkcs11_engine_path
)
719 fprintf(f
, "pkcs11_engine_path=%s\n",
720 config
->pkcs11_engine_path
);
721 if (config
->pkcs11_module_path
)
722 fprintf(f
, "pkcs11_module_path=%s\n",
723 config
->pkcs11_module_path
);
724 if (config
->pcsc_reader
)
725 fprintf(f
, "pcsc_reader=%s\n", config
->pcsc_reader
);
726 if (config
->pcsc_pin
)
727 fprintf(f
, "pcsc_pin=%s\n", config
->pcsc_pin
);
728 if (config
->driver_param
)
729 fprintf(f
, "driver_param=%s\n", config
->driver_param
);
730 if (config
->dot11RSNAConfigPMKLifetime
)
731 fprintf(f
, "dot11RSNAConfigPMKLifetime=%d\n",
732 config
->dot11RSNAConfigPMKLifetime
);
733 if (config
->dot11RSNAConfigPMKReauthThreshold
)
734 fprintf(f
, "dot11RSNAConfigPMKReauthThreshold=%d\n",
735 config
->dot11RSNAConfigPMKReauthThreshold
);
736 if (config
->dot11RSNAConfigSATimeout
)
737 fprintf(f
, "dot11RSNAConfigSATimeout=%d\n",
738 config
->dot11RSNAConfigSATimeout
);
739 if (config
->update_config
)
740 fprintf(f
, "update_config=%d\n", config
->update_config
);
742 if (!is_nil_uuid(config
->uuid
)) {
744 uuid_bin2str(config
->uuid
, buf
, sizeof(buf
));
745 fprintf(f
, "uuid=%s\n", buf
);
747 if (config
->device_name
)
748 fprintf(f
, "device_name=%s\n", config
->device_name
);
749 if (config
->manufacturer
)
750 fprintf(f
, "manufacturer=%s\n", config
->manufacturer
);
751 if (config
->model_name
)
752 fprintf(f
, "model_name=%s\n", config
->model_name
);
753 if (config
->model_number
)
754 fprintf(f
, "model_number=%s\n", config
->model_number
);
755 if (config
->serial_number
)
756 fprintf(f
, "serial_number=%s\n", config
->serial_number
);
758 char _buf
[WPS_DEV_TYPE_BUFSIZE
], *buf
;
759 buf
= wps_dev_type_bin2str(config
->device_type
,
761 if (os_strcmp(buf
, "0-00000000-0") != 0)
762 fprintf(f
, "device_type=%s\n", buf
);
764 if (WPA_GET_BE32(config
->os_version
))
765 fprintf(f
, "os_version=%08x\n",
766 WPA_GET_BE32(config
->os_version
));
767 if (config
->config_methods
)
768 fprintf(f
, "config_methods=%s\n", config
->config_methods
);
769 if (config
->wps_cred_processing
)
770 fprintf(f
, "wps_cred_processing=%d\n",
771 config
->wps_cred_processing
);
772 if (config
->wps_vendor_ext_m1
) {
773 int i
, len
= wpabuf_len(config
->wps_vendor_ext_m1
);
774 const u8
*p
= wpabuf_head_u8(config
->wps_vendor_ext_m1
);
776 fprintf(f
, "wps_vendor_ext_m1=");
777 for (i
= 0; i
< len
; i
++)
778 fprintf(f
, "%02x", *p
++);
782 #endif /* CONFIG_WPS */
784 if (config
->p2p_listen_reg_class
)
785 fprintf(f
, "p2p_listen_reg_class=%u\n",
786 config
->p2p_listen_reg_class
);
787 if (config
->p2p_listen_channel
)
788 fprintf(f
, "p2p_listen_channel=%u\n",
789 config
->p2p_listen_channel
);
790 if (config
->p2p_oper_reg_class
)
791 fprintf(f
, "p2p_oper_reg_class=%u\n",
792 config
->p2p_oper_reg_class
);
793 if (config
->p2p_oper_channel
)
794 fprintf(f
, "p2p_oper_channel=%u\n", config
->p2p_oper_channel
);
795 if (config
->p2p_go_intent
!= DEFAULT_P2P_GO_INTENT
)
796 fprintf(f
, "p2p_go_intent=%u\n", config
->p2p_go_intent
);
797 if (config
->p2p_ssid_postfix
)
798 fprintf(f
, "p2p_ssid_postfix=%s\n", config
->p2p_ssid_postfix
);
799 if (config
->persistent_reconnect
)
800 fprintf(f
, "persistent_reconnect=%u\n",
801 config
->persistent_reconnect
);
802 if (config
->p2p_intra_bss
!= DEFAULT_P2P_INTRA_BSS
)
803 fprintf(f
, "p2p_intra_bss=%u\n", config
->p2p_intra_bss
);
804 if (config
->p2p_group_idle
)
805 fprintf(f
, "p2p_group_idle=%u\n", config
->p2p_group_idle
);
806 if (config
->p2p_pref_chan
) {
808 fprintf(f
, "p2p_pref_chan=");
809 for (i
= 0; i
< config
->num_p2p_pref_chan
; i
++) {
810 fprintf(f
, "%s%u:%u", i
> 0 ? "," : "",
811 config
->p2p_pref_chan
[i
].op_class
,
812 config
->p2p_pref_chan
[i
].chan
);
816 #endif /* CONFIG_P2P */
817 if (config
->country
[0] && config
->country
[1]) {
818 fprintf(f
, "country=%c%c\n",
819 config
->country
[0], config
->country
[1]);
821 if (config
->bss_max_count
!= DEFAULT_BSS_MAX_COUNT
)
822 fprintf(f
, "bss_max_count=%u\n", config
->bss_max_count
);
823 if (config
->bss_expiration_age
!= DEFAULT_BSS_EXPIRATION_AGE
)
824 fprintf(f
, "bss_expiration_age=%u\n",
825 config
->bss_expiration_age
);
826 if (config
->bss_expiration_scan_count
!=
827 DEFAULT_BSS_EXPIRATION_SCAN_COUNT
)
828 fprintf(f
, "bss_expiration_scan_count=%u\n",
829 config
->bss_expiration_scan_count
);
830 if (config
->filter_ssids
)
831 fprintf(f
, "filter_ssids=%d\n", config
->filter_ssids
);
832 if (config
->max_num_sta
!= DEFAULT_MAX_NUM_STA
)
833 fprintf(f
, "max_num_sta=%u\n", config
->max_num_sta
);
834 if (config
->disassoc_low_ack
)
835 fprintf(f
, "disassoc_low_ack=%u\n", config
->disassoc_low_ack
);
836 #ifdef CONFIG_INTERWORKING
837 if (config
->interworking
)
838 fprintf(f
, "interworking=%u\n", config
->interworking
);
839 if (!is_zero_ether_addr(config
->hessid
))
840 fprintf(f
, "hessid=" MACSTR
"\n", MAC2STR(config
->hessid
));
841 if (config
->access_network_type
!= DEFAULT_ACCESS_NETWORK_TYPE
)
842 fprintf(f
, "access_network_type=%d\n",
843 config
->access_network_type
);
844 #endif /* CONFIG_INTERWORKING */
847 #endif /* CONFIG_NO_CONFIG_WRITE */
850 int wpa_config_write(const char *name
, struct wpa_config
*config
)
852 #ifndef CONFIG_NO_CONFIG_WRITE
854 struct wpa_ssid
*ssid
;
855 struct wpa_cred
*cred
;
856 #ifndef CONFIG_NO_CONFIG_BLOBS
857 struct wpa_config_blob
*blob
;
858 #endif /* CONFIG_NO_CONFIG_BLOBS */
861 wpa_printf(MSG_DEBUG
, "Writing configuration file '%s'", name
);
863 f
= fopen(name
, "w");
865 wpa_printf(MSG_DEBUG
, "Failed to open '%s' for writing", name
);
869 wpa_config_write_global(f
, config
);
871 for (cred
= config
->cred
; cred
; cred
= cred
->next
) {
872 fprintf(f
, "\ncred={\n");
873 wpa_config_write_cred(f
, cred
);
877 for (ssid
= config
->ssid
; ssid
; ssid
= ssid
->next
) {
878 if (ssid
->key_mgmt
== WPA_KEY_MGMT_WPS
|| ssid
->temporary
)
879 continue; /* do not save temporary networks */
880 if (wpa_key_mgmt_wpa_psk(ssid
->key_mgmt
) && !ssid
->psk_set
&&
882 continue; /* do not save invalid network */
883 fprintf(f
, "\nnetwork={\n");
884 wpa_config_write_network(f
, ssid
);
888 #ifndef CONFIG_NO_CONFIG_BLOBS
889 for (blob
= config
->blobs
; blob
; blob
= blob
->next
) {
890 ret
= wpa_config_write_blob(f
, blob
);
894 #endif /* CONFIG_NO_CONFIG_BLOBS */
898 wpa_printf(MSG_DEBUG
, "Configuration file '%s' written %ssuccessfully",
899 name
, ret
? "un" : "");
901 #else /* CONFIG_NO_CONFIG_WRITE */
903 #endif /* CONFIG_NO_CONFIG_WRITE */