Exemple #1
0
    def _get_conditional_input(self, data):  # pylint: disable=unused-argument
        """Callback when user wants to set conditional input.

        :param data: can be passed when adding callback in container (not used here)
        :type data: anything
        """
        dialog = PasswordDialog("Unconditional password input", policy_name=PASSWORD_POLICY_ROOT)

        self._conditional_input = dialog.run()
    def _get_conditional_input(self, data):
        """Callback when user wants to set conditional input.

        :param data: can be passed when adding callback in container (not used here)
        :type data: anything
        """

        # password policy for setting root password
        password_policy = self.data.anaconda.pwpolicy.get_policy("root", fallback_to_default=True)
        dialog = PasswordDialog("Unconditional input", policy=password_policy)

        self._conditional_input = dialog.run()
Exemple #3
0
    def _get_conditional_input(self, data):  # pylint: disable=unused-argument
        """Callback when user wants to set conditional input.

        :param data: can be passed when adding callback in container (not used here)
        :type data: anything
        """
        # password policy for setting root password
        password_policy = self.data.anaconda.pwpolicy.get_policy(
            "root", fallback_to_default=True)
        dialog = PasswordDialog("Unconditional password input",
                                policy=password_policy)

        self._conditional_input = dialog.run()
Exemple #4
0
    def show_all(self):
        super().show_all()

        password_dialog = PasswordDialog(title=_("Password"),
                                         policy_name=PASSWORD_POLICY_ROOT)
        password_dialog.no_separator = True
        self._password = password_dialog.run()

        if self._password is None:
            self.redraw()
            return
        else:
            self.apply()
            self.close()
Exemple #5
0
    def show_all(self):
        super().show_all()

        password_dialog = PasswordDialog(_("Password"), policy=self._policy)
        password_dialog.no_separator = True

        self._password = password_dialog.run()

        if self._password is None:
            self.redraw()
            return
        else:
            self.apply()
            self.close()
Exemple #6
0
    def show_all(self):
        super().show_all()

        password_dialog = PasswordDialog(_("Password"), policy=self._policy)
        password_dialog.no_separator = True

        self._password = password_dialog.run()

        if self._password is None:
            self.redraw()
            return
        else:
            self.apply()
            self.close()
Exemple #7
0
    def _unlock_devices(self):
        """Attempt to unlock all locked LUKS devices.

        Returns true if all devices were unlocked.
        """
        try_passphrase = None
        for device_name in self._rescue.get_locked_device_names():
            skip = False
            unlocked = False
            while not (skip or unlocked):
                if try_passphrase is None:
                    p = PasswordDialog(self.app, device_name)
                    self.app.switch_screen_modal(p)
                    if p.answer:
                        passphrase = p.answer.strip()
                else:
                    passphrase = try_passphrase

                if passphrase is None:
                    # cancelled
                    skip = True
                else:
                    unlocked = self._rescue.unlock_device(
                        device_name, passphrase)
                    try_passphrase = passphrase if unlocked else None

        return not self._rescue.get_locked_device_names()
Exemple #8
0
    def run_passphrase_dialog(self):
        """Ask user for a default passphrase."""
        if not self._is_passphrase_required():
            return

        dialog = PasswordDialog(
            title=_("Passphrase"),
            message=_(
                "Please provide a default LUKS passphrase for all devices "
                "you want to encrypt. You will have to type it twice."),
            secret_type=SecretType.PASSPHRASE,
            policy=get_policy(self.data, "luks"),
            process_func=lambda x: x)

        passphrase = None
        while passphrase is None:
            passphrase = dialog.run()

        self._set_required_passphrase(passphrase)
Exemple #9
0
    def run_passphrase_dialog(self):
        """Ask user for a default passphrase."""
        if not is_passphrase_required(self._partitioning):
            return

        dialog = PasswordDialog(
            title=_("Passphrase"),
            message=_(
                "Please provide a default LUKS passphrase for all devices "
                "you want to encrypt. You will have to type it twice."),
            secret_type=SecretType.PASSPHRASE,
            policy_name=PASSWORD_POLICY_LUKS,
            process_func=lambda x: x)

        passphrase = None
        while passphrase is None:
            passphrase = dialog.run()

        set_required_passphrase(self._partitioning, passphrase)
Exemple #10
0
    def run_passphrase_dialog(self):
        """Ask user for a default passphrase."""
        data_without_passphrase = self._get_data_without_passphrase()
        if not data_without_passphrase:
            return

        dialog = PasswordDialog(
            title=_("Passphrase"),
            message=_("Please provide a default LUKS passphrase for all devices "
                      "you want to encrypt. You will have to type it twice."),
            secret_type=SecretType.PASSPHRASE,
            policy=get_policy(self.data, "luks"),
            process_func=lambda x: x
        )

        passphrase = None
        while passphrase is None:
            passphrase = dialog.run()

        self._set_data_without_passphrase(data_without_passphrase, passphrase)
