Fix password setting using chpasswd -R and improve screen wake lock
This commit is contained in:
@@ -239,21 +239,6 @@ UUID={efi_uuid} /boot vfat defaults 0 2
|
|||||||
# Ensure changes to /etc/passwd and /etc/shadow are flushed
|
# Ensure changes to /etc/passwd and /etc/shadow are flushed
|
||||||
run_command(["sync"])
|
run_command(["sync"])
|
||||||
|
|
||||||
# Set password using passwd --stdin
|
|
||||||
try:
|
|
||||||
logger.info("Setting user password...")
|
|
||||||
p = subprocess.run(
|
|
||||||
["chroot", mount_root, "passwd", "--stdin", user_info["username"]],
|
|
||||||
input=f"{user_info['password']}\n",
|
|
||||||
text=True,
|
|
||||||
check=True,
|
|
||||||
stdout=subprocess.PIPE,
|
|
||||||
stderr=subprocess.PIPE
|
|
||||||
)
|
|
||||||
except subprocess.CalledProcessError as e:
|
|
||||||
logger.error(f"Failed to set password: {e.stderr}")
|
|
||||||
raise e
|
|
||||||
|
|
||||||
# Ensure wheel group has sudo privileges
|
# Ensure wheel group has sudo privileges
|
||||||
sudoers_dir = os.path.join(mount_root, "etc/sudoers.d")
|
sudoers_dir = os.path.join(mount_root, "etc/sudoers.d")
|
||||||
os.makedirs(sudoers_dir, exist_ok=True)
|
os.makedirs(sudoers_dir, exist_ok=True)
|
||||||
@@ -261,6 +246,21 @@ UUID={efi_uuid} /boot vfat defaults 0 2
|
|||||||
f.write("%wheel ALL=(ALL) ALL\n")
|
f.write("%wheel ALL=(ALL) ALL\n")
|
||||||
os.chmod(os.path.join(sudoers_dir, "wheel"), 0o440)
|
os.chmod(os.path.join(sudoers_dir, "wheel"), 0o440)
|
||||||
|
|
||||||
|
# Set user and root password using chpasswd -R (from host side)
|
||||||
|
try:
|
||||||
|
logger.info(f"Setting passwords for {user_info['username']} and root...")
|
||||||
|
# We set both to the same password for convenience in this minimal install
|
||||||
|
pass_data = f"{user_info['username']}:{user_info['password']}\nroot:{user_info['password']}\n"
|
||||||
|
subprocess.run(
|
||||||
|
["chpasswd", "-R", mount_root],
|
||||||
|
input=pass_data,
|
||||||
|
text=True,
|
||||||
|
check=True
|
||||||
|
)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
logger.error("Failed to set passwords using chpasswd -R")
|
||||||
|
raise e
|
||||||
|
|
||||||
# Set hostname
|
# Set hostname
|
||||||
with open(os.path.join(mount_root, "etc/hostname"), "w") as f:
|
with open(os.path.join(mount_root, "etc/hostname"), "w") as f:
|
||||||
f.write(user_info["hostname"] + "\n")
|
f.write(user_info["hostname"] + "\n")
|
||||||
|
|||||||
@@ -230,6 +230,12 @@ class InstallerWindow(Adw.ApplicationWindow):
|
|||||||
if self.log_handler:
|
if self.log_handler:
|
||||||
logging.getLogger().removeHandler(self.log_handler)
|
logging.getLogger().removeHandler(self.log_handler)
|
||||||
self.log_handler = None
|
self.log_handler = None
|
||||||
|
|
||||||
|
# Release wake lock if held
|
||||||
|
if hasattr(self, "inhibit_cookie") and self.inhibit_cookie:
|
||||||
|
app = self.get_application()
|
||||||
|
app.uninhibit(self.inhibit_cookie)
|
||||||
|
self.inhibit_cookie = None
|
||||||
|
|
||||||
finish_page = Adw.StatusPage()
|
finish_page = Adw.StatusPage()
|
||||||
finish_page.set_title(message)
|
finish_page.set_title(message)
|
||||||
@@ -465,11 +471,11 @@ class InstallerWindow(Adw.ApplicationWindow):
|
|||||||
# Show success in UI even in mock
|
# Show success in UI even in mock
|
||||||
self.show_finish_page("Mock Installation Complete!")
|
self.show_finish_page("Mock Installation Complete!")
|
||||||
else:
|
else:
|
||||||
# Inhibit logout/suspend
|
# Inhibit logout/suspend/idle
|
||||||
app = self.get_application()
|
app = self.get_application()
|
||||||
self.inhibit_cookie = app.inhibit(
|
self.inhibit_cookie = app.inhibit(
|
||||||
self,
|
self,
|
||||||
Gtk.ApplicationInhibitFlags.LOGOUT | Gtk.ApplicationInhibitFlags.SUSPEND,
|
Gtk.ApplicationInhibitFlags.LOGOUT | Gtk.ApplicationInhibitFlags.SUSPEND | Gtk.ApplicationInhibitFlags.IDLE,
|
||||||
"Installing Operating System"
|
"Installing Operating System"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user