From e96f33c1851f34a4c031a0483c39007713f05d03 Mon Sep 17 00:00:00 2001 From: Bo-Chun Louis Chen <louistw@uab.edu> Date: Tue, 20 Apr 2021 23:07:02 -0500 Subject: [PATCH] Update cmd to get next uid/gid Add BEGIN to have a default value starting 10000 --- prod_rmq_agents/get-next-uid-gid.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/prod_rmq_agents/get-next-uid-gid.py b/prod_rmq_agents/get-next-uid-gid.py index 565501b..a59255d 100644 --- a/prod_rmq_agents/get-next-uid-gid.py +++ b/prod_rmq_agents/get-next-uid-gid.py @@ -20,7 +20,7 @@ args = rc_util.get_args() # Logger logger = rc_util.get_logger() -#Account creation +#Account creation def create_account(msg): logger.info(f'Account creation request received: {msg}') @@ -56,17 +56,17 @@ def resolve_uid_gid(ch, method, properties, body): if user_exists: logger.info("The user, {} already exists".format(username)) - msg['uid'] = user_exists.split(':')[2] + msg['uid'] = user_exists.split(':')[2] msg['gid'] = user_exists.split(':')[3] else: cmd_uid = "/usr/bin/getent passwd | \ - awk -F: '($3>10000) && ($3<20000) && ($3>maxuid) { maxuid=$3; } END { print maxuid+1; }'" + awk -F: 'BEGIN { maxuid=10000 } ($3>10000) && ($3<20000) && ($3>maxuid) { maxuid=$3; } END { print maxuid+1; }'" msg['uid'] = popen(cmd_uid).read().rstrip() logger.info(f"UID query: {cmd_uid}") cmd_gid = "/usr/bin/getent group | \ - awk -F: '($3>10000) && ($3<20000) && ($3>maxgid) { maxgid=$3; } END { print maxgid+1; }'" + awk -F: 'BEGIN { maxgid=10000 } ($3>10000) && ($3<20000) && ($3>maxgid) { maxgid=$3; } END { print maxgid+1; }'" msg['gid'] = popen(cmd_gid).read().rstrip() logger.info(f"GID query: {cmd_gid}") -- GitLab