Disallow echo disabling when prompting for a PIN. master
authorDamien Goutte-Gattat via Gnupg-devel <gnupg-devel@gnupg.org>
Tue, 21 Aug 2018 19:31:53 +0000 (20:31 +0100)
committerDamien Goutte-Gattat <dgouttegattat@incenp.org>
Wed, 22 Aug 2018 21:28:32 +0000 (22:28 +0100)
* gtk+-2/pinentry-gtk-2.c (create_window): Do not setup
the backspace handler when prompting for a PIN.
callback only when not prompting for a PIN.
* qt/pinentrydialog.h (_got_input): Rename field to
_disable_echo_allowed.
* qt/pinentrydialog.cpp (PinEntryDialog::setPrompt): Disallow
echo disabling when prompting for a PIN.
* tqt/pinentrydialog.h (_got_input): Rename field to
_disable_echo_allowed.
* tqt/pinentrydialog.cpp (PinEntryDialog::setPrompt): Disallow
echo disabling when prompting for a PIN.

Signed-off-by: Damien Goutte-Gattat <dgouttegattat@incenp.org>
gtk+-2/pinentry-gtk-2.c
qt/pinentrydialog.cpp
qt/pinentrydialog.h
tqt/pinentrydialog.cpp
tqt/pinentrydialog.h

index 1e07fdc..a4522e4 100644 (file)
@@ -729,8 +729,14 @@ create_window (pinentry_t ctx)
       gtk_widget_set_size_request (entry, 200, -1);
       g_signal_connect (G_OBJECT (entry), "changed",
                         G_CALLBACK (changed_text_handler), entry);
-      g_signal_connect (G_OBJECT (entry), "backspace",
-                        G_CALLBACK (backspace_handler), entry);
+
+      /* Enable disabling echo if we're not asking for a PIN. */
+      if (pinentry->prompt && !strstr (pinentry->prompt, "PIN"))
+       {
+         g_signal_connect (G_OBJECT (entry), "backspace",
+                           G_CALLBACK (backspace_handler), entry);
+       }
+
       hbox = gtk_hbox_new (FALSE, HIG_TINY);
       gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
       /* There was a wish in issue #2139 that this button should not
index b7f2e53..a58e636 100644 (file)
@@ -138,7 +138,7 @@ PinEntryDialog::PinEntryDialog(QWidget *parent, const char *name,
     : QDialog(parent),
       mRepeat(NULL),
       _grabbed(false),
-      _got_input(false),
+      _disable_echo_allowed(true),
       mVisibilityTT(visibilityTT),
       mHideTT(hideTT),
       mVisiActionEdit(NULL),
@@ -318,6 +318,8 @@ void PinEntryDialog::setPrompt(const QString &txt)
 {
     _prompt->setText(txt);
     _prompt->setVisible(!txt.isEmpty());
+    if (txt.contains("PIN"))
+      _disable_echo_allowed = false;
 }
 
 QString PinEntryDialog::prompt() const
@@ -362,7 +364,7 @@ void PinEntryDialog::setQualityBarTT(const QString &txt)
 
 void PinEntryDialog::onBackspace()
 {
-    if (!_got_input) {
+    if (_disable_echo_allowed) {
         _edit->setEchoMode(QLineEdit::NoEcho);
         if (mRepeat) {
             mRepeat->setEchoMode(QLineEdit::NoEcho);
@@ -380,7 +382,7 @@ void PinEntryDialog::updateQuality(const QString &txt)
         _timer->stop();
     }
 
-    _got_input = true;
+    _disable_echo_allowed = false;
 
     if (!_have_quality_bar || !_pinentry_info) {
         return;
index 396f03b..d5e6963 100644 (file)
@@ -109,7 +109,7 @@ private:
     bool       _grabbed;
     bool       _have_quality_bar;
     bool       _timed_out;
-    bool       _got_input;
+    bool       _disable_echo_allowed;
     pinentry_t _pinentry_info;
     QTimer    *_timer;
     QString    mRepeatError,
index 6a2ae12..b7aa309 100644 (file)
@@ -33,7 +33,7 @@
 PinEntryDialog::PinEntryDialog( TQWidget* parent, const char* name,
                                 bool modal, bool enable_quality_bar )
   : TQDialog( parent, name, modal, TQt::WStyle_StaysOnTop ), _grabbed( false ),
-    _got_input( false )
+    _disable_echo_allowed ( true )
 {
   TQBoxLayout* top = new TQVBoxLayout( this, 6 );
   TQBoxLayout* upperLayout = new TQHBoxLayout( top );
@@ -134,7 +134,7 @@ void PinEntryDialog::updateQuality( const SecTQString & txt )
   int percent;
   TQPalette pal;
 
-  _got_input = true;
+  _disable_echo_allowed = false;
 
   if (!_have_quality_bar || !_pinentry_info)
     return;
@@ -166,7 +166,7 @@ void PinEntryDialog::updateQuality( const SecTQString & txt )
 
 void PinEntryDialog::onBackspace()
 {
-  if (!_got_input)
+  if (_disable_echo_allowed)
     _edit->setEchoMode( SecTQLineEdit::NoEcho );
 }
 
@@ -208,6 +208,8 @@ SecTQString PinEntryDialog::text() const
 void PinEntryDialog::setPrompt( const TQString& txt )
 {
   _prompt->setText( txt );
+  if (txt.contains("PIN"))
+    _disable_echo_allowed = false;
 }
 
 TQString PinEntryDialog::prompt() const
index eb4d332..8ec3fd5 100644 (file)
@@ -87,7 +87,7 @@ private:
   bool       _grabbed;
   bool       _have_quality_bar;
   pinentry_t _pinentry_info;
-  bool       _got_input;
+  bool       _disable_echo_allowed;
 };