def _customization(self): self._enabled = self.environment[osetupcons.DBEnv.NEW_DATABASE] if not self._enabled: self.dialog.note(text=_( 'Skipping storing options as database already ' 'prepared'), ) else: if self.environment[osetupcons.ConfigEnv.ADMIN_PASSWORD] is None: valid = False password = None while not valid: password = self.dialog.queryString( name='OVESETUP_CONFIG_ADMIN_SETUP', note=_('Engine admin password: '******'OVESETUP_CONFIG_ADMIN_SETUP', note=_('Confirm engine admin password: '******'Passwords do not match')) else: 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, )) valid = dialog.queryBoolean( dialog=self.dialog, name='OVESETUP_CONFIG_WEAK_ENGINE_PASSWORD', note=_('Use weak password? ' '(@VALUES@) [@DEFAULT@]: '), prompt=True, default=False, ) self.environment[ osetupcons.ConfigEnv.ADMIN_PASSWORD] = password self.environment[otopicons.CoreEnv.LOG_FILTER].append( self.environment[osetupcons.ConfigEnv.ADMIN_PASSWORD])
def validatePassword(param, options=[]): logging.debug("Validating password") if not validateStringNotEmpty(param, options): return False if "'" in param: logging.error(output_messages.ERR_NOT_ALLOWED_CHAR % "'") print output_messages.ERR_NOT_ALLOWED_CHAR % "'" return False if re.search("\s", param): logging.error(output_messages.ERR_SPACES_IN_PASS) print output_messages.ERR_SPACES_IN_PASS return False try: cracklib.FascistCheck(param) except: logging.warn("Password failed check") logging.warn(traceback.format_exc()) print output_messages.WARN_WEAK_PASS return True
def getNext (self): # check if we already have an encrypted password from kickstart if self.rootPassword["isCrypted"] and self.pw.get_text() == "xxxxxxxx": return None pw = self.pw.get_text() confirm = self.confirm.get_text() if not pw or not confirm: self.intf.messageWindow(_("Error with Password"), _("You must enter your root password " "and confirm it by typing it a second " "time to continue."), custom_icon="error") self.passwordError() if pw != confirm: self.intf.messageWindow(_("Error with Password"), _("The passwords you entered were " "different. Please try again."), custom_icon="error") self.passwordError() if len(pw) < 6: self.intf.messageWindow(_("Error with Password"), _("The root password must be at least " "six characters long."), custom_icon="error") self.passwordError() try: cracklib.FascistCheck(pw) except ValueError, e: msg = gettext.ldgettext("cracklib", e) ret = self.intf.messageWindow(_("Weak Password"), _("You have provided a weak password: %s") % msg, type="custom", custom_icon="error", default=0, custom_buttons=[_("Cancel"), _("_Use Anyway")]) if ret == 0: self.passwordError()