15 lines
456 B
Python
15 lines
456 B
Python
import json
|
|
import subprocess
|
|
|
|
|
|
def func_run_bash(command_data: str):
|
|
j = json.loads(command_data)
|
|
command = j.get('command')
|
|
|
|
# TODO: config option to block all commands with "sudo" in them.
|
|
|
|
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
|
stdout, stderr = process.communicate()
|
|
return_code = process.returncode
|
|
return stdout.decode('utf-8'), stderr.decode('utf-8'), return_code
|