From 950a09c2056c213d213689f81110c61886e982f7 Mon Sep 17 00:00:00 2001 From: Eric Menezes Noronha Date: Fri, 19 Sep 2014 18:41:18 -0300 Subject: [PATCH] Chamada do mapa independe do agente agora. O gerente manda apenas um 'true' ou 'false' para a exeucação do mesmo, juntamente com a mensagem contendo os termos. Modificadação do método de comunicação para que caso dê problema conectar ao get/update. --- CACIC_Comm.pas | 27 ++++++++++++++++++++++----- Mapa/Mapa.pas | 5 +++-- Mapa/mapacacic.dproj | 2 +- Mapa/mapacacic.res | Bin 4192 -> 0 bytes cacic280.dproj | 2 +- cacic280.res | Bin 4876 -> 0 bytes cacicservice/cacicservice.dproj | 2 +- cacicservice/cacicservice.res | Bin 5296 -> 0 bytes chksis/chksis.dpr | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- chksis/chksis.dproj | 2 +- chksis/chksis.res | Bin 5088 -> 0 bytes gercols/gercols.dproj | 2 +- gercols/gercols.res | Bin 4760 -> 0 bytes installcacic/installcacic.dproj | 2 +- installcacic/installcacic.res | Bin 3308 -> 0 bytes installcacic/uInstallCACIC.pas | 2 ++ main.pas | 36 ++++++++++++++++++------------------ 17 files changed, 126 insertions(+), 32 deletions(-) diff --git a/CACIC_Comm.pas b/CACIC_Comm.pas index 75aa600..f2c8b5b 100644 --- a/CACIC_Comm.pas +++ b/CACIC_Comm.pas @@ -37,7 +37,8 @@ var tStringStrResponseCS : TStringStream; strWin32_SoftwareFeature, strTeDebugging, strMac, - strSubnet : String; + strSubnet, + route : String; Begin Try tStringStrResponseCS := TStringStream.Create(''); @@ -112,7 +113,7 @@ Begin Try idHTTP1.AllowCookies := true; idHTTP1.AuthRetries := 1; - idHTTP1.HandleRedirects := false; + idHTTP1.HandleRedirects := true; idHTTP1.ProxyParams.BasicAuthentication := false; idHTTP1.ProxyParams.ProxyPort := 0; idHTTP1.ReadTimeout := 0; @@ -131,9 +132,25 @@ Begin IdHTTP1.Post(pStrFullURL, tstrRequest, tStringStrResponseCS); Except on E : Exception do - Begin - objCacicCOMM.writeExceptionLog(E.Message,E.ClassName,'ERRO! Comunicação impossível com o endereço ' + pStrFullURL); - End; + Begin + objCacicCOMM.writeExceptionLog(E.Message,E.ClassName,'ERRO![1] Comunicação impossível com o endereço ' + pStrFullURL); + if not (pos('get/update',pStrFullUrl) > 0) then + begin + route:= ''; + if (pos('get/test', pStrFullUrl) > 0) then + route:= 'get/test' + else if (pos('get/config', pStrFullUrl) > 0) then + route:= 'get/config'; + if (route <> '') then + begin + delete(pStrFullUrl, pos(route, pStrFullUrl), length(pStrFullUrl)); + pStrFullUrl := pStrFullUrl + 'get/update'; + objCacicCOMM.writeExceptionLog(E.Message,E.ClassName,'Realizando nova tentativa em ' + pStrFullURL); + objCacicCOMM.writeDailyLog('Realizando nova tentativa em rota alternativa'); + IdHTTP1.Post(pStrFullUrl, tstrRequest, tStringStrResponseCS); + end; + end; + End; End; objCacicCOMM.writeDebugLog('Comm: Retorno -> ' + tStringStrResponseCS.DataString); idHTTP1.Disconnect; diff --git a/Mapa/Mapa.pas b/Mapa/Mapa.pas index 46d4e43..09130d7 100644 --- a/Mapa/Mapa.pas +++ b/Mapa/Mapa.pas @@ -170,7 +170,7 @@ Begin if FileExists(objCACIC.getLocalFolderName + '\temp\aguarde_MAPACACIC.txt') then objCACIC.deleteFileOrFolder(objCacic.getLocalFolderName + '\temp\aguarde_MAPACACIC.txt'); - + objCacic.setValueToFile('Configs', 'Patrimonio', 'false', strGercolsInfFileName); Application.ProcessMessages; Sair; @@ -517,6 +517,7 @@ Begin lbEtiqueta5.Visible := true; lbEtiqueta5.ShowHint := true; lbEtiqueta5.hint := 'Digite seu nome, não foi possível recuperá-lo.'; + objCacic.writeDailyLog('Não foi possível pegar nome do ldap'); end; // objCacic.writeDebugLog('MontaInterface: in_exibir_etiqueta6 -> "' + @@ -943,7 +944,7 @@ begin ldap.Timeout := 5000; if ldap.Login and ldap.Bind then //Loga no LDAP e autentica no LDAP com Usuário e senha repassado. (BindSasl é mais seguro que Bind) begin - ldap.Search(base, False, identificador+ '=' + strTeInfoPatrimonio2, retorno); //Faz a pesquisa, com o CPF repassado. + ldap.Search(base, False, identificador+ '=' + strTeInfoPatrimonio4, retorno); //Faz a pesquisa, com o CPF repassado. result := LDAPResultdump(ldap.SearchResult); objCACIC.writeDailyLog('Nome Usuário: Conexão estabelecida, pesquisa realizada.'); ldap.Logout; diff --git a/Mapa/mapacacic.dproj b/Mapa/mapacacic.dproj index feb480f..a4e0f09 100644 --- a/Mapa/mapacacic.dproj +++ b/Mapa/mapacacic.dproj @@ -24,7 +24,7 @@ Delphi.Personality -FalseTrueFalseTrueFalse28118TrueFalseFalseFalseFalse10461252Dataprev - Emp. de TI da Prev Social - URES/SESSSistema CACIC - Módulo para Verificação e Instalação de Estrutura Básica do Sistema CACIC2.8.1.183.0Licença: GNU/LGPLmapacacic.dprFalse +FalseTrueFalseTrueFalse28120TrueFalseFalseFalseFalse10461252Dataprev - Emp. de TI da Prev Social - URES/SESSSistema CACIC - Módulo para Verificação e Instalação de Estrutura Básica do Sistema CACIC2.8.1.203.0Licença: GNU/LGPLmapacacic.dprFalse diff --git a/Mapa/mapacacic.res b/Mapa/mapacacic.res index d23981e..30b5fec 100644 Binary files a/Mapa/mapacacic.res and b/Mapa/mapacacic.res differ diff --git a/cacic280.dproj b/cacic280.dproj index 90078b0..8dab660 100644 --- a/cacic280.dproj +++ b/cacic280.dproj @@ -40,7 +40,7 @@ Delphi.Personality VCLApplication -FalseTrueFalseTrueFalse28118FalseFalseFalseFalseFalse10461252Dataprev - Emp. de TI da Prev.Social - URES/SESSSistema CACIC - Módulo Agente Principal2.8.1.18Baseado na licença GNU/LGPLCacic - Configurador Automático e Coletor de Informações Computacionais3.0cacic280.dpr +FalseTrueFalseTrueFalse28120FalseFalseFalseFalseFalse10461252Dataprev - Emp. de TI da Prev.Social - URES/SESSSistema CACIC - Módulo Agente Principal2.8.1.20Baseado na licença GNU/LGPLCacic - Configurador Automático e Coletor de Informações Computacionais3.0cacic280.dpr diff --git a/cacic280.res b/cacic280.res index f5ee511..4f40518 100644 Binary files a/cacic280.res and b/cacic280.res differ diff --git a/cacicservice/cacicservice.dproj b/cacicservice/cacicservice.dproj index 845ee54..5d7df82 100644 --- a/cacicservice/cacicservice.dproj +++ b/cacicservice/cacicservice.dproj @@ -37,7 +37,7 @@ Delphi.Personality VCLApplication -FalseTrueFalseE:\NTService\TrueFalse28118FalseFalseFalseFalseFalse10461252Dataprev - Emp. de TI da Prev Social - URES/SESSSistema CACIC - Módulo para Sustentação do Agente Principal2.8.1.183.0Licença: GNU/LGPLcacicservice.dpr +FalseTrueFalseE:\NTService\TrueFalse28120FalseFalseFalseFalseFalse10461252Dataprev - Emp. de TI da Prev Social - URES/SESSSistema CACIC - Módulo para Sustentação do Agente Principal2.8.1.203.0Licença: GNU/LGPLcacicservice.dpr diff --git a/cacicservice/cacicservice.res b/cacicservice/cacicservice.res index 5826772..fa7ba97 100755 Binary files a/cacicservice/cacicservice.res and b/cacicservice/cacicservice.res differ diff --git a/chksis/chksis.dpr b/chksis/chksis.dpr index ad2048b..a9141df 100755 --- a/chksis/chksis.dpr +++ b/chksis/chksis.dpr @@ -185,7 +185,81 @@ begin // 5 segundos para espera de possível FTP em andamento... Sleep(5000); - End; + End + else + begin + strCommResponse := Comm(objCacic.getWebManagerAddress + objCacic.getWebServicesFolderName + 'get/update', strFieldsAndValuesToRequest, objCacic.getLocalFolderName); + if (strCommResponse <> '0') then + begin + objCacic.writeDailyLog('executeChkSIS: Iniciando segunda tentativa de comunicação sem a obrigatoriedade do MAC'); + objCacic.setBoolCipher(not objCacic.isInDebugMode); + objCacic.setMainProgramName( objCacic.deCrypt(objCacic.getValueFromTags('MainProgramName' , strCommResponse, '<>'))); + objCacic.setMainProgramHash( objCacic.deCrypt(objCacic.getValueFromTags(objCacic.getMainProgramName + '_HASH' , strCommResponse, '<>'),true,true)); + objCacic.setWebManagerAddress( objCacic.deCrypt(objCacic.getValueFromTags('WebManagerAddress' , strCommResponse, '<>'))); + objCacic.setWebServicesFolderName(objCacic.deCrypt(objCacic.getValueFromTags('WebServicesFolderName' , strCommResponse, '<>'))); + objCacic.setLocalFolderName( objCacic.deCrypt(objCacic.getValueFromTags('LocalFolderName' , strCommResponse, '<>'))); + + objCacic.writeDebugLog('executeChkSIS: Resposta: ' + strCommResponse); + + objCacic.setValueToFile('Configs' ,'NmUsuarioLoginServUpdates', objCacic.getValueFromTags('nm_usuario_login_serv_updates' , strCommResponse, '<>'), strChkSisInfFileName); + objCacic.setValueToFile('Configs' ,'NuPortaServUpdates' , objCacic.getValueFromTags('nu_porta_serv_updates' , strCommResponse, '<>'), strChkSisInfFileName); + objCacic.setValueToFile('Configs' ,'TePathServUpdates' , objCacic.getValueFromTags('te_path_serv_updates' , strCommResponse, '<>'), strChkSisInfFileName); + objCacic.setValueToFile('Configs' ,'TeSenhaLoginServUpdates' , objCacic.getValueFromTags('te_senha_login_serv_updates' , strCommResponse, '<>'), strChkSisInfFileName); + objCacic.setValueToFile('Configs' ,'TeServUpdates' , objCacic.getValueFromTags('te_serv_updates' , strCommResponse, '<>'), strChkSisInfFileName); + objCacic.setValueToFile('Configs' ,'WebManagerAddress' , objCacic.getValueFromTags('WebManagerAddress' , strCommResponse, '<>'), strChkSisInfFileName); + objCacic.setValueToFile('Configs' ,'WebServicesFolderName' , objCacic.getValueFromTags('WebServicesFolderName' , strCommResponse, '<>'), strChkSisInfFileName); + objCacic.setValueToFile('Hash-Codes','CACICSERVICE.EXE' , objCacic.getValueFromTags('CACICSERVICE.EXE_HASH' , strCommResponse, '<>'), strChkSisInfFileName); + objCacic.setValueToFile('Hash-Codes','CHKSIS.EXE' , objCacic.getValueFromTags('CHKSIS.EXE_HASH' , strCommResponse, '<>'), strChkSisInfFileName); + objCacic.setValueToFile('Hash-Codes','GERCOLS.EXE' , objCacic.getValueFromTags('GERCOLS.EXE_HASH' , strCommResponse, '<>'), strChkSisInfFileName); + objCacic.setValueToFile('Hash-Codes','MAPACACIC.EXE' , objCacic.getValueFromTags('MAPACACIC.EXE_HASH' , strCommResponse, '<>'), strChkSisInfFileName); + objCacic.setValueToFile('Hash-Codes',objCacic.getMainProgramName, objCacic.getValueFromTags(objCacic.getMainProgramName + '_HASH', strCommResponse, '<>'), strChkSisInfFileName); + objCacic.deleteFileOrFolder(objCacic.getLocalFolderName + 'aguarde_CACIC.txt'); + + // Auto verificação de versão + verifyAndGetModules('chksis.exe', + objCacic.deCrypt(objCacic.getValueFromTags('CHKSIS.EXE_HASH', strCommResponse, '<>'),true,true), + objCacic.getWinDir, + objCacic.getLocalFolderName, + objCacic, + strChkSisInfFileName); + + // Verificação de versão do Agente Principal + verifyAndGetModules(LowerCase(objCacic.getMainProgramName), + objCacic.getMainProgramHash, + objCacic.getLocalFolderName, + objCacic.getLocalFolderName, + objCacic, + strChkSisInfFileName); + + // Verificação de versão do Agente Gerente de Coletas + verifyAndGetModules('gercols.exe', + objCacic.deCrypt(objCacic.getValueFromTags('GERCOLS.EXE_HASH', strCommResponse, '<>'),true,true), + objCacic.getLocalFolderName + 'Modules', + objCacic.getLocalFolderName, + objCacic, + strChkSisInfFileName); + + // Verificação de versão do Serviço de Sustentação do Agente CACIC + verifyAndGetModules('cacicservice.exe', + objCacic.deCrypt(objCacic.getValueFromTags('CACICSERVICE.EXE_HASH', strCommResponse, '<>'),true,true), + objCacic.getWinDir, + objCacic.getLocalFolderName, + objCacic, + strChkSisInfFileName); + + // Verificação de versão do Mapa Cacic + verifyAndGetModules('mapacacic.exe', + objCacic.deCrypt(objCacic.getValueFromTags('MAPACACIC.EXE_HASH', strCommResponse, '<>'),true,true), + objCacic.getLocalFolderName + 'Modules', + objCacic.getLocalFolderName, + objCacic, + strChkSisInfFileName); + + // 5 segundos para espera de possível FTP em andamento... + Sleep(5000); + end; + end; + Except on E : Exception do Begin diff --git a/chksis/chksis.dproj b/chksis/chksis.dproj index f0ad4ec..fbae22b 100755 --- a/chksis/chksis.dproj +++ b/chksis/chksis.dproj @@ -29,7 +29,7 @@ Delphi.Personality VCLApplication -C:\Arquivos de programas\Borland\Delphi7\Mitec\D7FalseTrueFalseC:\Arquivos de programas\Borland\Delphi7\Bin\TrueFalse28118FalseFalseFalseFalseFalse10461252Dataprev - Emp. de TI da Prev.Social - URES/SESSSistema CACIC - Módulo Verificador de Integridade2.8.1.18ChkSIS3.0Licença: GNU/LGPLchksis.dpr +C:\Arquivos de programas\Borland\Delphi7\Mitec\D7FalseTrueFalseC:\Arquivos de programas\Borland\Delphi7\Bin\TrueFalse28120FalseFalseFalseFalseFalse10461252Dataprev - Emp. de TI da Prev.Social - URES/SESSSistema CACIC - Módulo Verificador de Integridade2.8.1.20ChkSIS3.0Licença: GNU/LGPLchksis.dpr diff --git a/chksis/chksis.res b/chksis/chksis.res index ed267d5..2d1eecd 100755 Binary files a/chksis/chksis.res and b/chksis/chksis.res differ diff --git a/gercols/gercols.dproj b/gercols/gercols.dproj index c9ca255..5229753 100644 --- a/gercols/gercols.dproj +++ b/gercols/gercols.dproj @@ -38,7 +38,7 @@ Delphi.Personality VCLApplication -C:\vendors_lib\JVCL345CompleteJCL231-Build4197\jcl\lib\d7\debugFalseTrueFalseTrueFalse28118FalseFalseFalseFalseFalse10461252Dataprev-Emp. de TI da Prev Social - URES/SESSSistema CACIC - Módulo Gerente de Coletas2.8.1.18Ger_COLS3.0Licença: GNU/LGPLgercols.dpr +C:\vendors_lib\JVCL345CompleteJCL231-Build4197\jcl\lib\d7\debugFalseTrueFalseTrueFalse28120FalseFalseFalseFalseFalse10461252Dataprev-Emp. de TI da Prev Social - URES/SESSSistema CACIC - Módulo Gerente de Coletas2.8.1.20Ger_COLS3.0Licença: GNU/LGPLgercols.dpr diff --git a/gercols/gercols.res b/gercols/gercols.res index d6d25a9..bede610 100644 Binary files a/gercols/gercols.res and b/gercols/gercols.res differ diff --git a/installcacic/installcacic.dproj b/installcacic/installcacic.dproj index 84d23a8..867f2c4 100644 --- a/installcacic/installcacic.dproj +++ b/installcacic/installcacic.dproj @@ -32,7 +32,7 @@ Delphi.Personality VCLApplication -FalseTrueFalseTrueFalse28118FalseFalseFalseFalseFalse10461252Dataprev - Emp. de TI da Prev Social - URES/SESSSistema CACIC - Módulo para Verificação e Instalação de Estrutura Básica do Sistema CACIC2.8.1.183.0Licença: GNU/LGPLinstallcacic.dpr +FalseTrueFalseTrueFalse28120FalseFalseFalseFalseFalse10461252Dataprev - Emp. de TI da Prev Social - URES/SESSSistema CACIC - Módulo para Verificação e Instalação de Estrutura Básica do Sistema CACIC2.8.1.203.0Licença: GNU/LGPLinstallcacic.dpr diff --git a/installcacic/installcacic.res b/installcacic/installcacic.res index e0aa8f5..e671da6 100644 Binary files a/installcacic/installcacic.res and b/installcacic/installcacic.res differ diff --git a/installcacic/uInstallCACIC.pas b/installcacic/uInstallCACIC.pas index 82f449b..54fde88 100644 --- a/installcacic/uInstallCACIC.pas +++ b/installcacic/uInstallCACIC.pas @@ -487,7 +487,9 @@ begin objCacic.writeDebugLog('installCACIC: Preparando Chamada ao Gerente WEB: "' + objCacic.getWebManagerAddress + objCacic.getWebServicesFolderName +'get/config'); informaProgresso('Fazendo contato com Gerente WEB.'); informaProgresso('Endereço do gerente: ' + objCacic.getWebManagerAddress); + strCommResponse := Comm(objCacic.getWebManagerAddress + objCacic.getWebServicesFolderName + 'get/config', strFieldsAndValuesToRequest, objCACIC.getLocalFolderName); + if (strCommResponse <> '0') then Begin { Já realizados na chamada ao get_test.php substituido por get/test diff --git a/main.pas b/main.pas index 87d0f3a..7af33fc 100755 --- a/main.pas +++ b/main.pas @@ -1126,6 +1126,16 @@ begin ExecutaCACIC(nil); end; Invoca_GerCols('getMapa'); + //////////////////////////////////////////////////////////////////////////////// + // CRIADO PARA TESTAR A CHAMADA DO MAPA CACIC // + //////////////////////////////////////////////////////////////////////////////// + if (not FileExists(objCacic.getLocalFolderName + 'Temp\aguarde_MAPACACIC.txt')) + and (objCACIC.getValueFromFile('Configs', 'Patrimonio', strGerColsInfFileName) = 'true') then + begin + objCACIC.writeDebugLog('ExecutaCACIC: Executa chamada ao Mapa Cacic...'); + Invoca_MapaCacic; + sleep(10000); + end; // Os timers iniciam-se desabilitados... Mais � frente receber�o par�metros de tempo para execu��o. timerNuExecApos.Enabled := False; timerNuIntervalo.Enabled := False; @@ -1322,7 +1332,7 @@ end; procedure TFormularioGeral.InvocaMapa1Click(Sender: TObject); begin FormularioGeral.Invoca_GerCols('getMapa'); - if (ActualActivity=0) and (objCACIC.getValueFromFile('Configs', 'modulo_patr', strGerColsInfFileName) = 'S') then + if (ActualActivity=0) and (objCACIC.getValueFromFile('Configs', 'Patrimonio', strGerColsInfFileName) = 'true') then Invoca_MapaCacic else if(ActualActivity <> 0) then begin @@ -1334,7 +1344,7 @@ begin MessageDlg(#13#13+'Mapa já está em execução!',mtInformation, [mbOK], 0); end else - MessageDlg(#13#13+'M�dulo desabilitado!',mtInformation, [mbOK], 0); + MessageDlg(#13#13+'Módulo desabilitado ou já coletado!',mtInformation, [mbOK], 0); end; //////////////////////////////////////////////////////////////////////////////// @@ -1353,7 +1363,9 @@ begin objCacic.writeDailyLog('Invoca_MapaCacic: Criando processo mapa.'); objCACIC.writeDebugLog('Invoca_MapaCacic: Criando Processo Mapa => "'+objCACIC.getLocalFolderName + 'Modules\MapaCACIC.exe'); if (objCACIC.createOneProcess(objCACIC.getLocalFolderName + 'Modules\mapacacic.exe',false,SW_SHOW)) then - objCacic.writeDailyLog('Invoca_MapaCacic: Processo criado.') + Begin + objCacic.writeDailyLog('Invoca_MapaCacic: Processo criado.'); + End else objCacic.writeDailyLog('Invoca_MapaCacic: Falha ao criar processo.'); End @@ -1395,7 +1407,6 @@ var v_mensagem, intTentativas : integer; begin try - if FindCmdLineSwitch('execute', True) or FindCmdLineSwitch('atualizacao', True) or Pode_Coletar or @@ -1433,17 +1444,6 @@ begin Application.ProcessMessages; InicializaTray; - //////////////////////////////////////////////////////////////////////////////// - // CRIADO PARA TESTAR A CHAMADA DO MAPA CACIC // - //////////////////////////////////////////////////////////////////////////////// - if not FindCmdLineSwitch('atualizacao', True) - and not (FileExists(objCacic.getLocalFolderName + 'Temp\aguarde_MAPACACIC.txt')) - and (objCACIC.getValueFromFile('Configs', 'Patrimonio', strGerColsInfFileName) = 'true') then - begin - objCACIC.writeDebugLog('ExecutaCACIC: Executa chamada ao Mapa Cacic...'); - Invoca_MapaCacic; - end; - // Pausas de 15 segundos para o caso de ser(em) baixada(s) nova(s) vers�o(�es) de GerCols e/ou Cacic280. // Ser�o 4 tentativas por minuto // Ser�o 30 minutos no m�ximo de tentativas, totalizando 120 @@ -1622,7 +1622,7 @@ begin if g_intStatus = EM_SUPORTE then v_strHint := v_strHint + chr(13) + chr(10) + ' Em Suporte Remoto...' else if g_intStatus = COLETANDO then - v_strHint := v_strHint + chr(13) + chr(10) + ' Coletas em Execu��o...'; + v_strHint := v_strHint + chr(13) + chr(10) + ' Coletas em Execução...'; objCACIC.writeDebugLog('InicializaTray: v_strHint Depois = "'+v_strHint+'"'); End; @@ -1731,7 +1731,7 @@ end; procedure TFormularioGeral.WMQueryEndSession(var Msg: TWMQueryEndSession); begin - objCACIC.writeDailyLog('Windows em processo de finaliza��o!'); + objCACIC.writeDailyLog('Windows em processo de finalização!'); // Quando h� um shutdown do windows em execu��o, libera o close. OnCloseQuery := Nil; Msg.Result := 1; @@ -1960,7 +1960,7 @@ begin st_lb_Etiqueta9.Caption := st_lb_Etiqueta9.Caption + IfThen(st_lb_Etiqueta9.Caption='','',':'); st_lb_Etiqueta9.Visible := true; st_vl_etiqueta9.Caption := objCACIC.deCrypt( objCACIC.GetValueFromFile('Patrimonio','TeInfoPatrimonio6', strMainProgramInfFileName)); - end + end else Begin st_lb_Etiqueta9.Visible := false; -- libgit2 0.21.2