self.bricklayer.settings["root-password"] = password
-class SetRootPassword(Step):
+class SetRootPassword(InteractiveStep):
+ first_install = True
+
def run(self):
with self.tui.progress(_("Applying Configuration"),
- _("Setting password for the '%s' user...")) as t:
+ _("Setting password for the 'root' user...")) as t:
+ # Fetch the password
+ password = self.bricklayer.settings.get("root-password")
+
+ # Fail if no password has been set
+ if not password:
+ raise ValueError("No password has been set")
+
+ # Encode the password
+ password = password.encode()
+
+ # Send the password twice
+ input = b"%s\n%s\n" % (password, password)
+
+ # Setup Pakfire
p = self.bricklayer.setup_pakfire()
- # XXX execute currently has no way to write to stdin, which is
- # why we reset the root password here, so that we will have a working login
- p.execute(["passwd", "--delete", "root"])
+ # Set the password
+ p.execute(["passwd", "root"], input=input)
class ToggleFirstInstallStatus(Step):