[elbe-devel] [PATCH v2 2/8] finetuning: use chpasswd for user password

Holger Dengler holger at hdengler.de
Thu Jun 16 12:10:08 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>
---
 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