From d14bc3177179b0573b56db4b64550f3287cd9ff3 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Mon, 14 Aug 2017 10:37:05 +0200 Subject: [PATCH] [mod] directly call python instead of using os.system --- src/yunohost/user.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/yunohost/user.py b/src/yunohost/user.py index bc65146c9..ee0655291 100644 --- a/src/yunohost/user.py +++ b/src/yunohost/user.py @@ -129,11 +129,13 @@ def user_create(auth, username, firstname, lastname, mail, password, domain=mail.split("@")[1])) # Get random UID/GID - uid_check = gid_check = 0 - while uid_check == 0 and gid_check == 0: + all_uid = {x.pw_uid for x in pwd.getpwall()} + all_gid = {x.pw_gid for x in pwd.getpwall()} + + uid_guid_found = False + while not uid_guid_found: uid = str(random.randint(200, 99999)) - uid_check = os.system("getent passwd %s" % uid) - gid_check = os.system("getent group %s" % uid) + uid_guid_found = uid not in all_uid and uid not in all_gid # Adapt values for LDAP fullname = '%s %s' % (firstname, lastname)