Alon Bar-Lev has uploaded a new change for review.

Change subject: packaging: setup: add cracklib validation to engine password
......................................................................

packaging: setup: add cracklib validation to engine password

Change-Id: Idcc275774e3b1b10fd8fc7ad056245907c6bdbba
Signed-off-by: Alon Bar-Lev <[email protected]>
---
M packaging/setup/plugins/ovirt-engine-setup/config/options.py
1 file changed, 32 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/79/14679/1

diff --git a/packaging/setup/plugins/ovirt-engine-setup/config/options.py 
b/packaging/setup/plugins/ovirt-engine-setup/config/options.py
index 3d52217..e94b9b3 100644
--- a/packaging/setup/plugins/ovirt-engine-setup/config/options.py
+++ b/packaging/setup/plugins/ovirt-engine-setup/config/options.py
@@ -30,6 +30,7 @@
 
 
 from ovirt_engine_setup import constants as osetupcons
+from ovirt_engine_setup import dialog
 
 
 @util.export
@@ -72,8 +73,9 @@
             )
         else:
             if self.environment[osetupcons.ConfigEnv.ADMIN_PASSWORD] is None:
+                valid = False
                 password = None
-                while True:
+                while not valid:
                     password = self.dialog.queryString(
                         name='OVESETUP_CONFIG_ADMIN_SETUP',
                         note=_('Engine admin password: '),
@@ -88,9 +90,36 @@
                     )
 
                     if password != password2:
-                        self.logger.warning('Passwords do not match')
+                        self.logger.warning(_('Passwords do not match'))
                     else:
-                        break  # do while missing in python
+                        try:
+                            import cracklib
+                            cracklib.FascistCheck(password)
+                            valid = True
+                        except ImportError:
+                            # do not force this optional feature
+                            self.logger.debug(
+                                'cannot import cracklib',
+                                exc_info=True,
+                            )
+                            valid = True
+                        except ValueError as e:
+                            self.logger.warning(
+                                _('Password is weak: {error}').format(
+                                    error=e,
+                                )
+                            )
+                            if dialog.queryBoolean(
+                                dialog=self.dialog,
+                                name='OVESETUP_CONFIG_WEAK_ENGINE_PASSWORD',
+                                note=_(
+                                    'Use weak password? '
+                                    '(@VALUES@) [@DEFAULT@]: '
+                                ),
+                                prompt=True,
+                                default=False,
+                            ):
+                                valid = True
 
                 self.environment[
                     osetupcons.ConfigEnv.ADMIN_PASSWORD


--
To view, visit http://gerrit.ovirt.org/14679
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idcc275774e3b1b10fd8fc7ad056245907c6bdbba
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to