Skip to content
Snippets Groups Projects
Commit eb53c160 authored by Eesaan Atluri's avatar Eesaan Atluri
Browse files

Add uid, gid to the msg obj if user exists else get next uid,gid.

parent 666bd9e9
No related branches found
No related tags found
6 merge requests!147Merge previous default branch feat-cod-rmq into main,!85kill nginx process running under user from login node,!51Fix acct create wait,!39WIP:Feat cod rmq,!38WIP: Feat cod rmq,!28Feat resolve uid gid
...@@ -42,25 +42,21 @@ def get_next_uid_gid(ch, method, properties, body): ...@@ -42,25 +42,21 @@ def get_next_uid_gid(ch, method, properties, body):
# Determine next available UID # Determine next available UID
try: try:
#if user_exists(username): if user_exists(username):
if False:
logger.info("The user, {} already exists".format(username)) logger.info("The user, {} already exists".format(username))
sys.exit(1) msg['uid'] = result[0][1]['uidNumber'][0].decode('utf-8')
msg['gid'] = result[0][1]['gidNumber'][0].decode('utf-8')
cmd_uid = "/usr/bin/getent passwd | \ else:
awk -F: '($3>10000) && ($3<20000) && ($3>maxuid) { maxuid=$3; } END { print maxuid+1; }'" cmd_uid = "/usr/bin/getent passwd | \
if not args.dry_run: awk -F: '($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 | \
awk -F: '($3>10000) && ($3<20000) && ($3>maxgid) { maxgid=$3; } END { print maxgid+1; }'"
cmd_gid = "/usr/bin/getent group | \
awk -F: '($3>10000) && ($3<20000) && ($3>maxgid) { maxgid=$3; } END { print maxgid+1; }'"
if not args.dry_run:
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}")
success = True
except Exception: except Exception:
logger.exception("Fatal error:") logger.exception("Fatal error:")
......
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