# HG changeset patch
# User Pascal Volk <neverseen@users.sourceforge.net>
# Date 1256236806 0
# Node ID 6949f6eaf26e9ca2ddcef5d6dc59ff7b0ae01240
# Parent  eb3ccf9484b3fb785ef12a7a924cb1168495a948
VMM: Don't prompt endless for a password. Stop after 3rd failure.

diff -r eb3ccf9484b3 -r 6949f6eaf26e VirtualMailManager/VirtualMailManager.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
diff -r eb3ccf9484b3 -r 6949f6eaf26e VirtualMailManager/constants/ERROR.py
--- 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