Exemple #1
0
    def apply(self):
        if self.args.gecos and not self.args.name:
            username = guess_username(self.args.gecos)
            if USERNAME_VALID.match(username):
                self.args.name = guess_username(self.args.gecos)

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

        # Add or remove the user from wheel group
        if self.args._admin and "wheel" not in self.args.groups:
            self.args.groups.append("wheel")
        elif not self.args._admin and "wheel" in self.args.groups:
            self.args.groups.remove("wheel")

        # Add or remove the user from userlist as needed
        if self.args._create and (self.args not in self.data.user.userList):
            self.data.user.userList.append(self.args)
        elif (not self.args._create) and (self.args in self.data.user.userList):
            self.data.user.userList.remove(self.args)

        # encrypt and store password only if user entered anything; this should
        # preserve passwords set via kickstart
        if self.args._use_password and len(self.args._password) > 0:
            self.args.password = self.args._password
            self.args.isCrypted = True
            self.args.password_kickstarted = False
        # clear pw when user unselects to use pw
        else:
            self.args.password = ""
            self.args.isCrypted = False
            self.args.password_kickstarted = False
Exemple #2
0
    def apply(self):
        if self._user_data.gecos and not self._user_data.name:
            username = guess_username(self._user_data.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_data.name = guess_username(self._user_data.gecos)

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

        # Add or remove the user from wheel group
        if self._is_admin and "wheel" not in self._user_data.groups:
            self._user_data.groups.append("wheel")
        elif not self._is_admin and "wheel" in self._user_data.groups:
            self._user_data.groups.remove("wheel")

        # Add or remove the user from userlist as needed
        if self._create_user and (self._user_data not in self.data.user.userList and self._user_data.name):
            self.data.user.userList.append(self._user_data)
        elif (not self._create_user) and (self._user_data in self.data.user.userList):
            self.data.user.userList.remove(self._user_data)

        # encrypt and store password only if user entered anything; this should
        # preserve passwords set via kickstart
        if self._use_password and self._user_data.password and len(self._user_data.password) > 0:
            self._user_data.password = self._user_data.password
            self._user_data.isCrypted = True
        # clear pw when user unselects to use pw
        else:
            self._user_data.password = ""
            self._user_data.isCrypted = False
Exemple #3
0
    def apply(self):
        if self.args.gecos and not self.args.name:
            username = guess_username(self.args.gecos)
            if USERNAME_VALID.match(username):
                self.args.name = guess_username(self.args.gecos)

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

        # Add or remove the user from wheel group
        if self.args._admin and "wheel" not in self.args.groups:
            self.args.groups.append("wheel")
        elif not self.args._admin and "wheel" in self.args.groups:
            self.args.groups.remove("wheel")

        # Add or remove the user from userlist as needed
        if self.args._create and (self.args not in self.data.user.userList):
            self.data.user.userList.append(self.args)
        elif (not self.args._create) and (self.args
                                          in self.data.user.userList):
            self.data.user.userList.remove(self.args)

        # encrypt and store password only if user entered anything; this should
        # preserve passwords set via kickstart
        if self.args._use_password and len(self.args._password) > 0:
            self.args.password = self.args._password
            self.args.isCrypted = True
            self.args.password_kickstarted = False
        # clear pw when user unselects to use pw
        else:
            self.args.password = ""
            self.args.isCrypted = False
            self.args.password_kickstarted = False
Exemple #4
0
    def apply(self):
        if self.args.gecos and not self.args.name:
            username = guess_username(self.args.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.args.name = guess_username(self.args.gecos)

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

        # Add or remove the user from wheel group
        if self.args._admin and "wheel" not in self.args.groups:
            self.args.groups.append("wheel")
        elif not self.args._admin and "wheel" in self.args.groups:
            self.args.groups.remove("wheel")

        # Add or remove the user from userlist as needed
        if self.args._create and (self.args not in self.data.user.userList and self.args.name):
            self.data.user.userList.append(self.args)
        elif (not self.args._create) and (self.args in self.data.user.userList):
            self.data.user.userList.remove(self.args)

        # encrypt and store password only if user entered anything; this should
        # preserve passwords set via kickstart
        if self.args._use_password and len(self.args._password) > 0:
            self.args.password = self.args._password
            self.args.isCrypted = True
            self.args.password_kickstarted = False
        # clear pw when user unselects to use pw
        else:
            self.args.password = ""
            self.args.isCrypted = False
            self.args.password_kickstarted = False
Exemple #5
0
    def full_name_changed(self, editable, data=None):
        """Called by Gtk callback when the full name field changes."""

        if self.guesser:
            fullname = editable.get_text()
            username = guess_username(fullname)

            with blockedHandler(self.username, self.on_username_set_by_user):
                self.username.set_text(username)
Exemple #6
0
    def full_name_changed(self, editable, data=None):
        """Called by Gtk callback when the full name field changes."""

        if self.guesser:
            fullname = editable.get_text()
            username = guess_username(fullname)

            with blockedHandler(self.username, self.on_username_set_by_user):
                self.username.set_text(username)
Exemple #7
0
    def full_name_changed(self, editable=None, data=None):
        """Called by Gtk callback when the full name field changes.
        It guesses the username and hostname, strips diacritics
        and make those lowercase.
        """

        # after the text is updated in guesser, the guess has to be reenabled
        if self.guesser[self.username]:
            fullname = self.fullname.get_text()
            username = guess_username(fullname)
            self.username.set_text(username)
            self.guesser[self.username] = True
Exemple #8
0
    def full_name_changed(self, editable=None, data=None):
        """Called by Gtk callback when the full name field changes.
        It guesses the username and hostname, strips diacritics
        and make those lowercase.
        """

        # after the text is updated in guesser, the guess has to be reenabled
        if self.guesser[self.username]:
            fullname = self.fullname.get_text()
            username = guess_username(fullname)
            self.username.set_text(username)
            self.guesser[self.username] = True
Exemple #9
0
    def on_full_name_changed(self, editable, data=None):
        """Called by Gtk callback when the full name field changes."""

        fullname = editable.get_text()
        if self.guesser:
            username = guess_username(fullname)
            with blockedHandler(self.username_entry, self.on_username_set_by_user):
                self.username = username

        self.checker.fullname = fullname

        # rerun the checks
        self.checker.run_checks()
Exemple #10
0
    def on_full_name_changed(self, editable, data=None):
        """Called by Gtk callback when the full name field changes."""

        fullname = editable.get_text()
        if self.guesser:
            username = guess_username(fullname)
            with blockedHandler(self.username_entry, self.on_username_set_by_user):
                self.username = username

        self.checker.fullname = fullname

        # rerun the checks
        self.checker.run_checks()
    def apply(self):
        if self.args.gecos and not self.args.name:
            self.args.name = guess_username(self.args.gecos)

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

        # Add or remove the user from wheel group
        if self.args._admin and "wheel" not in self.args.groups:
            self.args.groups.append("wheel")
        elif not self.args._admin and "wheel" in self.args.groups:
            self.args.groups.remove("wheel")

        # Add or remove the user from userlist as needed
        if self.args._create and (self.args not in self.data.user.userList):
            self.data.user.userList.append(self.args)
        elif (not self.args._create) and (self.args in self.data.user.userList):
            self.data.user.userList.remove(self.args)