Exemplo n.º 1
0
 def run(self, check_request):
     """Check if the username is valid."""
     # in some cases an empty username is also considered valid,
     # so that the user can exit the User spoke without filling it in
     if self.success_if_username_empty and not check_request.username:
         self.result.error_message = ""
         self.result.success = True
     else:
         success, error_message = users.check_username(
             check_request.username)
         self.result.error_message = error_message
         self.result.success = success
Exemplo n.º 2
0
    def apply(self):
        if self.user.gecos and not self.user.name:
            username = guess_username(self.user.gecos)
            valid, msg = check_username(username)
            if not valid:
                self.errors.append(
                    _("Invalid user name: %(name)s.\n%(error_message)s") % {
                        "name": username,
                        "error_message": msg
                    })
            else:
                self.user.name = guess_username(self.user.gecos)

        self.user.groups = [g.strip() for g in self._groups.split(",") if g]

        # Add or remove user admin status
        self.user.set_admin_priviledges(self._is_admin)

        # encrypt and store password only if user entered anything; this should
        # preserve passwords set via kickstart
        if self._use_password and self.user.password and len(
                self.user.password) > 0:
            self.user.password = self.user.password
            self.user.is_crypted = True
        # clear pw when user unselects to use pw
        else:
            self.user.password = ""
            self.user.is_crypted = False

        # Turning user creation off clears any already configured user,
        # regardless of origin (kickstart, user, DBus).
        if not self._create_user and self.user.name:
            self.user.name = ""
            self._user_cleared = True
        # An the other hand, if we have a user with name set,
        # it is valid and should be used if the spoke is re-visited.
        if self.user.name:
            self._user_cleared = False
        # Set the user list while removing any unset users, where unset
        # means the user has nema == "".
        set_user_list(self._users_module, self._user_list, remove_unset=True)
Exemplo n.º 3
0
 def _check_username(self, user_input, report_func):
     return check_username(user_input)
Exemplo n.º 4
0
 def _check_name(self, name):
     return check_username(name)