Don't reuse UIDs, use max(uids)+1 in adduser
This commit is contained in:
parent
9acc13c1cb
commit
b2a0acfdcd
3
adduser
3
adduser
|
@ -13,8 +13,7 @@ def adduser(username, firstname, lastname, email, pubkey, password):
|
||||||
|
|
||||||
# Get UID
|
# Get UID
|
||||||
output = check_output(['ldapsearch', '-x', 'uidNumber']).decode('utf-8')
|
output = check_output(['ldapsearch', '-x', 'uidNumber']).decode('utf-8')
|
||||||
used = {int(line.split()[1]) for line in output.split('\n') if line.startswith('uid')}
|
uid = max(int(line.split()[1]) for line in output.split('\n') if line.startswith('uid')) + 1
|
||||||
uid = next(u for u in range(1001, 10000) if u not in used)
|
|
||||||
|
|
||||||
if firstname == lastname:
|
if firstname == lastname:
|
||||||
fullname = firstname
|
fullname = firstname
|
||||||
|
|
Loading…
Reference in a new issue