Generate temporary password in adduser

This commit is contained in:
Anthony Wang 2022-06-25 19:22:04 -05:00
parent ee81994947
commit d619b166be
Signed by: a
GPG key ID: BC96B00AEC5F2D76

14
adduser
View file

@ -2,10 +2,11 @@
# A wrapper script over ldapadd
from sys import argv
from os import remove
from subprocess import run, call, check_output
from crypt import crypt
from os import remove
from secrets import token_urlsafe
from subprocess import run, call, check_output
from sys import argv
def configure(username):
@ -65,7 +66,12 @@ gidNumber: {uid}'''
if ret != 0:
return
# Configure and set up user
configure(username)
adduser(*[argv[i] for i in range(1, 6)])
# Generate temporary password
password = token_urlsafe(6)
print('Temporary password:', password)
adduser(*[argv[i] for i in range(1, 5)], password)