From 25cfb317253a1bf08df46cac79a58ba7e782470f Mon Sep 17 00:00:00 2001 From: Natalia Serrano Date: Wed, 21 Aug 2024 14:44:30 +0200 Subject: [PATCH] refs #527 remove unused code --- src/opengnsys/linux/OGAgentService.py | 0 .../server/ogAdmClient/__init__.py | 46 +++---------------- 2 files changed, 7 insertions(+), 39 deletions(-) mode change 100644 => 100755 src/opengnsys/linux/OGAgentService.py diff --git a/src/opengnsys/linux/OGAgentService.py b/src/opengnsys/linux/OGAgentService.py old mode 100644 new mode 100755 diff --git a/src/test_modules/server/ogAdmClient/__init__.py b/src/test_modules/server/ogAdmClient/__init__.py index 0e7673c..ad31007 100644 --- a/src/test_modules/server/ogAdmClient/__init__.py +++ b/src/test_modules/server/ogAdmClient/__init__.py @@ -48,7 +48,6 @@ import urllib.request from configparser import NoOptionError from opengnsys import REST, operations, VERSION from opengnsys.log import logger -from opengnsys.scriptThread import ScriptExecutorThread from opengnsys.workers import ServerWorker # Check authorization header decorator @@ -173,44 +172,6 @@ class ogAdmClientWorker(ServerWorker): threading.Thread(target=pwoff).start() return {'op': 'launched'} - @check_secret - def process_script(self, path, get_params, post_params, server): - """ - Processes an script execution (script should be encoded in base64) - :param path: - :param get_params: - :param post_params: JSON object {"script": "commands"} - :param server: authorization header - :return: JSON object {"op": "launched"} - """ - logger.debug('Processing script request') - # Decoding script - script = urllib.parse.unquote(base64.b64decode(post_params.get('script')).decode('utf-8')) - logger.debug('received script {}'.format(script)) - if operations.os_type == 'Windows': - ## for windows, we turn the script into utf16le, then to b64 again, and feed the blob to powershell - u16 = script.encode ('utf-16le') ## utf16 - b64 = base64.b64encode (u16).decode ('utf-8') ## b64 (which returns bytes, so we need an additional decode(utf8)) - script = """ -import os -import tempfile -import subprocess -cp = subprocess.run ("powershell -WindowStyle Hidden -EncodedCommand {}", capture_output=True) -subprocs_log = os.path.join (tempfile.gettempdir(), 'opengnsys-subprocs.log') -with open (subprocs_log, 'ab') as fd: ## TODO improve this logging - fd.write (cp.stdout) - fd.write (cp.stderr) -""".format (b64) - else: - script = 'import subprocess; subprocess.check_output("""{0}""",shell=True)'.format(script) - # Executing script. - if post_params.get('client', 'false') == 'false': - thr = ScriptExecutorThread(script) - thr.start() - else: - self.sendClientMessage('script', {'code': script}) - return {'op': 'launched'} - @check_secret def process_logoff(self, path, get_params, post_params, server): logger.warn('in process_logoff, should not happen') @@ -223,6 +184,13 @@ with open (subprocs_log, 'ab') as fd: ## TODO improve this logging ## type(post_params) "" return {'debug':'test'} + + + + + + + #def process_client_popup(self, params): # logger.warn('in process_client_popup')