diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2020-02-25 13:39:42 +0100 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2020-05-19 18:15:30 +0200 |
commit | 43f789465526f288613d9325cf2be4078903267f (patch) | |
tree | b78a356477b3d675ba8b5ae57f955b8cfc8dad71 | |
parent | 340bd127556cb6d23d44fc6f6043c33b01046ed1 (diff) |
#915 Add new case to command shell/run (web)
I tried to delete a cache image but the character "*" of the command
was missing so the command fails.
Command received:
"rm -r /opt/opengnsys/cache/opt/opengnsys/images/test."
Command expected:
"rm -r /opt/opengnsys/cache/opt/opengnsys/images/test.*"
This command adds a new case to the call shell/run. This new case is
needed because in the case of deleting a image from the cache the web
only has to delete the last character of the string instead of last two
characters.
-rw-r--r-- | admin/WebConsole/comandos/gestores/gestor_Comandos.php | 4 | ||||
-rw-r--r-- | admin/WebConsole/includes/restfunctions.php | 22 |
2 files changed, 18 insertions, 8 deletions
diff --git a/admin/WebConsole/comandos/gestores/gestor_Comandos.php b/admin/WebConsole/comandos/gestores/gestor_Comandos.php index d825c2d3..4d52ba1f 100644 --- a/admin/WebConsole/comandos/gestores/gestor_Comandos.php +++ b/admin/WebConsole/comandos/gestores/gestor_Comandos.php @@ -79,9 +79,11 @@ function run_command($idcomando, $cadenaip, $cadenamac, $atributos) { software($cadenaip, $atributos); break; case OG_CMD_ID_SCRIPT: - case OG_CMD_ID_DELETE_CACHED_IMAGE: shell(3, $cadenaip, $atributos); break; + case OG_CMD_ID_DELETE_CACHED_IMAGE: + shell(4, $cadenaip, $atributos); + break; } } diff --git a/admin/WebConsole/includes/restfunctions.php b/admin/WebConsole/includes/restfunctions.php index 274ca708..adf09b2e 100644 --- a/admin/WebConsole/includes/restfunctions.php +++ b/admin/WebConsole/includes/restfunctions.php @@ -116,6 +116,17 @@ function shell($case, $string_ips, $command) { $ips = explode(';',$string_ips); switch ($case) { + case 1: + $data = array(OG_REST_PARAM_CLIENTS => $ips, + OG_REST_PARAM_RUN => $command, + OG_REST_PARAM_ECHO => true); + $command = OG_REST_CMD_RUN; + break; + default: + case 2: + $data = array(OG_REST_PARAM_CLIENTS => $ips); + $command = OG_REST_CMD_OUTPUT; + break; case 3: $decoded_cmds = rawurldecode(substr($command, 4)); $command = substr($decoded_cmds, 0, -2); @@ -124,16 +135,13 @@ function shell($case, $string_ips, $command) { OG_REST_PARAM_ECHO => false); $command = OG_REST_CMD_RUN; break; - case 1: + case 4: + $decoded_cmds = rawurldecode(substr($command, 4)); + $command = substr($decoded_cmds, 0, -1); $data = array(OG_REST_PARAM_CLIENTS => $ips, OG_REST_PARAM_RUN => $command, - OG_REST_PARAM_ECHO => true); + OG_REST_PARAM_ECHO => false); $command = OG_REST_CMD_RUN; - break; - default: - case 2: - $data = array(OG_REST_PARAM_CLIENTS => $ips); - $command = OG_REST_CMD_OUTPUT; } $result = common_request($command, POST, |