[master/rhel7-branch] Fix PWQError issue when checking TUI passwords. (#1066988)

Samantha N. Bueno sbueno+anaconda at redhat.com
Mon Sep 29 13:17:58 UTC 2014


Let this one slip under the radar a bit....

On Fri, Sep 19, 2014 at 08:37:44AM -0400, Anne Mulhern wrote:
> 
> Probably would be just as good with:
> 
> error = None
> try:
> 
>     error_msg = ...
>     if error_msg:
>         ...
> 
>     strength = checkPassword(pw)
>     if strength < 50:
>         error = "The password you have provided is weak."
> except PWQError as e:
>     error = e[1]
> finally:
>     if error:
>         error = _("You have provided...%s") % error
>         error += ("\n...")
>         etc....

Right then, here's the new patch--

diff --git a/pyanaconda/ui/tui/spokes/__init__.py b/pyanaconda/ui/tui/spokes/__init__.py
index 3b48a2a..76bed4b 100644
--- a/pyanaconda/ui/tui/spokes/__init__.py
+++ b/pyanaconda/ui/tui/spokes/__init__.py
@@ -124,14 +124,17 @@ class EditTUIDialog(NormalTUISpoke):
                     return None
                 strength = checkPassword(pw)
                 if strength < 50:
-                    raise PWQError("The password you have provided is weak.")
+                    error = _("The password you have provided is weak")
             except PWQError as e:
-                error = _("You have provided a weak password: %s. ") % e[1]
-                error += _("\nWould you like to use it anyway?")
-                question_window = YesNoDialog(self._app, error)
-                self._app.switch_screen_modal(question_window)
-                if not question_window.answer:
-                    return None
+                error = e[1]
+            finally:
+                if error:
+                    error = _("You have provided a weak password: %s.  ") % error
+                    error += _("\nWould you like to use it anyway?")
+                    question_window = YesNoDialog(self._app, error)
+                    self._app.switch_screen_modal(question_window)
+                    if not question_window.answer:
+                        return None
 
             self.value = cryptPassword(pw)
             return None


More information about the anaconda-patches mailing list