[elbe-devel] [PATCH v3 2/7] finetuning: use chpasswd for user password

Holger Dengler holger at hdengler.de
Thu Jun 30 08:00:02 CEST 2022


Use batch-mode tool "chpasswd" for setting user passwords. It allows the
processing of plain-text and hashed passwords.

Signed-off-by: Holger Dengler <holger at hdengler.de>
Reviewed-by: Bastian Germann <bage at linutronix.de>
---
 elbepack/finetuning.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/elbepack/finetuning.py b/elbepack/finetuning.py
index 52051223b..920d7bba3 100644
--- a/elbepack/finetuning.py
+++ b/elbepack/finetuning.py
@@ -276,9 +276,8 @@ class AddUserAction(FinetuningAction):
             chroot(target.path, cmd)
 
             if 'passwd' in att:
-                cmd = "passwd %s" % self.node.et.text
-                stdin = "%s\n%s\n" % (att["passwd"], att["passwd"])
-                chroot(target.path, cmd, stdin=stdin)
+                stdin = "%s:%s" % (self.node.et.text, att["passwd"])
+                chroot(target.path, "chpasswd", stdin=stdin)
 
 
 @FinetuningAction.register('addgroup')
-- 
2.36.1



More information about the elbe-devel mailing list