diff mbox series

wpa_cli: add command for setting PSK_PASSPHRASE

Message ID 20180712153551.2978-1-hagai.moshe@tandemg.com
State Accepted
Headers show
Series wpa_cli: add command for setting PSK_PASSPHRASE | expand

Commit Message

hagai July 12, 2018, 3:35 p.m. UTC
From: Hagai Moshe <hagai.moshe@tandemg.com>

setting mem_only_psk=1 in the configuration
prevent the passphrase from being stored in the
configuration file.
the wpa_supplicant will request the psk_passphrase.
this command should be used to set the psk_passphrase

usage:
psk_passphrase <network id> <psk_passphrase>

Signed-off-by: Hagai Moshe <hagai.moshe@tandemg.com>
Signed-off-by: Simon Dinkin <simon.dinkin@tandemg.com>
---
 wpa_supplicant/wpa_cli.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

Comments

Jouni Malinen Jan. 2, 2019, 11:22 p.m. UTC | #1
On Thu, Jul 12, 2018 at 06:35:51PM +0300, hagai wrote:
> setting mem_only_psk=1 in the configuration
> prevent the passphrase from being stored in the
> configuration file.
> the wpa_supplicant will request the psk_passphrase.
> this command should be used to set the psk_passphrase
> 
> usage:
> psk_passphrase <network id> <psk_passphrase>

Thanks, applied.
diff mbox series

Patch

diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
index 05e3ebf2f..3ba1fe271 100644
--- a/wpa_supplicant/wpa_cli.c
+++ b/wpa_supplicant/wpa_cli.c
@@ -1203,6 +1203,40 @@  static int wpa_cli_cmd_sim(struct wpa_ctrl *ctrl, int argc, char *argv[])
 }
 
 
+static int wpa_cli_cmd_psk_passphrase(struct wpa_ctrl *ctrl, int argc,
+				  char *argv[])
+{
+	char cmd[256], *pos, *end;
+	int i, ret;
+
+	if (argc < 2) {
+		printf("Invalid PSK_PASSPHRASE command: needs two arguments "
+		       "(network id and psk_passphrase)\n");
+		return -1;
+	}
+
+	end = cmd + sizeof(cmd);
+	pos = cmd;
+	ret = os_snprintf(pos, end - pos, WPA_CTRL_RSP "PSK_PASSPHRASE-%s:%s",
+			  argv[0], argv[1]);
+	if (os_snprintf_error(end - pos, ret)) {
+		printf("Too long PSK PASSPHRASE command.\n");
+		return -1;
+	}
+	pos += ret;
+	for (i = 2; i < argc; i++) {
+		ret = os_snprintf(pos, end - pos, " %s", argv[i]);
+		if (os_snprintf_error(end - pos, ret)) {
+			printf("Too long PSK PASSPHRASE command.\n");
+			return -1;
+		}
+		pos += ret;
+	}
+
+	return wpa_ctrl_command(ctrl, cmd);
+}
+
+
 static int wpa_cli_cmd_passphrase(struct wpa_ctrl *ctrl, int argc,
 				  char *argv[])
 {
@@ -3084,6 +3118,10 @@  static const struct wpa_cli_cmd wpa_cli_commands[] = {
 	  cli_cmd_flag_sensitive,
 	  "<network id> <password> = configure one-time-password for an SSID"
 	},
+	{ "psk_passphrase", wpa_cli_cmd_psk_passphrase,
+	  wpa_cli_complete_network_id, cli_cmd_flag_sensitive,
+	  "<network id> <psk_passphrase> = configure private key psk_passphrase\n"
+	  "  for an SSID" },
 	{ "passphrase", wpa_cli_cmd_passphrase, wpa_cli_complete_network_id,
 	  cli_cmd_flag_sensitive,
 	  "<network id> <passphrase> = configure private key passphrase\n"