예제 #1
0
class LUKSOptionsForm(SubForm):

    password = PasswordField(_("Passphrase:"))
    confirm_password = PasswordField(_("Confirm passphrase:"))

    def validate_password(self):
        if len(self.password.value) < 1:
            return _("Password must be set")

    def validate_confirm_password(self):
        if self.password.value != self.confirm_password.value:
            return _("Passwords do not match")
예제 #2
0
class VolGroupForm(CompoundDiskForm):
    def __init__(self, model, possible_components, initial, vg_names,
                 deleted_vg_names):
        self.vg_names = vg_names
        self.deleted_vg_names = deleted_vg_names
        super().__init__(model, possible_components, initial)
        connect_signal(self.encrypt.widget, 'change', self._change_encrypt)
        setup_password_validation(self, _("passphrases"))
        self._change_encrypt(None, self.encrypt.value)

    name = VGNameField(_("Name:"))
    devices = MultiDeviceField(_("Devices:"))
    size = ReadOnlyField(_("Size:"))
    encrypt = BooleanField(_("Create encrypted volume"))
    password = PasswordField(_("Passphrase:"))
    confirm_password = PasswordField(_("Confirm passphrase:"))

    def _change_encrypt(self, sender, new_value):
        self.password.enabled = new_value
        self.confirm_password.enabled = new_value
        if not new_value:
            self.password.validate()
            self.confirm_password.validate()

    def validate_devices(self):
        if len(self.devices.value) < 1:
            return _("Select at least one device to be part of the volume "
                     "group.")

    def validate_name(self):
        v = self.name.value
        if not v:
            return _("The name of a volume group cannot be empty")
        if v.startswith('-'):
            return _("The name of a volume group cannot start with a hyphen")
        if v in self.vg_names:
            return _("There is already a volume group named '{name}'").format(
                name=self.name.value)
        if v in ('.', '..', 'md') or os.path.exists('/dev/' + v):
            if v not in self.deleted_vg_names:
                return _("{name} is not a valid name for a volume "
                         "group").format(name=v)

    def validate_password(self):
        if self.encrypt.value and len(self.password.value) < 1:
            return _("Passphrase must be set")

    def validate_confirm_password(self):
        if self.encrypt.value and \
          self.password.value != self.confirm_password.value:
            return _("Passphrases do not match")
예제 #3
0
class WLANForm(Form):

    ssid = StringField(caption="Network Name:")
    psk = PasswordField(caption="Password:"******"Password must be at least 8 characters long if present"
        elif len(psk) > 63:
            return "Password must be less than 63 characters long"