Fix password setting by using passwd --stdin and sync
This commit is contained in:
@@ -236,12 +236,15 @@ UUID={efi_uuid} /boot vfat defaults 0 2
|
||||
# Create user and add to wheel group (sudoer)
|
||||
run_command(["chroot", mount_root, "useradd", "-m", "-G", "wheel", user_info["username"]])
|
||||
|
||||
# Set password
|
||||
# Ensure changes to /etc/passwd and /etc/shadow are flushed
|
||||
run_command(["sync"])
|
||||
|
||||
# Set password using passwd --stdin
|
||||
try:
|
||||
logger.info("Setting user password...")
|
||||
p = subprocess.run(
|
||||
["chroot", mount_root, "chpasswd"],
|
||||
input=f"{user_info['username']}:{user_info['password']}\n",
|
||||
["chroot", mount_root, "passwd", "--stdin", user_info["username"]],
|
||||
input=f"{user_info['password']}\n",
|
||||
text=True,
|
||||
check=True,
|
||||
stdout=subprocess.PIPE,
|
||||
|
||||
Reference in New Issue
Block a user