Skip to content
Snippets Groups Projects
Unverified Commit 6e86cf2c authored by Ravi Tripathi's avatar Ravi Tripathi Committed by GitHub
Browse files

Merge pull request #89 from diedpigs/fix-uid-lookup-cmd

Fix uid/gid lookup cmd
parents 6c06a1bf e96f33c1
No related branches found
No related tags found
2 merge requests!147Merge previous default branch feat-cod-rmq into main,!94WIP: Merge feat_prod_rmq with feat_cod_rmq
...@@ -20,7 +20,7 @@ args = rc_util.get_args() ...@@ -20,7 +20,7 @@ args = rc_util.get_args()
# Logger # Logger
logger = rc_util.get_logger() logger = rc_util.get_logger()
#Account creation #Account creation
def create_account(msg): def create_account(msg):
logger.info(f'Account creation request received: {msg}') logger.info(f'Account creation request received: {msg}')
...@@ -56,17 +56,17 @@ def resolve_uid_gid(ch, method, properties, body): ...@@ -56,17 +56,17 @@ def resolve_uid_gid(ch, method, properties, body):
if user_exists: if user_exists:
logger.info("The user, {} already exists".format(username)) 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] msg['gid'] = user_exists.split(':')[3]
else: else:
cmd_uid = "/usr/bin/getent passwd | \ 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() msg['uid'] = popen(cmd_uid).read().rstrip()
logger.info(f"UID query: {cmd_uid}") logger.info(f"UID query: {cmd_uid}")
cmd_gid = "/usr/bin/getent group | \ 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() msg['gid'] = popen(cmd_gid).read().rstrip()
logger.info(f"GID query: {cmd_gid}") logger.info(f"GID query: {cmd_gid}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment