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

Anne Mulhern amulhern at redhat.com
Fri Sep 19 12:37:44 UTC 2014





----- Original Message -----
> From: "Vratislav Podzimek" <vpodzime at redhat.com>
> To: "anaconda patch review" <anaconda-patches at lists.fedorahosted.org>
> Sent: Friday, September 19, 2014 2:03:54 AM
> Subject: Re: [master/rhel7-branch] Fix PWQError issue when checking TUI	passwords.	(#1066988)
> 
> On Thu, 2014-09-18 at 15:33 -0400, Anne Mulhern wrote:
> > 
> > 
> > 
> > ----- Original Message -----
> > > From: "Samantha N. Bueno" <sbueno+anaconda at redhat.com>
> > > To: anaconda-patches at lists.fedorahosted.org
> > > Sent: Thursday, September 18, 2014 2:32:43 PM
> > > Subject: [master/rhel7-branch] Fix PWQError issue when checking TUI
> > > passwords.	(#1066988)
> > > 
> > > PWQErrors are tuples, so when we raise PWQError, we should also treat
> > > it as a tuple, or else incur a traceback when trying to fetch/display
> > > an error message.
> > > 
> > > Related: rhbz#1066988
> > > ---
> > >  pyanaconda/ui/tui/spokes/__init__.py | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/pyanaconda/ui/tui/spokes/__init__.py
> > > b/pyanaconda/ui/tui/spokes/__init__.py
> > > index 3b48a2a..b40b08f 100644
> > > --- a/pyanaconda/ui/tui/spokes/__init__.py
> > > +++ b/pyanaconda/ui/tui/spokes/__init__.py
> > > @@ -124,7 +124,8 @@ class EditTUIDialog(NormalTUISpoke):
> > >                      return None
> > >                  strength = checkPassword(pw)
> > >                  if strength < 50:
> > > -                    raise PWQError("The password you have provided is
> > > weak.")
> > > +                    # this is so stupid
> > > +                    raise PWQError(-1, "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?")
> > > --
> > > 1.9.3
> > > 
> > > _______________________________________________
> > > anaconda-patches mailing list
> > > anaconda-patches at lists.fedorahosted.org
> > > https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> > > 
> > 
> > We should not really be raising a PWQError, it belongs to pwquality
> > package.
> > 
> > Some other logic would be better here.
> Agreed, it'd be easier to raise some our exception and catch both below.
> 
> --
> Vratislav Podzimek
> 
> Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
> 
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> 

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....

- mulhern
       



More information about the anaconda-patches mailing list