summaryrefslogtreecommitdiffstats
path: root/src/live
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-12-12 11:20:23 +0100
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-12-12 11:20:23 +0100
commit203f3e55339c878e750829588c5430240d3dd486 (patch)
tree8f466e343964c9f41b5fa515606c6e0bae624630 /src/live
parentbf1549143515d9054b2d66a3a270bc8c2398193c (diff)
live: add additional error checks for shell run
Add checks for invalid arguments and permission errors.
Diffstat (limited to 'src/live')
-rw-r--r--src/live/ogOperations.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py
index a692c01..b1aa731 100644
--- a/src/live/ogOperations.py
+++ b/src/live/ogOperations.py
@@ -381,6 +381,9 @@ class OgLiveOperations:
cmd = request.getrun()
is_inline = request.get_inline()
+ if not cmd:
+ raise OgError("No command provided for shell run")
+
self._restartBrowser(self._url_log)
if is_inline:
@@ -389,6 +392,9 @@ class OgLiveOperations:
cmds = shlex.split(cmd)
shell_path = '/opt/opengnsys/shell/'
+ if not cmds:
+ raise OgError("Parsed shell command list is empty")
+
try:
shell_path_files = os.listdir(shell_path)
except OSError as e:
@@ -404,6 +410,8 @@ class OgLiveOperations:
else:
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:
ogRest.proc = subprocess.Popen(
cmds,