From daf3d88aa1b554c5d6d41116c51517d30cb7c4b7 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Fri, 1 Sep 2017 11:14:35 +0200 Subject: Display security state when asking for password Indicate to the user how secure the transport channel is so they can avoid entering their password for untrusted sites. --- vncviewer/UserDialog.cxx | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'vncviewer/UserDialog.cxx') diff --git a/vncviewer/UserDialog.cxx b/vncviewer/UserDialog.cxx index cf6893c8..640f2a98 100644 --- a/vncviewer/UserDialog.cxx +++ b/vncviewer/UserDialog.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -42,8 +43,18 @@ #include "parameters.h" #include "UserDialog.h" +/* xpm:s predate const, so they have invalid definitions */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wwrite-strings" +#include "../media/secure.xpm" +#include "../media/insecure.xpm" +#pragma GCC diagnostic pop + using namespace rfb; +static Fl_Pixmap secure_icon(secure); +static Fl_Pixmap insecure_icon(insecure); + static int ret_val = 0; static void button_cb(Fl_Widget *widget, void *val) { @@ -59,7 +70,7 @@ UserDialog::~UserDialog() { } -void UserDialog::getUserPasswd(char** user, char** password) +void UserDialog::getUserPasswd(bool secure, char** user, char** password) { CharArray passwordFileStr(passwordFile.getData()); @@ -83,6 +94,7 @@ void UserDialog::getUserPasswd(char** user, char** password) } Fl_Window *win; + Fl_Box *banner; Fl_Input *username; Fl_Secret_Input *passwd; Fl_Box *icon; @@ -93,9 +105,22 @@ void UserDialog::getUserPasswd(char** user, char** password) win = new Fl_Window(410, 145, _("VNC authentication")); win->callback(button_cb,(void *)0); - y = 10; + banner = new Fl_Box(0, 0, win->w(), 20); + banner->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE|FL_ALIGN_IMAGE_NEXT_TO_TEXT); + banner->box(FL_FLAT_BOX); + if (secure) { + banner->label(_("This connection is secure")); + banner->color(FL_GREEN); + banner->image(secure_icon); + } else { + banner->label(_("This connection is not secure")); + banner->color(FL_RED); + banner->image(insecure_icon); + } + + y = 20 + 10; - icon = new Fl_Box(10, 10, 50, 50, "?"); + icon = new Fl_Box(10, y, 50, 50, "?"); icon->box(FL_UP_BOX); icon->labelfont(FL_TIMES_BOLD); icon->labelsize(34); -- cgit v1.2.3