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)
|
# Create user and add to wheel group (sudoer)
|
||||||
run_command(["chroot", mount_root, "useradd", "-m", "-G", "wheel", user_info["username"]])
|
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:
|
try:
|
||||||
logger.info("Setting user password...")
|
logger.info("Setting user password...")
|
||||||
p = subprocess.run(
|
p = subprocess.run(
|
||||||
["chroot", mount_root, "chpasswd"],
|
["chroot", mount_root, "passwd", "--stdin", user_info["username"]],
|
||||||
input=f"{user_info['username']}:{user_info['password']}\n",
|
input=f"{user_info['password']}\n",
|
||||||
text=True,
|
text=True,
|
||||||
check=True,
|
check=True,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
|
|||||||
Reference in New Issue
Block a user