bin/128582: [patch] activate readline(3) support in wpa_cli

Eygene Ryabinkin rea-fbsd at codelabs.ru
Fri Jan 16 20:20:02 PST 2009


The following reply was made to PR bin/128582; it has been noted by GNATS.

From: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
To: Sam Leffler <sam at freebsd.org>
Cc: bug-followup at freebsd.org
Subject: Re: bin/128582: [patch] activate readline(3) support in wpa_cli
Date: Sat, 17 Jan 2009 07:12:51 +0300

 --x+6KMIRAuhnl3hBn
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Sam, good day.
 
 Tue, Jan 06, 2009 at 10:36:08PM +0300, Eygene Ryabinkin wrote:
 > The fixes were integrated to the 0.6.x series and are in 0.6.7,
 >   http://hostap.epitest.fi/gitweb/gitweb.cgi?p=hostap-06.git;a=shortlog
 > 
 > I had asked Jouni if he is going to backport the fixes to 0.5.x.
 
 Jouni said that he isn't going to integrate the full fixes.  May be
 only small part will go to 5.x, may be nothing will be added.  Said
 that, I have full patches for 5.x and if you want them, they are
 attached to this message.  It is up to you to either integrate them
 somehow into the FreeBSD base or to close the PR without doing this.
 -- 
 Eygene
  _                ___       _.--.   #
  \`.|\..----...-'`   `-._.-'_.-'`   #  Remember that it is hard
  /  ' `         ,       __.--'      #  to read the on-line manual
  )/' _/     \   `-_,   /            #  while single-stepping the kernel.
  `-'" `"\_  ,_.-;_.-\_ ',  fsc/as   #
      _.-'_./   {_.'   ; /           #    -- FreeBSD Developers handbook
     {_.-``-'         {_/            #
 
 --x+6KMIRAuhnl3hBn
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="0001-WPA-CLI-tool-properly-clean-history-before-writing.patch"
 Content-Transfer-Encoding: quoted-printable
 
 =46rom 675f3cf08143fdc04ee23a550c9846d8a1cc89d1 Mon Sep 17 00:00:00 2001
 =46rom: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
 Date: Sat, 8 Nov 2008 14:13:50 +0300
 Subject: [PATCH] WPA CLI tool: properly clean history before writing it to =
 the disk
 
 First of all, the history had not been written to the disk, since almost
 all commands were cleaned up due to the error in the history cleaning:
 the return value of the last os_strncasecmp() call was not compared to
 zero, but was rather used as is.  So the condition was almost always
 true and most commands were removed from the history.
 
 The second problem was that the evaluation of the potentially sensitive
 commands was started at the entry number 1, instead of very first entry.
 
 I had added flags to the every command description: just now the only
 meaningful flag tells that this command has sensitive arguments and it
 shouldn't be written to the disk.  I rewrote the logics for the search
 for the sensitive commands: special procedure is now loops over all
 commands and tries to see if command has sensitive data.  And I had
 rewritten the command checking loop to properly check all commands.
 
 Signed-off-by: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
 ---
  wpa_supplicant/wpa_cli.c |  175 ++++++++++++++++++++++++++++++++----------=
 ----
  1 files changed, 121 insertions(+), 54 deletions(-)
 
 diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
 index 46ec736..e6d4608 100644
 --- a/wpa_supplicant/wpa_cli.c
 +++ b/wpa_supplicant/wpa_cli.c
 @@ -1041,59 +1041,130 @@ static int wpa_cli_cmd_interface_remove(struct wpa=
 _ctrl *ctrl, int argc,
  	return wpa_ctrl_command(ctrl, cmd);
  }
 =20
 +enum wpa_cli_cmd_flags {
 +	cli_cmd_flag_none		=3D 0x00,
 +	cli_cmd_flag_sensitive		=3D 0x01
 +};
 =20
  struct wpa_cli_cmd {
  	const char *cmd;
  	int (*handler)(struct wpa_ctrl *ctrl, int argc, char *argv[]);
 +	enum wpa_cli_cmd_flags flags;
  };
 =20
  static struct wpa_cli_cmd wpa_cli_commands[] =3D {
 -	{ "status", wpa_cli_cmd_status },
 -	{ "ping", wpa_cli_cmd_ping },
 -	{ "mib", wpa_cli_cmd_mib },
 -	{ "help", wpa_cli_cmd_help },
 -	{ "interface", wpa_cli_cmd_interface },
 -	{ "level", wpa_cli_cmd_level },
 -	{ "license", wpa_cli_cmd_license },
 -	{ "quit", wpa_cli_cmd_quit },
 -	{ "set", wpa_cli_cmd_set },
 -	{ "logon", wpa_cli_cmd_logon },
 -	{ "logoff", wpa_cli_cmd_logoff },
 -	{ "pmksa", wpa_cli_cmd_pmksa },
 -	{ "reassociate", wpa_cli_cmd_reassociate },
 -	{ "preauthenticate", wpa_cli_cmd_preauthenticate },
 -	{ "identity", wpa_cli_cmd_identity },
 -	{ "password", wpa_cli_cmd_password },
 -	{ "new_password", wpa_cli_cmd_new_password },
 -	{ "pin", wpa_cli_cmd_pin },
 -	{ "otp", wpa_cli_cmd_otp },
 -	{ "passphrase", wpa_cli_cmd_passphrase },
 -	{ "bssid", wpa_cli_cmd_bssid },
 -	{ "list_networks", wpa_cli_cmd_list_networks },
 -	{ "select_network", wpa_cli_cmd_select_network },
 -	{ "enable_network", wpa_cli_cmd_enable_network },
 -	{ "disable_network", wpa_cli_cmd_disable_network },
 -	{ "add_network", wpa_cli_cmd_add_network },
 -	{ "remove_network", wpa_cli_cmd_remove_network },
 -	{ "set_network", wpa_cli_cmd_set_network },
 -	{ "get_network", wpa_cli_cmd_get_network },
 -	{ "save_config", wpa_cli_cmd_save_config },
 -	{ "disconnect", wpa_cli_cmd_disconnect },
 -	{ "reconnect", wpa_cli_cmd_reconnect },
 -	{ "scan", wpa_cli_cmd_scan },
 -	{ "scan_results", wpa_cli_cmd_scan_results },
 -	{ "bss", wpa_cli_cmd_bss },
 -	{ "get_capability", wpa_cli_cmd_get_capability },
 -	{ "reconfigure", wpa_cli_cmd_reconfigure },
 -	{ "terminate", wpa_cli_cmd_terminate },
 -	{ "interface_add", wpa_cli_cmd_interface_add },
 -	{ "interface_remove", wpa_cli_cmd_interface_remove },
 -	{ "ap_scan", wpa_cli_cmd_ap_scan },
 -	{ "stkstart", wpa_cli_cmd_stkstart },
 -	{ "ft_ds", wpa_cli_cmd_ft_ds },
 -	{ NULL, NULL }
 +	{ "status", wpa_cli_cmd_status,
 +	  cli_cmd_flag_none },
 +	{ "ping", wpa_cli_cmd_ping,
 +	  cli_cmd_flag_none },
 +	{ "mib", wpa_cli_cmd_mib,
 +	  cli_cmd_flag_none },
 +	{ "help", wpa_cli_cmd_help,
 +	  cli_cmd_flag_none },
 +	{ "interface", wpa_cli_cmd_interface,
 +	  cli_cmd_flag_none },
 +	{ "level", wpa_cli_cmd_level,
 +	  cli_cmd_flag_none },
 +	{ "license", wpa_cli_cmd_license,
 +	  cli_cmd_flag_none },
 +	{ "quit", wpa_cli_cmd_quit,
 +	  cli_cmd_flag_none },
 +	{ "set", wpa_cli_cmd_set,
 +	  cli_cmd_flag_none },
 +	{ "logon", wpa_cli_cmd_logon,
 +	  cli_cmd_flag_none },
 +	{ "logoff", wpa_cli_cmd_logoff,
 +	  cli_cmd_flag_none },
 +	{ "pmksa", wpa_cli_cmd_pmksa,
 +	  cli_cmd_flag_none },
 +	{ "reassociate", wpa_cli_cmd_reassociate,
 +	  cli_cmd_flag_none },
 +	{ "preauthenticate", wpa_cli_cmd_preauthenticate,
 +	  cli_cmd_flag_none },
 +	{ "identity", wpa_cli_cmd_identity,
 +	  cli_cmd_flag_none },
 +	{ "password", wpa_cli_cmd_password,
 +	  cli_cmd_flag_sensitive },
 +	{ "new_password", wpa_cli_cmd_new_password,
 +	  cli_cmd_flag_sensitive },
 +	{ "pin", wpa_cli_cmd_pin,
 +	  cli_cmd_flag_sensitive },
 +	{ "otp", wpa_cli_cmd_otp,
 +	  cli_cmd_flag_sensitive },
 +	{ "passphrase", wpa_cli_cmd_passphrase,
 +	  cli_cmd_flag_sensitive },
 +	{ "bssid", wpa_cli_cmd_bssid,
 +	  cli_cmd_flag_none },
 +	{ "list_networks", wpa_cli_cmd_list_networks,
 +	  cli_cmd_flag_none },
 +	{ "select_network", wpa_cli_cmd_select_network,
 +	  cli_cmd_flag_none },
 +	{ "enable_network", wpa_cli_cmd_enable_network,
 +	  cli_cmd_flag_none },
 +	{ "disable_network", wpa_cli_cmd_disable_network,
 +	  cli_cmd_flag_none },
 +	{ "add_network", wpa_cli_cmd_add_network,
 +	  cli_cmd_flag_none },
 +	{ "remove_network", wpa_cli_cmd_remove_network,
 +	  cli_cmd_flag_none },
 +	{ "set_network", wpa_cli_cmd_set_network,
 +	  cli_cmd_flag_none },
 +	{ "get_network", wpa_cli_cmd_get_network,
 +	  cli_cmd_flag_none },
 +	{ "save_config", wpa_cli_cmd_save_config,
 +	  cli_cmd_flag_none },
 +	{ "disconnect", wpa_cli_cmd_disconnect,
 +	  cli_cmd_flag_none },
 +	{ "reconnect", wpa_cli_cmd_reconnect,
 +	  cli_cmd_flag_none },
 +	{ "scan", wpa_cli_cmd_scan,
 +	  cli_cmd_flag_none },
 +	{ "scan_results", wpa_cli_cmd_scan_results,
 +	  cli_cmd_flag_none },
 +	{ "bss", wpa_cli_cmd_bss,
 +	  cli_cmd_flag_none },
 +	{ "get_capability", wpa_cli_cmd_get_capability,
 +	  cli_cmd_flag_none },
 +	{ "reconfigure", wpa_cli_cmd_reconfigure,
 +	  cli_cmd_flag_none },
 +	{ "terminate", wpa_cli_cmd_terminate,
 +	  cli_cmd_flag_none },
 +	{ "interface_add", wpa_cli_cmd_interface_add,
 +	  cli_cmd_flag_none },
 +	{ "interface_remove", wpa_cli_cmd_interface_remove,
 +	  cli_cmd_flag_none },
 +	{ "ap_scan", wpa_cli_cmd_ap_scan,
 +	  cli_cmd_flag_none },
 +	{ "stkstart", wpa_cli_cmd_stkstart,
 +	  cli_cmd_flag_none },
 +	{ "ft_ds", wpa_cli_cmd_ft_ds,
 +	  cli_cmd_flag_none },
 +	{ NULL, NULL,
 +	  cli_cmd_flag_none }
  };
 =20
 +#ifdef CONFIG_READLINE	/* Currently, only readline-related code uses this =
 */
 +static int _cmd_has_sensitive_data(const char *cmd)
 +{
 +	const char *c, *delim;
 +	int n;
 +	size_t len;
 +
 +	delim =3D strpbrk(cmd, " \t");
 +	if (delim)
 +		len =3D delim - cmd;
 +	else
 +		len =3D os_strlen(cmd);
 +
 +	for (n =3D 0; (c =3D wpa_cli_commands[n].cmd); n++) {
 +		if (os_strncasecmp(cmd, c, len) =3D=3D 0 && len =3D=3D os_strlen(c))
 +			return (wpa_cli_commands[n].flags &
 +			    cli_cmd_flag_sensitive);
 +	}
 +	return 0;
 +}
 +#endif
 +
 =20
  static int wpa_request(struct wpa_ctrl *ctrl, int argc, char *argv[])
  {
 @@ -1430,24 +1501,20 @@ static void wpa_cli_interactive(void)
  		 * passwords. */
  		HIST_ENTRY *h;
  		history_set_pos(0);
 -		h =3D next_history();
 -		while (h) {
 +		while ((h =3D current_history())) {
  			char *p =3D h->line;
  			while (*p =3D=3D ' ' || *p =3D=3D '\t')
  				p++;
 -			if (os_strncasecmp(p, "pa", 2) =3D=3D 0 ||
 -			    os_strncasecmp(p, "o", 1) =3D=3D 0 ||
 -			    os_strncasecmp(p, "n", 1)) {
 +			if (_cmd_has_sensitive_data(p)) {
  				h =3D remove_history(where_history());
  				if (h) {
  					os_free(h->line);
  					os_free(h->data);
  					os_free(h);
 -				}
 -				h =3D current_history();
 -			} else {
 -				h =3D next_history();
 -			}
 +				} else
 +					next_history();
 +			} else
 +				next_history();
  		}
  		write_history(hfile);
  		os_free(hfile);
 --=20
 1.6.0.3
 
 
 --x+6KMIRAuhnl3hBn
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="0002-WPA-CLI-tool-embed-command-usage-into-the-wpa_cli_c.patch"
 Content-Transfer-Encoding: quoted-printable
 
 =46rom c319af1e6dd24d09ef19e5e9f381db2fd61341c6 Mon Sep 17 00:00:00 2001
 =46rom: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
 Date: Sat, 8 Nov 2008 18:52:30 +0300
 Subject: [PATCH] WPA CLI tool: embed command usage into the wpa_cli_command=
 s array
 
 It is better to have command description around the command definitions:
 the chances for omitting usage, forgotting to change/delete them, etc
 are smaller then for the separate usage statement.
 
 Signed-off-by: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
 ---
  wpa_supplicant/wpa_cli.c |  235 +++++++++++++++++++++++++++---------------=
 ----
  1 files changed, 137 insertions(+), 98 deletions(-)
 
 diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
 index e6d4608..0830f7f 100644
 --- a/wpa_supplicant/wpa_cli.c
 +++ b/wpa_supplicant/wpa_cli.c
 @@ -14,6 +14,8 @@
 =20
  #include "includes.h"
 =20
 +#include <assert.h>
 +
  #ifdef CONFIG_CTRL_IFACE
 =20
  #ifdef CONFIG_CTRL_IFACE_UNIX
 @@ -86,55 +88,6 @@ static const char *wpa_cli_full_license =3D
  "OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  "\n";
 =20
 -static const char *commands_help =3D
 -"commands:\n"
 -"  status [verbose] =3D get current WPA/EAPOL/EAP status\n"
 -"  mib =3D get MIB variables (dot1x, dot11)\n"
 -"  help =3D show this usage help\n"
 -"  interface [ifname] =3D show interfaces/select interface\n"
 -"  level <debug level> =3D change debug level\n"
 -"  license =3D show full wpa_cli license\n"
 -"  logoff =3D IEEE 802.1X EAPOL state machine logoff\n"
 -"  logon =3D IEEE 802.1X EAPOL state machine logon\n"
 -"  set =3D set variables (shows list of variables when run without argumen=
 ts)\n"
 -"  pmksa =3D show PMKSA cache\n"
 -"  reassociate =3D force reassociation\n"
 -"  reconfigure =3D force wpa_supplicant to re-read its configuration file\=
 n"
 -"  preauthenticate <BSSID> =3D force preauthentication\n"
 -"  identity <network id> <identity> =3D configure identity for an SSID\n"
 -"  password <network id> <password> =3D configure password for an SSID\n"
 -"  new_password <network id> <password> =3D change password for an SSID\n"
 -"  pin <network id> <pin> =3D configure pin for an SSID\n"
 -"  otp <network id> <password> =3D configure one-time-password for an SSID=
 \n"
 -"  passphrase <network id> <passphrase> =3D configure private key passphra=
 se\n"
 -"    for an SSID\n"
 -"  bssid <network id> <BSSID> =3D set preferred BSSID for an SSID\n"
 -"  list_networks =3D list configured networks\n"
 -"  select_network <network id> =3D select a network (disable others)\n"
 -"  enable_network <network id> =3D enable a network\n"
 -"  disable_network <network id> =3D disable a network\n"
 -"  add_network =3D add a network\n"
 -"  remove_network <network id> =3D remove a network\n"
 -"  set_network <network id> <variable> <value> =3D set network variables "
 -"(shows\n"
 -"    list of variables when run without arguments)\n"
 -"  get_network <network id> <variable> =3D get network variables\n"
 -"  save_config =3D save the current configuration\n"
 -"  disconnect =3D disconnect and wait for reassociate/reconnect command be=
 fore\n "
 -"    connecting\n"
 -"  reconnect =3D like reassociate, but only takes effect if already "
 -"disconnected\n"
 -"  scan =3D request new BSS scan\n"
 -"  scan_results =3D get latest scan results\n"
 -"  bss <<idx> | <bssid>> =3D get detailed scan result info\n"
 -"  get_capability <eap/pairwise/group/key_mgmt/proto/auth_alg> =3D "
 -"get capabilies\n"
 -"  ap_scan <value> =3D set ap_scan parameter\n"
 -"  stkstart <addr> =3D request STK negotiation with <addr>\n"
 -"  ft_ds <addr> =3D request over-the-DS FT with <addr>\n"
 -"  terminate =3D terminate wpa_supplicant\n"
 -"  quit =3D exit wpa_cli\n";
 -
  static struct wpa_ctrl *ctrl_conn;
  static int wpa_cli_quit =3D 0;
  static int wpa_cli_attached =3D 0;
 @@ -146,9 +99,12 @@ static const char *pid_file =3D NULL;
  static const char *action_file =3D NULL;
 =20
 =20
 +static void _print_help(void);
 +
 +
  static void usage(void)
  {
 -	printf("wpa_cli [-p<path to ctrl sockets>] [-i<ifname>] [-hvB] "
 +	fputs("wpa_cli [-p<path to ctrl sockets>] [-i<ifname>] [-hvB] "
  	       "[-a<action file>] \\\n"
  	       "        [-P<pid file>] [-g<global ctrl>]  [command..]\n"
  	       "  -h =3D help (show this usage text)\n"
 @@ -158,9 +114,9 @@ static void usage(void)
  	       "       wpa_supplicant\n"
  	       "  -B =3D run a daemon in the background\n"
  	       "  default path: /var/run/wpa_supplicant\n"
 -	       "  default interface: first interface found in socket path\n"
 -	       "%s",
 -	       commands_help);
 +	       "  default interface: first interface found in socket path\n",
 +	       stdout);
 +	_print_help();
  }
 =20
 =20
 @@ -274,7 +230,7 @@ static int wpa_cli_cmd_pmksa(struct wpa_ctrl *ctrl, int=
  argc, char *argv[])
 =20
  static int wpa_cli_cmd_help(struct wpa_ctrl *ctrl, int argc, char *argv[])
  {
 -	printf("%s", commands_help);
 +	_print_help();
  	return 0;
  }
 =20
 @@ -1050,99 +1006,182 @@ struct wpa_cli_cmd {
  	const char *cmd;
  	int (*handler)(struct wpa_ctrl *ctrl, int argc, char *argv[]);
  	enum wpa_cli_cmd_flags flags;
 +	const char *usage;
  };
 =20
  static struct wpa_cli_cmd wpa_cli_commands[] =3D {
  	{ "status", wpa_cli_cmd_status,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "[verbose] =3D get current WPA/EAPOL/EAP status" },
  	{ "ping", wpa_cli_cmd_ping,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "=3D pings wpa_supplicant" },
  	{ "mib", wpa_cli_cmd_mib,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "=3D get MIB variables (dot1x, dot11)" },
  	{ "help", wpa_cli_cmd_help,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "=3D show this usage help" },
  	{ "interface", wpa_cli_cmd_interface,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "[ifname] =3D show interfaces/select interface" },
  	{ "level", wpa_cli_cmd_level,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  " <debug level> =3D change debug level" },
  	{ "license", wpa_cli_cmd_license,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "=3D show full wpa_cli license" },
  	{ "quit", wpa_cli_cmd_quit,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "exit wpa_cli" },
  	{ "set", wpa_cli_cmd_set,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "=3D set variables (show list of variables when run without arguments" =
 },
  	{ "logon", wpa_cli_cmd_logon,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "=3D IEEE 802.1X EAPOL state machine logon" },
  	{ "logoff", wpa_cli_cmd_logoff,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "=3D IEEE 802.1X EAPOL state machine logoff" },
  	{ "pmksa", wpa_cli_cmd_pmksa,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "=3D show PMKSA cache" },
  	{ "reassociate", wpa_cli_cmd_reassociate,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "=3D force reassociation" },
  	{ "preauthenticate", wpa_cli_cmd_preauthenticate,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "<BSSID> =3D forces preauthentication" },
  	{ "identity", wpa_cli_cmd_identity,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "<network id> <identity> =3D configure identity for an SSID" },
  	{ "password", wpa_cli_cmd_password,
 -	  cli_cmd_flag_sensitive },
 +	  cli_cmd_flag_sensitive,
 +	  "<network id> <password> =3D configure password for an SSID" },
  	{ "new_password", wpa_cli_cmd_new_password,
 -	  cli_cmd_flag_sensitive },
 +	  cli_cmd_flag_sensitive,
 +	  "<network id> <password> =3D change password for an SSID" },
  	{ "pin", wpa_cli_cmd_pin,
 -	  cli_cmd_flag_sensitive },
 +	  cli_cmd_flag_sensitive,
 +	  "<network id> <pin> =3D configure pin for an SSID" },
  	{ "otp", wpa_cli_cmd_otp,
 -	  cli_cmd_flag_sensitive },
 +	  cli_cmd_flag_sensitive,
 +	  "<network id> <password> =3D configure one-time-password for an SSID" },
  	{ "passphrase", wpa_cli_cmd_passphrase,
 -	  cli_cmd_flag_sensitive },
 +	  cli_cmd_flag_sensitive,
 +	  "<network id> <passphrase> =3D configure private key passphrase\n"
 +	  "  for an SSID" },
  	{ "bssid", wpa_cli_cmd_bssid,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "<network id> <BSSID> =3D set preferred BSSID for an SSID" },
  	{ "list_networks", wpa_cli_cmd_list_networks,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "=3D list configured networks" },
  	{ "select_network", wpa_cli_cmd_select_network,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "<network id> =3D select a network (disable others)" },
  	{ "enable_network", wpa_cli_cmd_enable_network,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "<network id> =3D enable a network" },
  	{ "disable_network", wpa_cli_cmd_disable_network,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "<network id> =3D disable a network" },
  	{ "add_network", wpa_cli_cmd_add_network,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "=3D add a network" },
  	{ "remove_network", wpa_cli_cmd_remove_network,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "<network id> =3D remove a network" },
  	{ "set_network", wpa_cli_cmd_set_network,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "<network id> <variable> <value> =3D set network variables (shows\n"
 +	  "  list of variables when run without arguments)" },
  	{ "get_network", wpa_cli_cmd_get_network,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "<network id> <variable> =3D get network variables" },
  	{ "save_config", wpa_cli_cmd_save_config,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "=3D save the current configuration" },
  	{ "disconnect", wpa_cli_cmd_disconnect,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "=3D disconnect and wait for reassociate/reconnect command before\n"
 +	  "  connecting" },
  	{ "reconnect", wpa_cli_cmd_reconnect,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "=3D like reassociate, but only takes effect if already disonnected" },
  	{ "scan", wpa_cli_cmd_scan,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "=3D request new BSS scan" },
  	{ "scan_results", wpa_cli_cmd_scan_results,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "=3D get latest scan results" },
  	{ "bss", wpa_cli_cmd_bss,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "<<idx> | <bssid>> =3D get detailed scan result info" },
  	{ "get_capability", wpa_cli_cmd_get_capability,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "<eap/pairwise/group/key_mgmt/proto/auth_alg> =3D get capabilities" },
  	{ "reconfigure", wpa_cli_cmd_reconfigure,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "=3D reconfigures wpa_supplicant" },
  	{ "terminate", wpa_cli_cmd_terminate,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "=3D terminate wpa_supplicant" },
  	{ "interface_add", wpa_cli_cmd_interface_add,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "<ifname> <confname> <driver> <ctrl_interface> <driver_param>\n"
 +	  "  <bridge_name> =3D adds new interface, all parameters but <ifname>\n"
 +	  "  are optional" },
  	{ "interface_remove", wpa_cli_cmd_interface_remove,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "<ifname> =3D removes the interface" },
  	{ "ap_scan", wpa_cli_cmd_ap_scan,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "<value> =3D set ap_scan parameter" },
  	{ "stkstart", wpa_cli_cmd_stkstart,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "<addr> =3D request STK negotiation with <addr>" },
  	{ "ft_ds", wpa_cli_cmd_ft_ds,
 -	  cli_cmd_flag_none },
 +	  cli_cmd_flag_none,
 +	  "<addr> =3D request over-the-DS FT with <addr>" },
  	{ NULL, NULL,
 -	  cli_cmd_flag_none }
 +	  cli_cmd_flag_none,
 +	  NULL }
  };
 =20
 +
 +/*
 + * Prints command usage, lines are padded with the specified string.
 + */
 +static void _print_cmd_help(struct wpa_cli_cmd *cmd, const char *pad)
 +{
 +	char c;
 +	size_t n;
 +	FILE *stream =3D stdout;
 +
 +	assert(cmd !=3D NULL);
 +	assert(pad !=3D NULL);
 +
 +	fprintf(stream, "%s%s ", pad, cmd->cmd);
 +	for (n =3D 0; (c=3Dcmd->usage[n]); n++) {
 +		(void)fputc((int)c, stream);
 +		if (c =3D=3D '\n')
 +			fputs(pad, stream);
 +	}
 +	fputc('\n', stream);
 +}
 +
 +
 +static void _print_help(void)
 +{
 +	int n;
 +
 +	fputs("commands:\n", stdout);
 +	for (n =3D 0; wpa_cli_commands[n].cmd; n++)
 +		_print_cmd_help(&wpa_cli_commands[n], "  ");
 +}
 +
 +
  #ifdef CONFIG_READLINE	/* Currently, only readline-related code uses this =
 */
  static int _cmd_has_sensitive_data(const char *cmd)
  {
 --=20
 1.6.0.3
 
 
 --x+6KMIRAuhnl3hBn--


More information about the freebsd-bugs mailing list