This is in keeping some consistency with GUI behavior, check a user's
pw quality score and warn/prompt them to confirm whether they are ok
with using a weak pw.
Resolves: rhbz#1001039
---
pyanaconda/ui/tui/spokes/__init__.py | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/pyanaconda/ui/tui/spokes/__init__.py b/pyanaconda/ui/tui/spokes/__init__.py
index 2f92126..fc904b3 100644
--- a/pyanaconda/ui/tui/spokes/__init__.py
+++ b/pyanaconda/ui/tui/spokes/__init__.py
@@ -22,7 +22,7 @@ from pyanaconda.ui.tui import simpleline as tui
from pyanaconda.ui.tui.tuiobject import TUIObject, YesNoDialog
from pyanaconda.ui.common import Spoke, StandaloneSpoke, NormalSpoke, PersonalizationSpoke, collect
from pyanaconda.users import validatePassword
-from pwquality import PWQError
+import pwquality
import re
from collections import namedtuple
from pyanaconda.iutil import setdeepattr, getdeepattr
@@ -104,6 +104,25 @@ class EditTUIDialog(NormalTUISpoke):
return True
def prompt(self, entry = None):
+ def _validatePassword(pw, confirm):
+ """ Better password checking. This sets up a quality checker
+ to score password attempts. This is similar to the pw quality
+ check done in the GUI, except this only raises an error if a
+ password is weak.
+ """
+ # set up quality checker
+ _pwq = pwquality.PWQSettings()
+ _pwq.read_config()
+
+ error = validatePassword(pw, confirm)
+ if error:
+ return error
+ strength = _pwq.check(pw, None, None)
+ if strength < 50:
+ raise pwquality.PWQError
+ else:
+ return None
+
if not entry:
return None
@@ -114,11 +133,11 @@ class EditTUIDialog(NormalTUISpoke):
# just returning an error is either blank or mismatched
# passwords. Raising is because of poor quality.
try:
- error = validatePassword(pw, confirm)
+ error = _validatePassword(pw, confirm)
if error:
print(error)
return None
- except PWQError as e:
+ except pwquality.PWQError as e:
error = _("You have provided a weak password: %s. " % e.message)
error += _("\nWould you like to use it anyway?")
question_window = YesNoDialog(self._app, error)
--
1.7.11.7