def apply(self): # set the password only if the user enters anything to the text entry # this should preserve the kickstart based password if self.password_required: if self.password: self.password_kickstarted = False self._user.password = cryptPassword(self.password) self._user.isCrypted = True self.remove_placeholder_texts() # reset the password when the user unselects it else: self.remove_placeholder_texts() self._user.password = "" self._user.isCrypted = False self.password_kickstarted = False self._user.name = self.username self._user.gecos = self.fullname # Copy the spoke data back to kickstart # If the user name is not set, no user will be created. if self._user.name: ksuser = copy.copy(self._user) if not self.data.user.userList: self.data.user.userList.append(ksuser) else: self.data.user.userList[0] = ksuser elif self.data.user.userList: self.data.user.userList.pop(0)
def prompt(self, entry=None): if not entry: return None if entry.aux == self.PASSWORD: pw = self._app.raw_input(_("%s: ") % entry.title, hidden=True) confirm = self._app.raw_input(_("%s (confirm): ") % entry.title, hidden=True) if (pw and not confirm) or (confirm and not pw): print(_("You must enter your root password and confirm it by typing" " it a second time to continue.")) return None if pw != confirm: print(_(PASSWORD_CONFIRM_ERROR_TUI)) return None valid, strength, message = validatePassword(pw, user=None) if not valid: print(message) return None if strength < 50: if message: error = _("You have provided a weak password: %s\n" "Would you like to use it anyway?") % message else: error = _("You have provided a weak password.\n" "Would 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 else: return _("Enter new value for '%s' and press enter\n") % entry.title
def prompt(self, entry=None): if not entry: return None if entry.aux == self.PASSWORD: pw = self._app.raw_input(_("%s: ") % entry.title, hidden=True) confirm = self._app.raw_input(_("%s (confirm): ") % entry.title, hidden=True) if (pw and not confirm) or (confirm and not pw): print(_("You must enter your root password and confirm it by typing" " it a second time to continue.")) return None if (pw != confirm): print(_(PASSWORD_CONFIRM_ERROR_TUI)) return None # If an empty password was provided, unset the value if not pw: self.value = "" return None valid, strength, message = validatePassword(pw, user=None, minlen=self.policy.minlen) if not valid: print(message) return None if strength < self.policy.minquality: if self.policy.strict: done_msg = "" else: done_msg = _("\nWould you like to use it anyway?") if message: error = _(PASSWORD_WEAK_WITH_ERROR) % message + " " + done_msg else: error = _(PASSWORD_WEAK) % done_msg if not self.policy.strict: question_window = YesNoDialog(self._app, error) self._app.switch_screen_modal(question_window) if not question_window.answer: return None else: print(error) return None if any(char not in PW_ASCII_CHARS for char in pw): print(_("You have provided a password containing non-ASCII characters.\n" "You may not be able to switch between keyboard layouts to login.\n")) self.value = cryptPassword(pw) return None else: return tui.Prompt(_("Enter a new value for '%(title)s' and press %(enter)s") % { # TRANSLATORS: 'title' as a title of the entry "title": entry.title, # TRANSLATORS: 'enter' as the key ENTER "enter": tui.Prompt.ENTER })
def apply(self): # set the password only if the user enters anything to the text entry # this should preserve the kickstart based password if self.pw.get_text(): self._password_kickstarted = False self._user.password = cryptPassword(self.pw.get_text()) self._user.isCrypted = True self.pw.set_placeholder_text("") self.confirm.set_placeholder_text("") self._user.name = self.username.get_text() if "wheel" not in self._user.groups: self._user.groups.append("wheel") if "qubes" not in self._user.groups: self._user.groups.append("qubes") # Copy the spoke data back to kickstart # If the user name is not set, no user will be created. if self._user.name: ksuser = copy.copy(self._user) if not self.data.user.userList: self.data.user.userList.append(ksuser) else: self.data.user.userList[0] = ksuser elif self.data.user.userList: self.data.user.userList.pop(0)
def apply(self): # set the password only if the user enters anything to the text entry # this should preserve the kickstart based password if self.input_enabled: if self.pw.get_text(): self._password_kickstarted = False self._user.password = cryptPassword(self.pw.get_text()) self._user.isCrypted = True self.pw.set_placeholder_text("") self.confirm.set_placeholder_text("") # reset the password when the user unselects it else: self.pw.set_placeholder_text("") self.confirm.set_placeholder_text("") self._user.password = "" self._user.isCrypted = False self._password_kickstarted = False self._user.name = self.username.get_text() self._user.gecos = self.fullname.get_text() # Copy the spoke data back to kickstart # If the user name is not set, no user will be created. if self._user.name: ksuser = copy.copy(self._user) if not self.data.user.userList: self.data.user.userList.append(ksuser) else: self.data.user.userList[0] = ksuser elif self.data.user.userList: self.data.user.userList.pop(0)
def apply(self): # set the password only if the user enters anything to the text entry # this should preserve the kickstart based password if self.usepassword.get_active(): if self.pw.get_text(): self._user.password_kickstarted = False self._user.password = cryptPassword(self.pw.get_text()) self._user.isCrypted = True self.pw.set_placeholder_text("") self.confirm.set_placeholder_text("") # reset the password when the user unselects it else: self.pw.set_placeholder_text("") self.confirm.set_placeholder_text("") self._user.password = "" self._user.isCrypted = False self._user.password_kickstarted = False self._user.name = self.username.get_text() self._user.gecos = self.fullname.get_text() # the user will be created only if the username is set if self._user.name: if self._user not in self.data.user.userList: self.data.user.userList.append(self._user) elif self._user in self.data.user.userList: self.data.user.userList.remove(self._user)
def prompt(self, entry): if entry.aux == self.PASSWORD: pw = self._app.raw_input(_("%s: ") % entry.title, hidden=True) confirm = self._app.raw_input(_("%s (confirm): ") % entry.title, hidden=True) error = None # just returning an error is either blank or mismatched # passwords. Raising is because of poor quality. try: error = validatePassword(pw, confirm) if error: print(error) return None strength = checkPassword(pw) if strength < 50: raise PWQError("The password you have provided is weak.") except 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) self._app.switch_screen_modal(question_window) if not question_window.answer: return None self.value = cryptPassword(pw) return None else: return _( "Enter new value for '%s' and press enter\n") % entry.title
def prompt(self, entry=None): if not entry: return None if entry.aux == self.PASSWORD: pw = self._app.raw_input(_("%s: ") % entry.title, hidden=True) confirm = self._app.raw_input(_("%s (confirm): ") % entry.title, hidden=True) if (pw and not confirm) or (confirm and not pw): print(_("You must enter your root password and confirm it by typing" " it a second time to continue.")) return None if pw != confirm: print(_(PASSWORD_CONFIRM_ERROR_TUI)) return None # If an empty password was provided, unset the value if not pw: self.value = "" return None valid, strength, message = validatePassword(pw, user=None, minlen=self.policy.minlen) if not valid: print(message) return None if strength < self.policy.minquality: if self.policy.strict: done_msg = "" else: done_msg = _("\nWould you like to use it anyway?") if message: error = _(PASSWORD_WEAK_WITH_ERROR) % message + " " + done_msg else: error = _(PASSWORD_WEAK) % done_msg if not self.policy.strict: question_window = YesNoDialog(self._app, error) self._app.switch_screen_modal(question_window) if not question_window.answer: return None else: print(error) return None if any(char not in PW_ASCII_CHARS for char in pw): print( _( "You have provided a password containing non-ASCII characters.\n" "You may not be able to switch between keyboard layouts to login.\n" ) ) self.value = cryptPassword(pw) return None else: return _("Enter a new value for '%s' and press <Enter>\n") % entry.title
def apply(self): pw = self.pw.get_text() if pw: self.data.rootpw.password = cryptPassword(pw) self.data.rootpw.isCrypted = True self.data.rootpw.lock = self._lock # value from the kickstart changed self.data.rootpw.seen = False self._kickstarted = False self.pw.set_placeholder_text("") self.confirm.set_placeholder_text("")
def apply(self): # set the password only if the user enters anything to the text entry # this should preserve the kickstart based password if self.usepassword.get_active(): if self.pw.get_text(): self._user.password_kickstarted = False self._user.password = cryptPassword(self.pw.get_text()) self._user.isCrypted = True self.pw.set_placeholder_text("") self.confirm.set_placeholder_text("") # reset the password when the user unselects it else: self.pw.set_placeholder_text("") self.confirm.set_placeholder_text("") self._user.password = "" self._user.isCrypted = False self._user.password_kickstarted = False self._user.name = self.username.get_text() self._user.gecos = self.fullname.get_text() # Remove any groups that were created in a previous visit to this spoke self.data.group.groupList = [g for g in self.data.group.groupList \ if not hasattr(g, 'anaconda_group')] # the user will be created only if the username is set if self._user.name: if self.admin.get_active() and \ self._wheel.name not in self._user.groups: self._user.groups.append(self._wheel.name) elif not self.admin.get_active() and \ self._wheel.name in self._user.groups: self._user.groups.remove(self._wheel.name) anaconda_groups = [ self._groupDict[g] for g in self._user.groups if g != self._wheel.name ] self.data.group.groupList += anaconda_groups # Flag the groups as being created in this spoke for g in anaconda_groups: g.anaconda_group = True if self._user not in self.data.user.userList: self.data.user.userList.append(self._user) elif self._user in self.data.user.userList: self.data.user.userList.remove(self._user)
def apply(self): if self._password is None and self._kickstarted: return self.data.rootpw.password = cryptPassword(self._password) self.data.rootpw.isCrypted = True self.data.rootpw.lock = False # value from the kickstart changed self.data.rootpw.seen = False self._kickstarted = False self.pw.set_placeholder_text("") self.confirm.set_placeholder_text("")
def apply(self): # set the password only if the user enters anything to the text entry # this should preserve the kickstart based password if self.usepassword.get_active(): if self.pw.get_text(): self._user.password_kickstarted = False self._user.password = cryptPassword(self.pw.get_text()) self._user.isCrypted = True self.pw.set_placeholder_text("") self.confirm.set_placeholder_text("") # reset the password when the user unselects it else: self.pw.set_placeholder_text("") self.confirm.set_placeholder_text("") self._user.password = "" self._user.isCrypted = False self._user.password_kickstarted = False self._user.name = self.username.get_text() self._user.gecos = self.fullname.get_text() # Remove any groups that were created in a previous visit to this spoke self.data.group.groupList = [g for g in self.data.group.groupList \ if not hasattr(g, 'anaconda_group')] # the user will be created only if the username is set if self._user.name: if self.admin.get_active() and \ self._wheel.name not in self._user.groups: self._user.groups.append(self._wheel.name) elif not self.admin.get_active() and \ self._wheel.name in self._user.groups: self._user.groups.remove(self._wheel.name) anaconda_groups = [self._groupDict[g] for g in self._user.groups if g != self._wheel.name] self.data.group.groupList += anaconda_groups # Flag the groups as being created in this spoke for g in anaconda_groups: g.anaconda_group = True if self._user not in self.data.user.userList: self.data.user.userList.append(self._user) elif self._user in self.data.user.userList: self.data.user.userList.remove(self._user)
def _validate_password(self, password, confirm): """Validate and process user password.""" if (password and not confirm) or (confirm and not password): self._report(_("You must enter your root password and confirm it by typing" " it a second time to continue.")) return None if password != confirm: self._report(_(PASSWORD_CONFIRM_ERROR_TUI)) return None # If an empty password was provided, unset the value if not password: return "" pw_score, _status_text, pw_quality, error_message = validatePassword(password, user=None, minlen=self._policy.minlen) # if the score is equal to 0 and we have an error message set if not pw_score and error_message: self._report(error_message) return None if pw_quality < self._policy.minquality: if self._policy.strict: done_msg = "" else: done_msg = _("\nWould you like to use it anyway?") if error_message: error = _(PASSWORD_WEAK_WITH_ERROR) % error_message + " " + done_msg else: error = _(PASSWORD_WEAK) % done_msg if not self._policy.strict: question_window = YesNoDialog(error) ScreenHandler.push_screen_modal(question_window) if not question_window.answer: return None else: self._report(error) return None if any(char not in PW_ASCII_CHARS for char in password): self._report(_("You have provided a password containing non-ASCII characters.\n" "You may not be able to switch between keyboard layouts to login.\n")) return cryptPassword(password)
def prompt(self, entry=None): if not entry: return None if entry.aux == self.PASSWORD: pw = self._app.raw_input(_("%s: ") % entry.title, hidden=True) confirm = self._app.raw_input(_("%s (confirm): ") % entry.title, hidden=True) if (pw and not confirm) or (confirm and not pw): print( _("You must enter your root password and confirm it by typing" " it a second time to continue.")) return None if (pw != confirm): print(_(PASSWORD_CONFIRM_ERROR_TUI)) return None valid, strength, message = validatePassword(pw, user=None) if not valid: print(message) return None if strength < 50: if message: error = _("You have provided a weak password: %s\n" "Would you like to use it anyway?") % message else: error = _("You have provided a weak password.\n" "Would 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 else: return _( "Enter new value for '%s' and press enter\n") % entry.title
def apply(self): pw = self.pw.get_text() # value from the kickstart changed self.data.rootpw.seen = False self._kickstarted = False self.data.rootpw.lock = False if not pw: self.data.rootpw.password = '' self.data.rootpw.isCrypted = False return self.data.rootpw.password = cryptPassword(pw) self.data.rootpw.isCrypted = True self.pw.set_placeholder_text("") self.confirm.set_placeholder_text("") # Send ready signal to main event loop hubQ.send_ready(self.__class__.__name__, False)
def apply(self): pw = self.password # value from the kickstart changed self.data.rootpw.seen = False self.password_kickstarted = False self.data.rootpw.lock = False if not pw: self.data.rootpw.password = '' self.data.rootpw.isCrypted = False return # we have a password - set it to kickstart data self.data.rootpw.password = cryptPassword(pw) self.data.rootpw.isCrypted = True # clear any placeholders self.remove_placeholder_texts() # Send ready signal to main event loop hubQ.send_ready(self.__class__.__name__, False)
def apply(self): pw = self.password # value from the kickstart changed # NOTE: yet again, this stops to be valid once multiple # commands are supported by a single DBUS module self._users_module.proxy.SetRootpwKickstarted(False) self.password_kickstarted = False self._users_module.proxy.SetRootAccountLocked(False) if not pw: self._users_module.proxy.ClearRootPassword() return # we have a password - set it to kickstart data self._users_module.proxy.SetCryptedRootPassword(cryptPassword(pw)) # clear any placeholders self.remove_placeholder_texts() # Send ready signal to main event loop hubQ.send_ready(self.__class__.__name__, False)
def _validate_password(self, password, confirm): """Validate and process user password.""" if (password and not confirm) or (confirm and not password): self._report( _("You must enter your root password and confirm it by typing" " it a second time to continue.")) return None if password != confirm: self._report( _(constants.PASSWORD_CONFIRM_ERROR_TUI) % {"password_name_plural": _(constants.NAME_OF_PASSWORD_PLURAL)}) return None # If an empty password was provided, unset the value if not password: return "" # prepare a password validation request password_check_request = input_checking.PasswordCheckRequest() password_check_request.password = password password_check_request.password_confirmation = "" password_check_request.policy = self._policy # validate the password password_check = input_checking.PasswordValidityCheck() password_check.run(password_check_request) # if the score is equal to 0 and we have an error message set if not password_check.result.password_score and password_check.result.error_message: self._report(password_check.result.error_message) return None if password_check.result.password_quality < self._policy.minquality: if self._policy.strict: done_msg = "" else: done_msg = _("\nWould you like to use it anyway?") if password_check.result.error_message: error_prefix = _(constants.PASSWORD_WEAK_WITH_ERROR) % { "password_name": _(constants.NAME_OF_PASSWORD), "error_message": password_check.result.error_message } error = "{} {}".format(error_prefix, done_msg) else: weak_prefix = _(constants.PASSWORD_WEAK) % { "password_name": _(constants.NAME_OF_PASSWORD) } error = "{} {}".format(weak_prefix, done_msg) if not self._policy.strict: question_window = YesNoDialog(error) ScreenHandler.push_screen_modal(question_window) if not question_window.answer: return None else: self._report(error) return None if any(char not in constants.PW_ASCII_CHARS for char in password): self._report( _("You have provided a password containing non-ASCII characters.\n" "You may not be able to switch between keyboard layouts to login.\n" )) return cryptPassword(password)
def prompt(self, args=None): entry = args if not entry: return None if entry.aux == self.PASSWORD: pw = self.get_user_input(_("%s: ") % entry.title, hidden=True) confirm = self.get_user_input(_("%s (confirm): ") % entry.title, hidden=True) if (pw and not confirm) or (confirm and not pw): print(_("You must enter your root password and confirm it by typing" " it a second time to continue.")) return None if pw != confirm: print(_(PASSWORD_CONFIRM_ERROR_TUI)) return None # If an empty password was provided, unset the value if not pw: self.value = "" return None pw_score, _status_text, pw_quality, error_message = validatePassword(pw, user=None, minlen=self.policy.minlen) # if the score is equal to 0 and we have an error message set if not pw_score and error_message: print(error_message) return None if pw_quality < self.policy.minquality: if self.policy.strict: done_msg = "" else: done_msg = _("\nWould you like to use it anyway?") if error_message: error = _(PASSWORD_WEAK_WITH_ERROR) % error_message + " " + done_msg else: error = _(PASSWORD_WEAK) % done_msg if not self.policy.strict: question_window = YesNoDialog(error) ScreenHandler.push_screen_modal(question_window) if not question_window.answer: return None else: print(error) return None if any(char not in PW_ASCII_CHARS for char in pw): print(_("You have provided a password containing non-ASCII characters.\n" "You may not be able to switch between keyboard layouts to login.\n")) self.value = cryptPassword(pw) return None else: return Prompt(_("Enter a new value for '%(title)s' and press %(enter)s") % { # TRANSLATORS: 'title' as a title of the entry "title": entry.title, # TRANSLATORS: 'enter' as the key ENTER "enter": Prompt.ENTER })
def prompt(self, entry=None): if not entry: return None if entry.aux == self.PASSWORD: pw = self._app.raw_input(_("%s: ") % entry.title, hidden=True) confirm = self._app.raw_input(_("%s (confirm): ") % entry.title, hidden=True) if (pw and not confirm) or (confirm and not pw): print( _("You must enter your root password and confirm it by typing" " it a second time to continue.")) return None if (pw != confirm): print(_(PASSWORD_CONFIRM_ERROR_TUI)) return None # If an empty password was provided, unset the value if not pw: self.value = "" return None pw_score, _status_text, pw_quality, error_message = validatePassword( pw, user=None, minlen=self.policy.minlen) # if the score is equal to 0 and we have an error message set # - ignore if the strict flag in the password policy == False if not pw_score and error_message and self.policy.strict: print(error_message) return None if pw_quality < self.policy.minquality: if self.policy.strict: done_msg = "" else: done_msg = _("\nWould you like to use it anyway?") if error_message: error = _(PASSWORD_WEAK_WITH_ERROR ) % error_message + " " + done_msg else: error = _(PASSWORD_WEAK) % done_msg if not self.policy.strict: question_window = YesNoDialog(self._app, error) self._app.switch_screen_modal(question_window) if not question_window.answer: return None else: print(error) return None if any(char not in PW_ASCII_CHARS for char in pw): print( _("You have provided a password containing non-ASCII characters.\n" "You may not be able to switch between keyboard layouts to login.\n" )) self.value = cryptPassword(pw) return None else: return _( "Enter new value for '%s' and press enter\n") % entry.title
def apply(self): self.data.rootpw.password = cryptPassword(self._password) self.data.rootpw.isCrypted = True self.data.rootpw.lock = False self.data.rootpw.seen = False