Exemple #11
0
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)

        # refresh the user list
        self._user_list = get_user_list(self._users_module,
                                        add_default=True,
                                        add_if_not_empty=self._user_cleared)

        self._is_admin = self.user.has_admin_priviledges()
        self._groups = ", ".join(self.user.groups)

        self._container = ListColumnContainer(1)

        w = CheckboxWidget(title=_("Create user"), completed=self._create_user)
        self._container.add(w, self._set_create_user)

        if self._create_user:
            dialog = Dialog(title=_("Full name"),
                            conditions=[self._check_fullname])
            self._container.add(EntryWidget(dialog.title, self.user.gecos),
                                self._set_fullname, dialog)

            dialog = Dialog(title=_("User name"),
                            conditions=[self._check_username])
            self._container.add(EntryWidget(dialog.title, self.user.name),
                                self._set_username, dialog)

            w = CheckboxWidget(title=_("Use password"),
                               completed=self._use_password)
            self._container.add(w, self._set_use_password)

            if self._use_password:
                password_dialog = PasswordDialog(
                    title=_("Password"), policy_name=PASSWORD_POLICY_USER)
                if self.user.password:
                    entry = EntryWidget(password_dialog.title, _(PASSWORD_SET))
                else:
                    entry = EntryWidget(password_dialog.title)

                self._container.add(entry, self._set_password, password_dialog)

            msg = _("Administrator")
            w = CheckboxWidget(title=msg, completed=self._is_admin)
            self._container.add(w, self._set_administrator)

            dialog = Dialog(title=_("Groups"), conditions=[self._check_groups])
            self._container.add(EntryWidget(dialog.title, self._groups),
                                self._set_groups, dialog)

        self.window.add_with_separator(self._container)
Exemple #12
0
    def _unlock_devices(self):
        """
            Loop through devices and attempt to unlock any which are detected as
            LUKS devices.
        """
        try_passphrase = None
        for device in self.storage.devices:
            if device.format.type != "luks":
                continue

            skip = False
            unlocked = False
            while not (skip or unlocked):
                if try_passphrase is None:
                    p = PasswordDialog(self.app, device.name)
                    self.app.switch_screen_modal(p)
                    if p.answer:
                        passphrase = p.answer.strip()
                else:
                    passphrase = try_passphrase

                if passphrase is None:
                    # canceled
                    skip = True
                else:
                    device.format.passphrase = passphrase
                    try:
                        device.setup()
                        device.format.setup()
                        luks_dev = LUKSDevice(device.format.map_name,
                                              parents=[device],
                                              exists=True)
                        self.storage.devicetree._add_device(luks_dev)

                        # Wait for the device.
                        # Otherwise, we could get a message about no Linux partitions.
                        time.sleep(2)

                        try_populate_devicetree(self.storage.devicetree)
                        unlocked = True
                        # try to use the same passhprase for other devices
                        try_passphrase = passphrase
                    except StorageError as serr:
                        log.error("Failed to unlock %s: %s", device.name, serr)
                        device.teardown(recursive=True)
                        device.format.passphrase = None
                        try_passphrase = None
        return True
Exemple #13
0
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)
        self._is_admin = "wheel" in self._user_data.groups
        self._groups = ", ".join(self._user_data.groups)

        self._container = ListColumnContainer(1)

        w = CheckboxWidget(title=_("Create user"), completed=self._create_user)
        self._container.add(w, self._set_create_user)

        if self._create_user:
            dialog = Dialog(title=_("Full name"),
                            conditions=[self._check_fullname])
            self._container.add(
                EntryWidget(dialog.title, self._user_data.gecos),
                self._set_fullname, dialog)

            dialog = Dialog(title=_("User name"),
                            conditions=[self._check_username])
            self._container.add(
                EntryWidget(dialog.title, self._user_data.name),
                self._set_username, dialog)

            w = CheckboxWidget(title=_("Use password"),
                               completed=self._use_password)
            self._container.add(w, self._set_use_password)

            if self._use_password:
                password_dialog = PasswordDialog(title=_("Password"),
                                                 policy=self._policy)
                if self._user_data.password:
                    entry = EntryWidget(password_dialog.title, _(PASSWORD_SET))
                else:
                    entry = EntryWidget(password_dialog.title)

                self._container.add(entry, self._set_password, password_dialog)

            msg = _("Administrator")
            w = CheckboxWidget(title=msg, completed=self._is_admin)
            self._container.add(w, self._set_administrator)

            dialog = Dialog(title=_("Groups"), conditions=[self._check_groups])
            self._container.add(EntryWidget(dialog.title, self._groups),
                                self._set_groups, dialog)

        self.window.add_with_separator(self._container)