summaryrefslogtreecommitdiffstats
path: root/admin/WebConsole/comandos/gestores/gestor_Comandos.php
diff options
context:
space:
mode:
authorRoberto Hueso Gómez <rhueso@soleta.eu>2019-10-29 12:42:54 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2019-10-29 14:22:20 +0100
commit37f3de613f5331c9c56801a221cf163afff1ff47 (patch)
tree5a3edabb03b8bca00a30c1beebffcf3692972e82 /admin/WebConsole/comandos/gestores/gestor_Comandos.php
parent207a74b03269abaf5729efe8e2a1e58881ef1d70 (diff)
#915 Adapt gestor_Comandos.php to use the REST API
This patch removes the possibility of commands being executed using SocketHidra and replaces it by the calls to the REST API. It also prevents commands from being executed when they are intended to be added to a task or scheduled.
Diffstat (limited to 'admin/WebConsole/comandos/gestores/gestor_Comandos.php')
-rw-r--r--admin/WebConsole/comandos/gestores/gestor_Comandos.php122
1 files changed, 44 insertions, 78 deletions
diff --git a/admin/WebConsole/comandos/gestores/gestor_Comandos.php b/admin/WebConsole/comandos/gestores/gestor_Comandos.php
index 3857a046..91c5d2f1 100644
--- a/admin/WebConsole/comandos/gestores/gestor_Comandos.php
+++ b/admin/WebConsole/comandos/gestores/gestor_Comandos.php
@@ -131,48 +131,6 @@ $cmd->CreaParametro("@restrambito","",0);
$cmd->CreaParametro("@ordprocedimiento",0,1);
$cmd->CreaParametro("@ordtarea",0,1);
-/* PARCHE UHU heredado de la version 1.1.0: Si la accion a realizar es Arrancar incluimos una pagina para arrancar desde el repo */
-switch ($idcomando) {
- case OG_CMD_ID_WAKEUP:
- include("wakeonlan_repo.php");
- break;
- case OG_CMD_ID_SETUP:
- setup($cadenaip, $atributos);
- break;
- case OG_CMD_ID_SESSION:
- session($cadenaip, $atributos);
- break;
- case OG_CMD_ID_CREATE_BASIC_IMAGE:
- create_basic_image($cadenaip, $atributos);
- break;
- case OG_CMD_ID_CREATE_INCREMENTAL_IMAGE:
- create_incremental_image($cadenaip, $atributos);
- break;
- case OG_CMD_ID_RESTORE_BASIC_IMAGE:
- restore_basic_image($cadenaip, $atributos);
- break;
- case OG_CMD_ID_RESTORE_INCREMENTAL_IMAGE:
- restore_incremental_image($cadenaip, $atributos);
- break;
- case OG_CMD_ID_POWEROFF:
- poweroff($cadenaip);
- break;
- case OG_CMD_ID_CREATE_IMAGE:
- create_image($cadenaip, $atributos);
- break;
- case OG_CMD_ID_RESTORE_IMAGE:
- restore_image($cadenaip, $atributos);
- break;
- case OG_CMD_ID_REBOOT:
- reboot($cadenaip);
- break;
- case OG_CMD_ID_HARDWARE:
- hardware($cadenaip);
- break;
- case OG_CMD_ID_SOFTWARE:
- software($cadenaip, $atributos);
-}
-
if($ambito==0){ // Ambito restringido a un subconjuto de ordenadores con formato (idordenador1,idordenador2,etc)
$cmd->ParamSetValor("@restrambito",$idambito);
$idambito=0;
@@ -226,43 +184,51 @@ if($sw_ejya=='on' || $sw_ejprg=="on" ){
else{
$ValorParametros=extrae_parametros($parametros,chr(13),'=');
$script=@urldecode($ValorParametros["scp"]);
- if($sw_ejya=='on'){
- if ($idcomando != OG_CMD_ID_SENDMESSAGE &&
- $idcomando != OG_CMD_ID_WAKEUP &&
- $idcomando != OG_CMD_ID_CREATE_IMAGE &&
- $idcomando != OG_CMD_ID_RESTORE_IMAGE &&
- $idcomando != OG_CMD_ID_SETUP &&
- $idcomando != OG_CMD_ID_SESSION &&
- $idcomando != OG_CMD_ID_CREATE_BASIC_IMAGE &&
- $idcomando != OG_CMD_ID_CREATE_INCREMENTAL_IMAGE &&
- $idcomando != OG_CMD_ID_RESTORE_BASIC_IMAGE &&
- $idcomando != OG_CMD_ID_RESTORE_INCREMENTAL_IMAGE &&
- $idcomando != OG_CMD_ID_POWEROFF &&
- $idcomando != OG_CMD_ID_HARDWARE &&
- $idcomando != OG_CMD_ID_SOFTWARE &&
- $idcomando != OG_CMD_ID_REBOOT) {
- // Envío al servidor
- $shidra=new SockHidra($servidorhidra,$hidraport);
- if ($shidra->conectar()){ // Se ha establecido la conexión con el servidor hidra
- $parametros.=$aplicacion;
- $parametros.=$acciones;
- $resul=$shidra->envia_comando($parametros);
- if($resul)
- $trama=$shidra->recibe_respuesta();
- if($resul){
- $hlonprm=hexdec(substr($trama,$LONCABECERA,$LONHEXPRM));
- $parametros=substr($trama,$LONCABECERA+$LONHEXPRM,$hlonprm);
- $ValorParametros=extrae_parametros($parametros,chr(13),'=');
- $resul=$ValorParametros["res"];
- }
- $shidra->desconectar();
- }
- // Guardamos resultado de ogAgent original
- $resulhidra = $resul;
- } else {
- // En agente nuevo devuelvo siempre correcto
- $resulhidra = 1;
+ if($sw_ejya=='on'){
+ /* PARCHE UHU heredado de la version 1.1.0: Si la accion a realizar es Arrancar incluimos una pagina para arrancar desde el repo */
+ switch ($idcomando) {
+ case OG_CMD_ID_WAKEUP:
+ include("wakeonlan_repo.php");
+ break;
+ case OG_CMD_ID_SETUP:
+ setup($cadenaip, $atributos);
+ break;
+ case OG_CMD_ID_SESSION:
+ session($cadenaip, $atributos);
+ break;
+ case OG_CMD_ID_CREATE_BASIC_IMAGE:
+ create_basic_image($cadenaip, $atributos);
+ break;
+ case OG_CMD_ID_CREATE_INCREMENTAL_IMAGE:
+ create_incremental_image($cadenaip, $atributos);
+ break;
+ case OG_CMD_ID_RESTORE_BASIC_IMAGE:
+ restore_basic_image($cadenaip, $atributos);
+ break;
+ case OG_CMD_ID_RESTORE_INCREMENTAL_IMAGE:
+ restore_incremental_image($cadenaip, $atributos);
+ break;
+ case OG_CMD_ID_POWEROFF:
+ poweroff($cadenaip);
+ break;
+ case OG_CMD_ID_CREATE_IMAGE:
+ create_image($cadenaip, $atributos);
+ break;
+ case OG_CMD_ID_RESTORE_IMAGE:
+ restore_image($cadenaip, $atributos);
+ break;
+ case OG_CMD_ID_REBOOT:
+ reboot($cadenaip);
+ break;
+ case OG_CMD_ID_HARDWARE:
+ hardware($cadenaip);
+ break;
+ case OG_CMD_ID_SOFTWARE:
+ software($cadenaip, $atributos);
+ break;
}
+ // En agente nuevo devuelvo siempre correcto
+ $resulhidra = 1;
// Comprobamos si el comando es soportado por el nuevo OGAgent
$numip=0;