#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
logged_in = False # User session flag
locked = {}
random = None # Random string for secure connections
length = 32 # Random string length
random = None # Random string for secure connections
length = 32 # Random string length
def onActivation(self):
"""
@ -280,10 +280,13 @@ class OpenGnSysWorker(ServerWorker):
:return: JSON object {"op": "launched"}
"""
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 = 'import subprocess;{0}'.format(
';'.join(['subprocess.check_output({0},shell=True)'.format(repr(c)) for c in script.split('\n')]))
if operations.os_type == 'Windoes':
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.
if post_params.get('client', 'false') == 'false':
thr = ScriptExecutorThread(script)