def commit(self):
     try:
         model = defaults.SSH()
         model.update(num_bytes=OVIRT_VARS["OVIRT_USE_STRONG_RNG"])
         tx = model.transaction()
         tx()
     except:
         logger.warning("Unknown ssh strong RNG: %s" % \
                        OVIRT_VARS["OVIRT_USE_STRONG_RNG"])
 def commit(self):
     try:
         model = defaults.SSH()
         model.update(disable_aesni=True)
         tx = model.transaction()
         tx()
     except:
         logger.warning("Unknown ssh AES NI: %s" % \
                        OVIRT_VARS["OVIRT_DISABLE_AES_NI"])
Beispiel #3
0
 def model(self):
     cfg = defaults.SSH().retrieve()
     self.logger.debug(cfg)
     model = {
         "ssh.pwauth": cfg["pwauth"] or False,
         "strongrng.disable_aesni": cfg["disable_aesni"] or False,
         "strongrng.num_bytes": cfg["num_bytes"] or "",
         "passwd.admin.password": "",
     }
     return model
Beispiel #4
0
    def on_merge(self, effective_changes):
        self.logger.debug("Saving security page")
        changes = Changeset(self.pending_changes(False))
        effective_model = Changeset(self.model())
        effective_model.update(effective_changes)

        self.logger.debug("Changes: %s" % changes)
        self.logger.debug("Effective Model: %s" % effective_model)

        ssh_keys = [
            "ssh.pwauth", "strongrng.num_bytes", "strongrng.disable_aesni"
        ]
        passwd_keys = [
            "passwd.admin.password", "passwd.admin.password_confirmation"
        ]

        txs = utils.Transaction("Updating security configuration")

        if changes.contains_any(ssh_keys):
            model = defaults.SSH()
            model.update(*effective_model.values_for(ssh_keys))
            txs += model.transaction()

        if changes.contains_any(passwd_keys):
            pw, pwc = effective_model.values_for(passwd_keys)
            if pw != pwc:
                raise exceptions.InvalidData("Passwords do not match")
            passwd = utils.security.Passwd()

            # Create a custom transaction element, because the password
            # is not handled/saved in the defaults file
            class SetAdminPasswd(utils.Transaction.Element):
                title = "Setting admin password"

                def commit(self):
                    self.logger.debug("Setting admin password.")
                    passwd.set_password("admin", pw)

            txs += [SetAdminPasswd()]

        progress_dialog = ui.TransactionProgressDialog("dialog.txs", txs, self)
        progress_dialog.run()