extcap: add masked to options.
This allows an option to be masked (like a password), by using the argument-type password. Change-Id: I2eae1be2e6672bff28ba5f749d7a3f687ebd4631 Reviewed-on: https://code.wireshark.org/review/13385 Reviewed-by: Dario Lombardo <lomato@gmail.com> Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Roland Knall <rknall@gmail.com>
This commit is contained in:
parent
36cd1959d3
commit
ff033c6a2f
|
@ -150,6 +150,10 @@ These options do have types, for which the following types are being supported:
|
|||
the user input for validity beyond normal data type or range checks. Back-slashes
|
||||
must be escaped (as in \\b for \b)
|
||||
|
||||
* PASSWORD - Let the user provide a masked string to the capture
|
||||
|
||||
arg {number=0}{call=--password}{display=The user password}{tooltip=The password for the connection}{type=password}
|
||||
|
||||
* BOOLEAN,BOOLFLAG - this provides the possibility to set a true/false value.
|
||||
BOOLFLAG values will only appear in the command-line if set to true, otherwise they
|
||||
will not be added to the command-line call for the extcap interface
|
||||
|
|
|
@ -46,6 +46,7 @@ Argument type for UI filtering for raw, or UI type for selector:
|
|||
radio (display group of radio buttons with provided values, all values as strings)
|
||||
fileselect (display a dialog to select a file from the filesystem, value as string)
|
||||
multicheck (display a textbox for selecting multiple options, values as strings)
|
||||
password (display a textbox with masked text)
|
||||
|
||||
=item value (options)
|
||||
|
||||
|
@ -79,6 +80,10 @@ Example 3:
|
|||
arg {number=1}{call=--server}{display=IP address for log server}{type=string}{validation=(?:\d{1,3}\.){3}\d{1,3}}
|
||||
flag {failure=Permission denied opening Ubertooth device}
|
||||
|
||||
Example 4:
|
||||
arg {number=0}{call=--username}{display=Username}{type=string}
|
||||
arg {number=1}{call=--password}{display=Password}{type=password}
|
||||
|
||||
=head1 Security awareness
|
||||
|
||||
=over 4
|
||||
|
|
3
extcap.c
3
extcap.c
|
@ -894,6 +894,9 @@ void extcap_debug_arguments ( extcap_arg *arg_iter )
|
|||
case EXTCAP_ARG_STRING:
|
||||
printf ( "string\n" );
|
||||
break;
|
||||
case EXTCAP_ARG_PASSWORD:
|
||||
printf ( "PASSWORD\n" );
|
||||
break;
|
||||
case EXTCAP_ARG_MULTICHECK:
|
||||
printf ( "unknown\n" );
|
||||
break;
|
||||
|
|
|
@ -550,7 +550,7 @@ static int list_config(char *interface, unsigned int remote_port)
|
|||
"{type=string}{default=%s}{tooltip=The remote SSH username. If not provided, "
|
||||
"the current user will be used}\n", inc++, g_get_user_name());
|
||||
printf("arg {number=%u}{call=--remote-password}{display=Remote SSH server password}"
|
||||
"{type=string}{tooltip=The SSH password, used when other methods (SSH agent "
|
||||
"{type=password}{tooltip=The SSH password, used when other methods (SSH agent "
|
||||
"or key files) are unavailable.}\n", inc++);
|
||||
printf("arg {number=%u}{call=--sshkey}{display=Path to SSH private key}"
|
||||
"{type=fileselect}{tooltip=The path on the local filesystem of the private ssh key}\n",
|
||||
|
|
|
@ -63,6 +63,7 @@ gchar *extcap_get_complex_as_string(extcap_complex *comp) {
|
|||
comp->complex_value.bool_value ? "true" : "false");
|
||||
break;
|
||||
case EXTCAP_ARG_STRING:
|
||||
case EXTCAP_ARG_PASSWORD:
|
||||
case EXTCAP_ARG_FILESELECT:
|
||||
g_free(ret);
|
||||
ret = g_strdup(comp->complex_value.string_value);
|
||||
|
@ -121,6 +122,7 @@ extcap_complex *extcap_parse_complex(extcap_arg_type complex_type,
|
|||
success = TRUE;
|
||||
break;
|
||||
case EXTCAP_ARG_STRING:
|
||||
case EXTCAP_ARG_PASSWORD:
|
||||
case EXTCAP_ARG_FILESELECT:
|
||||
rc->complex_value.string_value = g_strdup(data);
|
||||
success = TRUE;
|
||||
|
@ -174,6 +176,7 @@ gboolean extcap_compare_is_default(extcap_arg *element, extcap_complex *test) {
|
|||
result = TRUE;
|
||||
break;
|
||||
case EXTCAP_ARG_STRING:
|
||||
case EXTCAP_ARG_PASSWORD:
|
||||
if (strcmp(extcap_complex_get_string(test),
|
||||
extcap_complex_get_string(element->default_complex)) == 0)
|
||||
result = TRUE;
|
||||
|
@ -188,6 +191,7 @@ gboolean extcap_compare_is_default(extcap_arg *element, extcap_complex *test) {
|
|||
|
||||
void extcap_free_complex(extcap_complex *comp) {
|
||||
if (comp->complex_type == EXTCAP_ARG_STRING
|
||||
|| comp->complex_type == EXTCAP_ARG_PASSWORD
|
||||
|| comp->complex_type == EXTCAP_ARG_FILESELECT)
|
||||
g_free(comp->complex_value.string_value);
|
||||
|
||||
|
@ -627,6 +631,8 @@ extcap_arg *extcap_parse_arg_sentence(GList * args, extcap_token_sentence *s) {
|
|||
target_arg->arg_type = EXTCAP_ARG_RADIO;
|
||||
} else if (g_ascii_strcasecmp(v->value, "string") == 0) {
|
||||
target_arg->arg_type = EXTCAP_ARG_STRING;
|
||||
} else if (g_ascii_strcasecmp(v->value, "password") == 0) {
|
||||
target_arg->arg_type = EXTCAP_ARG_PASSWORD;
|
||||
} else if (g_ascii_strcasecmp(v->value, "fileselect") == 0) {
|
||||
target_arg->arg_type = EXTCAP_ARG_FILESELECT;
|
||||
} else if (g_ascii_strcasecmp(v->value, "multicheck") == 0) {
|
||||
|
|
|
@ -45,6 +45,7 @@ typedef enum {
|
|||
EXTCAP_ARG_BOOLEAN,
|
||||
EXTCAP_ARG_BOOLFLAG,
|
||||
EXTCAP_ARG_STRING,
|
||||
EXTCAP_ARG_PASSWORD,
|
||||
/* Complex GUI types which are populated with value sentences */
|
||||
EXTCAP_ARG_SELECTOR,
|
||||
EXTCAP_ARG_RADIO,
|
||||
|
|
|
@ -157,6 +157,7 @@ GHashTable *extcap_gtk_get_state(GtkWidget *widget) {
|
|||
case EXTCAP_ARG_LONG:
|
||||
case EXTCAP_ARG_DOUBLE:
|
||||
case EXTCAP_ARG_STRING:
|
||||
case EXTCAP_ARG_PASSWORD:
|
||||
parsed_complex = extcap_parse_complex(arg->arg_type,
|
||||
gtk_entry_get_text(GTK_ENTRY(list_widget)));
|
||||
if (parsed_complex == NULL) {
|
||||
|
@ -812,6 +813,7 @@ GSList *extcap_populate_gtk_vbox(GList *arguments, GtkWidget *vbox,
|
|||
}
|
||||
break;
|
||||
case EXTCAP_ARG_STRING:
|
||||
case EXTCAP_ARG_PASSWORD:
|
||||
label = gtk_label_new(arg_iter->display);
|
||||
|
||||
item = gtk_entry_new();
|
||||
|
@ -828,6 +830,9 @@ GSList *extcap_populate_gtk_vbox(GList *arguments, GtkWidget *vbox,
|
|||
g_free(default_str);
|
||||
}
|
||||
|
||||
if ( arg_iter->arg_type == EXTCAP_ARG_PASSWORD)
|
||||
gtk_entry_set_visibility(GTK_ENTRY(item), FALSE);
|
||||
|
||||
break;
|
||||
case EXTCAP_ARG_FILESELECT:
|
||||
label = gtk_label_new(arg_iter->display);
|
||||
|
|
|
@ -287,6 +287,9 @@ QWidget * ExtArgText::createEditor(QWidget * parent)
|
|||
if ( _argument->tooltip != NULL )
|
||||
textBox->setToolTip(QString().fromUtf8(_argument->tooltip));
|
||||
|
||||
if (_argument->arg_type == EXTCAP_ARG_PASSWORD)
|
||||
textBox->setEchoMode(QLineEdit::Password);
|
||||
|
||||
connect(textBox , SIGNAL(textChanged(QString)), SLOT(onStringChanged(QString)));
|
||||
|
||||
return textBox;
|
||||
|
@ -568,7 +571,7 @@ ExtcapArgument * ExtcapArgument::create(extcap_arg * argument, GHashTable * devi
|
|||
|
||||
ExtcapArgument * result = 0;
|
||||
|
||||
if ( argument->arg_type == EXTCAP_ARG_STRING )
|
||||
if ( argument->arg_type == EXTCAP_ARG_STRING || argument->arg_type == EXTCAP_ARG_PASSWORD )
|
||||
result = new ExtArgText(argument);
|
||||
else if ( argument->arg_type == EXTCAP_ARG_INTEGER || argument->arg_type == EXTCAP_ARG_LONG ||
|
||||
argument->arg_type == EXTCAP_ARG_UNSIGNED || argument->arg_type == EXTCAP_ARG_DOUBLE )
|
||||
|
|
Loading…
Reference in New Issue