diff options
author | Dario Lombardo <lomato@gmail.com> | 2016-01-18 12:01:14 +0100 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2016-01-18 15:04:33 +0000 |
commit | ff033c6a2fb7a6286e66b6ed89e24ea4c6cd22c9 (patch) | |
tree | bab0bf4c3077a1f36ec4dce13f864525096a814d | |
parent | 36cd1959d313862216c58a0765d75758c8715b1d (diff) |
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>
-rw-r--r-- | doc/README.extcap | 4 | ||||
-rw-r--r-- | doc/extcap.pod | 5 | ||||
-rw-r--r-- | extcap.c | 3 | ||||
-rw-r--r-- | extcap/sshdump.c | 2 | ||||
-rw-r--r-- | extcap_parser.c | 6 | ||||
-rw-r--r-- | extcap_parser.h | 1 | ||||
-rw-r--r-- | ui/gtk/extcap_gtk.c | 5 | ||||
-rw-r--r-- | ui/qt/extcap_argument.cpp | 5 |
8 files changed, 29 insertions, 2 deletions
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 @@ -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 ) |