From c1155144ab0cb30d4f3cba2b7a5dcf7ec0e6f1de Mon Sep 17 00:00:00 2001 From: Akashdeep Dhar Date: Mar 05 2021 05:28:16 +0000 Subject: Segregated process listing data from system info Fixed value error in process identity endpoint Signed-off-by: Akashdeep Dhar --- diff --git a/base/frnt.py b/base/frnt.py index 332b836..2a0a54b 100644 --- a/base/frnt.py +++ b/base/frnt.py @@ -60,8 +60,19 @@ class ProcessHandlingEndpoint(object): Method: GET """ passcode = rqst.get_param("passcode") + opername = rqst.get_param("opername") + prociden = rqst.get_param("prociden") if passcode == self.passcode: - retnjson = ProcessHandler(int(rqst.get_param("prociden"))).return_process_info() + try: + prociden = int(prociden) + if opername == "INFO": + retnjson = ProcessHandler(int(prociden)).return_process_info() + elif opername == "LIST": + retnjson = ProcessHandler(0).return_process_listing_info() + else: + retnjson = {"retnmesg": "deny"} + except Exception: + retnjson = {"retnmesg": "deny"} else: retnjson = {"retnmesg": "deny"} resp.body = json.dumps(retnjson, ensure_ascii=False) @@ -80,17 +91,21 @@ class ProcessControllingEndpoint(object): """ passcode = rqst.get_param("passcode") opername = rqst.get_param("opername") - prociden = int(rqst.get_param("prociden")) + prociden = rqst.get_param("prociden") if passcode == self.passcode: - if opername == "KILL": - retnjson = ProcessHandler(prociden).process_killer() - elif opername == "TERM": - retnjson = ProcessHandler(prociden).process_terminator() - elif opername == "HANG": - retnjson = ProcessHandler(prociden).process_suspender() - elif opername == "CONT": - retnjson = ProcessHandler(prociden).process_resumer() - else: + try: + prociden = int(prociden) + if opername == "KILL": + retnjson = ProcessHandler(prociden).process_killer() + elif opername == "TERM": + retnjson = ProcessHandler(prociden).process_terminator() + elif opername == "HANG": + retnjson = ProcessHandler(prociden).process_suspender() + elif opername == "CONT": + retnjson = ProcessHandler(prociden).process_resumer() + else: + retnjson = {"retnmesg": "deny"} + except Exception: retnjson = {"retnmesg": "deny"} else: retnjson = {"retnmesg": "deny"}