]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS: Add new PSK entries with wps=1 tag
authorJouni Malinen <j@w1.fi>
Sat, 15 Feb 2020 15:30:41 +0000 (17:30 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 15 Feb 2020 15:37:27 +0000 (17:37 +0200)
Now that hostapd wpa_psk_file has a new tag for identifying PSKs that
can be used with WPS, add that tag to new entries for PSKs from WPS.
This makes it clearer where the PSK came from and in addition, this
allows the same PSK to be assigned if the same Enrollee goes through WPS
provisioning again.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/ap/wps_hostapd.c

index 35e5772af6cb1652821b54deafa2853cbd7e9ae5..7b143b8214eb6a0a0de7881172a93d58032851c9 100644 (file)
@@ -137,16 +137,17 @@ static int hostapd_wps_new_psk_cb(void *ctx, const u8 *mac_addr,
        if (ssid->wpa_psk_file) {
                FILE *f;
                char hex[PMK_LEN * 2 + 1];
+
                /* Add the new PSK to PSK list file */
                f = fopen(ssid->wpa_psk_file, "a");
-               if (f == NULL) {
-                       wpa_printf(MSG_DEBUG, "Failed to add the PSK to "
-                                  "'%s'", ssid->wpa_psk_file);
+               if (!f) {
+                       wpa_printf(MSG_DEBUG, "Failed to add the PSK to '%s'",
+                                  ssid->wpa_psk_file);
                        return -1;
                }
 
                wpa_snprintf_hex(hex, sizeof(hex), psk, psk_len);
-               fprintf(f, MACSTR " %s\n", MAC2STR(mac_addr), hex);
+               fprintf(f, "wps=1 " MACSTR " %s\n", MAC2STR(mac_addr), hex);
                fclose(f);
        }