diff --git a/doc/README.extcap b/doc/README.extcap index 50dc1a82f3..7b53b7fcfd 100644 --- a/doc/README.extcap +++ b/doc/README.extcap @@ -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 diff --git a/doc/extcap.pod b/doc/extcap.pod index 511e1a59cd..05cbdcbb93 100644 --- a/doc/extcap.pod +++ b/doc/extcap.pod @@ -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 diff --git a/extcap.c b/extcap.c index 94eaa3cd11..a608787dc3 100644 --- a/extcap.c +++ b/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; diff --git a/extcap/sshdump.c b/extcap/sshdump.c index 1976f9c56b..8375161ae8 100644 --- a/extcap/sshdump.c +++ b/extcap/sshdump.c @@ -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", diff --git a/extcap_parser.c b/extcap_parser.c index 000dd6307c..a562ada52c 100644 --- a/extcap_parser.c +++ b/extcap_parser.c @@ -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) { diff --git a/extcap_parser.h b/extcap_parser.h index d10c5cd8cc..83600510aa 100644 --- a/extcap_parser.h +++ b/extcap_parser.h @@ -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, diff --git a/ui/gtk/extcap_gtk.c b/ui/gtk/extcap_gtk.c index c2a1e3386e..6d7c068db9 100644 --- a/ui/gtk/extcap_gtk.c +++ b/ui/gtk/extcap_gtk.c @@ -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); diff --git a/ui/qt/extcap_argument.cpp b/ui/qt/extcap_argument.cpp index 2ae543660f..38dc865770 100644 --- a/ui/qt/extcap_argument.cpp +++ b/ui/qt/extcap_argument.cpp @@ -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 )