VMM: Don't prompt endless for a password. Stop after 3rd failure.
authorPascal Volk <neverseen@users.sourceforge.net>
Thu, 22 Oct 2009 18:40:06 +0000
changeset 158 6949f6eaf26e
parent 157 eb3ccf9484b3
child 159 78b6b06188d3
VMM: Don't prompt endless for a password. Stop after 3rd failure.
VirtualMailManager/VirtualMailManager.py
VirtualMailManager/constants/ERROR.py
--- a/VirtualMailManager/VirtualMailManager.py	Tue Oct 20 18:58:09 2009 +0000
+++ b/VirtualMailManager/VirtualMailManager.py	Thu Oct 22 18:40:06 2009 +0000
@@ -193,13 +193,19 @@
         # TP: Please preserve the trailing space.
         readp_msg1 = _(u'Retype new password: ').encode(ENCODING, 'replace')
         mismatched = True
+        flrs = 0
         while mismatched:
+            if flrs > 2:
+                raise VMMException(_(u'Too many failures - try again later.'),
+                        ERR.VMM_TOO_MANY_FAILURES)
             clear0 = getpass(prompt=readp_msg0)
             clear1 = getpass(prompt=readp_msg1)
             if clear0 != clear1:
+                flrs += 1
                 w_std(_(u'Sorry, passwords do not match'))
                 continue
-            if len(clear0) < 1 or len(clear1) < 1:
+            if len(clear0) < 1:
+                flrs += 1
                 w_std(_(u'Sorry, empty passwords are not permitted'))
                 continue
             mismatched = False
--- a/VirtualMailManager/constants/ERROR.py	Tue Oct 20 18:58:09 2009 +0000
+++ b/VirtualMailManager/constants/ERROR.py	Thu Oct 22 18:40:06 2009 +0000
@@ -49,3 +49,4 @@
 UNKNOWN_SERVICE = 64
 UNKNOWN_TRANSPORT_ID = 65
 VMM_ERROR = 66
+VMM_TOO_MANY_FAILURES = 67