From e4d586032605a441fb18d952bbd0751fd1ea4e4b Mon Sep 17 00:00:00 2001 From: root Date: Fri, 4 Oct 2024 09:46:36 +0200 Subject: [PATCH] =?UTF-8?q?=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20creatusr.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sio2/SISR/07-python/creatusr/creatusr.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sio2/SISR/07-python/creatusr/creatusr.py b/sio2/SISR/07-python/creatusr/creatusr.py index 88e1d2a..3a0df7e 100644 --- a/sio2/SISR/07-python/creatusr/creatusr.py +++ b/sio2/SISR/07-python/creatusr/creatusr.py @@ -7,7 +7,11 @@ def create_user(login, nomcomplet): cmds = ["useradd", "-m", "-c", nomcomplet, "-s", "/bin/bash", login] res = subprocess.run(cmds,stdout=subprocess.PIPE) print ("createusr : utilisateur ", login, " cree") - + res=subprocess.run(["pwgen", "8", "1"],stdout=subprocess.PIPE) + pw = res.stdout.decode('utf8') + print (pw) + cmds = ["echo", login , ":" ,pw, "chpasswd"] + cmds = ["echo", login , ":" ,pw >> users.txt.pw] if len(sys.argv) != 2 : print ("usage : ", sys.argv[0], " ") exit (1)