#962: Only OGAgent for Windows runs each line in independent processes (other agents can run the whole script in a single subprocess).

oglive
Ramón M. Gómez 2020-04-23 12:53:27 +02:00
parent f6d5f3007d
commit dab4e358d4
1 changed files with 8 additions and 5 deletions

View File

@ -82,8 +82,8 @@ class OpenGnSysWorker(ServerWorker):
REST = None # REST object REST = None # REST object
logged_in = False # User session flag logged_in = False # User session flag
locked = {} locked = {}
random = None # Random string for secure connections random = None # Random string for secure connections
length = 32 # Random string length length = 32 # Random string length
def onActivation(self): def onActivation(self):
""" """
@ -280,10 +280,13 @@ class OpenGnSysWorker(ServerWorker):
:return: JSON object {"op": "launched"} :return: JSON object {"op": "launched"}
""" """
logger.debug('Processing script request') logger.debug('Processing script request')
# Decoding script # Decoding script (Windows scripts need a subprocess call per line)
script = urllib.unquote(post_params.get('script').decode('base64')).decode('utf8') script = urllib.unquote(post_params.get('script').decode('base64')).decode('utf8')
script = 'import subprocess;{0}'.format( if operations.os_type == 'Windoes':
';'.join(['subprocess.check_output({0},shell=True)'.format(repr(c)) for c in script.split('\n')])) script = 'import subprocess; {0}'.format(
';'.join(['subprocess.check_output({0},shell=True)'.format(repr(c)) for c in script.split('\n')]))
else:
script = 'import subprocess; subprocess.check_output("""{0}""",shell=True)'.format(script)
# Executing script. # Executing script.
if post_params.get('client', 'false') == 'false': if post_params.get('client', 'false') == 'false':
thr = ScriptExecutorThread(script) thr = ScriptExecutorThread(script)