mirror of https://git.48k.eu/ogclient
live: add additional error checks for shell run
Add checks for invalid arguments and permission errors.master
parent
bf15491435
commit
203f3e5533
|
@ -381,6 +381,9 @@ class OgLiveOperations:
|
||||||
cmd = request.getrun()
|
cmd = request.getrun()
|
||||||
is_inline = request.get_inline()
|
is_inline = request.get_inline()
|
||||||
|
|
||||||
|
if not cmd:
|
||||||
|
raise OgError("No command provided for shell run")
|
||||||
|
|
||||||
self._restartBrowser(self._url_log)
|
self._restartBrowser(self._url_log)
|
||||||
|
|
||||||
if is_inline:
|
if is_inline:
|
||||||
|
@ -389,6 +392,9 @@ class OgLiveOperations:
|
||||||
cmds = shlex.split(cmd)
|
cmds = shlex.split(cmd)
|
||||||
shell_path = '/opt/opengnsys/shell/'
|
shell_path = '/opt/opengnsys/shell/'
|
||||||
|
|
||||||
|
if not cmds:
|
||||||
|
raise OgError("Parsed shell command list is empty")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
shell_path_files = os.listdir(shell_path)
|
shell_path_files = os.listdir(shell_path)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
|
@ -404,6 +410,8 @@ class OgLiveOperations:
|
||||||
else:
|
else:
|
||||||
raise OgError(f'Script {cmds[0]} not found in {shell_path}')
|
raise OgError(f'Script {cmds[0]} not found in {shell_path}')
|
||||||
|
|
||||||
|
if not os.path.isfile(cmds[0]) or not os.access(cmds[0], os.X_OK):
|
||||||
|
raise OgError(f"Command '{cmds[0]}' is not a valid executable")
|
||||||
try:
|
try:
|
||||||
ogRest.proc = subprocess.Popen(
|
ogRest.proc = subprocess.Popen(
|
||||||
cmds,
|
cmds,
|
||||||
|
|
Loading…
Reference in New Issue