mirror of https://git.48k.eu/ogserver
#941 use dbi layer from respuestaEstandar()
And update all callers. Some of the db.Open() calls cannot be removed yet, since there are still more function dependencies that need to be converted too.master
parent
39157320ec
commit
1d801be52c
|
@ -1041,12 +1041,13 @@ static bool DisponibilidadComandos(TRAMA *ptrTrama, struct og_client *cli)
|
||||||
// true: Si el proceso es correcto
|
// true: Si el proceso es correcto
|
||||||
// false: En caso de ocurrir algún error
|
// false: En caso de ocurrir algún error
|
||||||
// ________________________________________________________________________________________________________
|
// ________________________________________________________________________________________________________
|
||||||
static bool respuestaEstandar(TRAMA *ptrTrama, char *iph, char *ido, Database db,
|
static bool respuestaEstandar(TRAMA *ptrTrama, char *iph, char *ido,
|
||||||
Table tbl)
|
struct og_dbi *dbi)
|
||||||
{
|
{
|
||||||
char msglog[LONSTD], sqlstr[LONSQL];
|
|
||||||
char *res, *ids, *der;
|
char *res, *ids, *der;
|
||||||
char fechafin[LONPRM];
|
char fechafin[LONPRM];
|
||||||
|
const char *msglog;
|
||||||
|
dbi_result result;
|
||||||
struct tm* st;
|
struct tm* st;
|
||||||
int idaccion;
|
int idaccion;
|
||||||
|
|
||||||
|
@ -1072,46 +1073,46 @@ static bool respuestaEstandar(TRAMA *ptrTrama, char *iph, char *ido, Database db
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(sqlstr,
|
result = dbi_conn_queryf(dbi->conn,
|
||||||
"SELECT * FROM acciones WHERE idordenador=%s"
|
"SELECT * FROM acciones WHERE idordenador=%s"
|
||||||
" AND sesion=%s ORDER BY idaccion", ido,ids);
|
" AND sesion=%s ORDER BY idaccion", ido,ids);
|
||||||
|
|
||||||
liberaMemoria(ids);
|
liberaMemoria(ids);
|
||||||
|
|
||||||
if (!db.Execute(sqlstr, tbl)) {
|
if (!result) {
|
||||||
db.GetErrorErrStr(msglog);
|
dbi_conn_error(dbi->conn, &msglog);
|
||||||
syslog(LOG_ERR, "failed to query database (%s:%d) %s\n",
|
syslog(LOG_ERR, "failed to query database (%s:%d) %s\n",
|
||||||
__func__, __LINE__, msglog);
|
__func__, __LINE__, msglog);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (tbl.ISEOF()) {
|
if (!dbi_result_next_row(result)) {
|
||||||
syslog(LOG_ERR, "no actions available\n");
|
syslog(LOG_ERR, "no actions available\n");
|
||||||
|
dbi_result_free(result);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!tbl.Get("idaccion", idaccion)) { // Toma identificador de la accion
|
|
||||||
tbl.GetErrorErrStr(msglog); // Error al acceder al registro
|
idaccion = dbi_result_get_uint(result, "idaccion");
|
||||||
og_info(msglog);
|
dbi_result_free(result);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
st = tomaHora();
|
st = tomaHora();
|
||||||
sprintf(fechafin, "%d/%d/%d %d:%d:%d", st->tm_year + 1900, st->tm_mon + 1,
|
sprintf(fechafin, "%d/%d/%d %d:%d:%d", st->tm_year + 1900, st->tm_mon + 1,
|
||||||
st->tm_mday, st->tm_hour, st->tm_min, st->tm_sec);
|
st->tm_mday, st->tm_hour, st->tm_min, st->tm_sec);
|
||||||
|
|
||||||
der = copiaParametro("der",ptrTrama); // Toma descripción del error (si hubiera habido)
|
der = copiaParametro("der",ptrTrama); // Toma descripción del error (si hubiera habido)
|
||||||
|
|
||||||
sprintf(sqlstr,
|
result = dbi_conn_queryf(dbi->conn,
|
||||||
"UPDATE acciones"\
|
"UPDATE acciones"\
|
||||||
" SET resultado='%s',estado='%d',fechahorafin='%s',descrinotificacion='%s'"\
|
" SET resultado='%s',estado='%d',fechahorafin='%s',descrinotificacion='%s'"\
|
||||||
" WHERE idordenador=%s AND idaccion=%d",
|
" WHERE idordenador=%s AND idaccion=%d",
|
||||||
res, ACCION_FINALIZADA, fechafin, der, ido, idaccion);
|
res, ACCION_FINALIZADA, fechafin, der, ido, idaccion);
|
||||||
|
if (!result) {
|
||||||
if (!db.Execute(sqlstr, tbl)) { // Error al actualizar
|
dbi_conn_error(dbi->conn, &msglog);
|
||||||
liberaMemoria(res);
|
liberaMemoria(res);
|
||||||
liberaMemoria(der);
|
liberaMemoria(der);
|
||||||
db.GetErrorErrStr(msglog);
|
og_info((char *)msglog);
|
||||||
og_info(msglog);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
dbi_result_free(result);
|
||||||
|
|
||||||
liberaMemoria(der);
|
liberaMemoria(der);
|
||||||
|
|
||||||
|
@ -1396,27 +1397,26 @@ bool WakeUp(int s, char* iph, char *mac, char *mar)
|
||||||
// ________________________________________________________________________________________________________
|
// ________________________________________________________________________________________________________
|
||||||
static bool RESPUESTA_Arrancar(TRAMA* ptrTrama, struct og_client *cli)
|
static bool RESPUESTA_Arrancar(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
{
|
{
|
||||||
char msglog[LONSTD];
|
struct og_dbi *dbi;
|
||||||
Database db;
|
|
||||||
Table tbl;
|
|
||||||
int i;
|
|
||||||
char *iph, *ido;
|
char *iph, *ido;
|
||||||
char *tpc;
|
char *tpc;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (!db.Open(usuario, pasguor, datasource, catalog)) {
|
dbi = og_dbi_open(&dbi_config);
|
||||||
db.GetErrorErrStr(msglog);
|
if (!dbi) {
|
||||||
syslog(LOG_ERR, "cannot open connection database (%s:%d) %s\n",
|
syslog(LOG_ERR, "cannot open connection database (%s:%d)\n",
|
||||||
__func__, __LINE__, msglog);
|
__func__, __LINE__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
iph = copiaParametro("iph",ptrTrama); // Toma dirección ip
|
iph = copiaParametro("iph",ptrTrama); // Toma dirección ip
|
||||||
ido = copiaParametro("ido",ptrTrama); // Toma identificador del ordenador
|
ido = copiaParametro("ido",ptrTrama); // Toma identificador del ordenador
|
||||||
|
|
||||||
if (!respuestaEstandar(ptrTrama, iph, ido, db, tbl)) {
|
if (!respuestaEstandar(ptrTrama, iph, ido, dbi)) {
|
||||||
liberaMemoria(iph);
|
liberaMemoria(iph);
|
||||||
liberaMemoria(ido);
|
liberaMemoria(ido);
|
||||||
syslog(LOG_ERR, "failed to register notification\n");
|
syslog(LOG_ERR, "failed to register notification\n");
|
||||||
|
og_dbi_close(dbi);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1427,8 +1427,8 @@ static bool RESPUESTA_Arrancar(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
liberaMemoria(iph);
|
liberaMemoria(iph);
|
||||||
liberaMemoria(ido);
|
liberaMemoria(ido);
|
||||||
liberaMemoria(tpc);
|
liberaMemoria(tpc);
|
||||||
|
og_dbi_close(dbi);
|
||||||
|
|
||||||
db.Close(); // Cierra conexión
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// ________________________________________________________________________________________________________
|
// ________________________________________________________________________________________________________
|
||||||
|
@ -1445,26 +1445,25 @@ static bool RESPUESTA_Arrancar(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
// ________________________________________________________________________________________________________
|
// ________________________________________________________________________________________________________
|
||||||
static bool RESPUESTA_Apagar(TRAMA* ptrTrama, struct og_client *cli)
|
static bool RESPUESTA_Apagar(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
{
|
{
|
||||||
char msglog[LONSTD];
|
struct og_dbi *dbi;
|
||||||
Database db;
|
|
||||||
Table tbl;
|
|
||||||
int i;
|
|
||||||
char *iph, *ido;
|
char *iph, *ido;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (!db.Open(usuario, pasguor, datasource, catalog)) {
|
dbi = og_dbi_open(&dbi_config);
|
||||||
db.GetErrorErrStr(msglog);
|
if (!dbi) {
|
||||||
syslog(LOG_ERR, "cannot open connection database (%s:%d) %s\n",
|
syslog(LOG_ERR, "cannot open connection database (%s:%d)\n",
|
||||||
__func__, __LINE__, msglog);
|
__func__, __LINE__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
iph = copiaParametro("iph",ptrTrama); // Toma dirección ip
|
iph = copiaParametro("iph",ptrTrama); // Toma dirección ip
|
||||||
ido = copiaParametro("ido",ptrTrama); // Toma identificador del ordenador
|
ido = copiaParametro("ido",ptrTrama); // Toma identificador del ordenador
|
||||||
|
|
||||||
if (!respuestaEstandar(ptrTrama, iph, ido, db, tbl)) {
|
if (!respuestaEstandar(ptrTrama, iph, ido, dbi)) {
|
||||||
liberaMemoria(iph);
|
liberaMemoria(iph);
|
||||||
liberaMemoria(ido);
|
liberaMemoria(ido);
|
||||||
syslog(LOG_ERR, "failed to register notification\n");
|
syslog(LOG_ERR, "failed to register notification\n");
|
||||||
|
og_dbi_close(dbi);
|
||||||
return false; // Error al registrar notificacion
|
return false; // Error al registrar notificacion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1473,8 +1472,8 @@ static bool RESPUESTA_Apagar(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
|
|
||||||
liberaMemoria(iph);
|
liberaMemoria(iph);
|
||||||
liberaMemoria(ido);
|
liberaMemoria(ido);
|
||||||
|
og_dbi_close(dbi);
|
||||||
|
|
||||||
db.Close(); // Cierra conexión
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// ________________________________________________________________________________________________________
|
// ________________________________________________________________________________________________________
|
||||||
|
@ -1495,6 +1494,7 @@ static bool RESPUESTA_CrearImagen(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
Database db;
|
Database db;
|
||||||
Table tbl;
|
Table tbl;
|
||||||
char *iph, *dsk, *par, *cpt, *ipr, *ido;
|
char *iph, *dsk, *par, *cpt, *ipr, *ido;
|
||||||
|
struct og_dbi *dbi;
|
||||||
char *idi;
|
char *idi;
|
||||||
bool res;
|
bool res;
|
||||||
|
|
||||||
|
@ -1505,13 +1505,22 @@ static bool RESPUESTA_CrearImagen(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbi = og_dbi_open(&dbi_config);
|
||||||
|
if (!dbi) {
|
||||||
|
syslog(LOG_ERR, "cannot open connection database (%s:%d)\n",
|
||||||
|
__func__, __LINE__);
|
||||||
|
db.Close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
iph = copiaParametro("iph",ptrTrama); // Toma dirección ip
|
iph = copiaParametro("iph",ptrTrama); // Toma dirección ip
|
||||||
ido = copiaParametro("ido",ptrTrama); // Toma identificador del ordenador
|
ido = copiaParametro("ido",ptrTrama); // Toma identificador del ordenador
|
||||||
|
|
||||||
if (!respuestaEstandar(ptrTrama, iph, ido, db, tbl)) {
|
if (!respuestaEstandar(ptrTrama, iph, ido, dbi)) {
|
||||||
liberaMemoria(iph);
|
liberaMemoria(iph);
|
||||||
liberaMemoria(ido);
|
liberaMemoria(ido);
|
||||||
syslog(LOG_ERR, "failed to register notification\n");
|
syslog(LOG_ERR, "failed to register notification\n");
|
||||||
|
og_dbi_close(dbi);
|
||||||
return false; // Error al registrar notificacion
|
return false; // Error al registrar notificacion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1528,15 +1537,14 @@ static bool RESPUESTA_CrearImagen(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
liberaMemoria(par);
|
liberaMemoria(par);
|
||||||
liberaMemoria(cpt);
|
liberaMemoria(cpt);
|
||||||
liberaMemoria(ipr);
|
liberaMemoria(ipr);
|
||||||
|
og_dbi_close(dbi);
|
||||||
|
|
||||||
if(!res){
|
if (!res)
|
||||||
syslog(LOG_ERR, "Problem processing update\n");
|
syslog(LOG_ERR, "Problem processing update\n");
|
||||||
db.Close();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
db.Close(); // Cierra conexión
|
db.Close(); // Cierra conexión
|
||||||
return true;
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
// ________________________________________________________________________________________________________
|
// ________________________________________________________________________________________________________
|
||||||
// Función: actualizaCreacionImagen
|
// Función: actualizaCreacionImagen
|
||||||
|
@ -1685,6 +1693,7 @@ static bool RESPUESTA_CrearSoftIncremental(TRAMA* ptrTrama, struct og_client *cl
|
||||||
char *iph,*par,*ido,*idf;
|
char *iph,*par,*ido,*idf;
|
||||||
int ifs;
|
int ifs;
|
||||||
char msglog[LONSTD],sqlstr[LONSQL];
|
char msglog[LONSTD],sqlstr[LONSQL];
|
||||||
|
struct og_dbi *dbi;
|
||||||
|
|
||||||
if (!db.Open(usuario, pasguor, datasource, catalog)) {
|
if (!db.Open(usuario, pasguor, datasource, catalog)) {
|
||||||
db.GetErrorErrStr(msglog);
|
db.GetErrorErrStr(msglog);
|
||||||
|
@ -1693,10 +1702,19 @@ static bool RESPUESTA_CrearSoftIncremental(TRAMA* ptrTrama, struct og_client *cl
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbi = og_dbi_open(&dbi_config);
|
||||||
|
if (!dbi) {
|
||||||
|
syslog(LOG_ERR, "cannot open connection database (%s:%d)\n",
|
||||||
|
__func__, __LINE__);
|
||||||
|
db.Close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
iph = copiaParametro("iph",ptrTrama); // Toma dirección ip
|
iph = copiaParametro("iph",ptrTrama); // Toma dirección ip
|
||||||
ido = copiaParametro("ido",ptrTrama); // Toma identificador del ordenador
|
ido = copiaParametro("ido",ptrTrama); // Toma identificador del ordenador
|
||||||
|
|
||||||
if (!respuestaEstandar(ptrTrama, iph, ido, db, tbl)) {
|
if (!respuestaEstandar(ptrTrama, iph, ido, dbi)) {
|
||||||
|
og_dbi_close(dbi);
|
||||||
liberaMemoria(iph);
|
liberaMemoria(iph);
|
||||||
liberaMemoria(ido);
|
liberaMemoria(ido);
|
||||||
syslog(LOG_ERR, "failed to register notification\n");
|
syslog(LOG_ERR, "failed to register notification\n");
|
||||||
|
@ -1735,6 +1753,7 @@ static bool RESPUESTA_CrearSoftIncremental(TRAMA* ptrTrama, struct og_client *cl
|
||||||
__func__, __LINE__, msglog);
|
__func__, __LINE__, msglog);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
og_dbi_close(dbi);
|
||||||
db.Close(); // Cierra conexión
|
db.Close(); // Cierra conexión
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1758,6 +1777,7 @@ static bool RESPUESTA_RestaurarImagen(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
Table tbl;
|
Table tbl;
|
||||||
bool res;
|
bool res;
|
||||||
char *iph, *ido, *idi, *dsk, *par, *ifs, *cfg;
|
char *iph, *ido, *idi, *dsk, *par, *ifs, *cfg;
|
||||||
|
struct og_dbi *dbi;
|
||||||
|
|
||||||
if (!db.Open(usuario, pasguor, datasource, catalog)) {
|
if (!db.Open(usuario, pasguor, datasource, catalog)) {
|
||||||
db.GetErrorErrStr(msglog);
|
db.GetErrorErrStr(msglog);
|
||||||
|
@ -1766,10 +1786,19 @@ static bool RESPUESTA_RestaurarImagen(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbi = og_dbi_open(&dbi_config);
|
||||||
|
if (!dbi) {
|
||||||
|
syslog(LOG_ERR, "cannot open connection database (%s:%d)\n",
|
||||||
|
__func__, __LINE__);
|
||||||
|
db.Close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
iph = copiaParametro("iph",ptrTrama); // Toma dirección ip
|
iph = copiaParametro("iph",ptrTrama); // Toma dirección ip
|
||||||
ido = copiaParametro("ido",ptrTrama); // Toma identificador del ordenador
|
ido = copiaParametro("ido",ptrTrama); // Toma identificador del ordenador
|
||||||
|
|
||||||
if (!respuestaEstandar(ptrTrama, iph, ido, db, tbl)) {
|
if (!respuestaEstandar(ptrTrama, iph, ido, dbi)) {
|
||||||
|
og_dbi_close(dbi);
|
||||||
liberaMemoria(iph);
|
liberaMemoria(iph);
|
||||||
liberaMemoria(ido);
|
liberaMemoria(ido);
|
||||||
syslog(LOG_ERR, "failed to register notification\n");
|
syslog(LOG_ERR, "failed to register notification\n");
|
||||||
|
@ -1793,15 +1822,14 @@ static bool RESPUESTA_RestaurarImagen(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
liberaMemoria(idi);
|
liberaMemoria(idi);
|
||||||
liberaMemoria(par);
|
liberaMemoria(par);
|
||||||
liberaMemoria(ifs);
|
liberaMemoria(ifs);
|
||||||
|
og_dbi_close(dbi);
|
||||||
|
|
||||||
if(!res){
|
if(!res)
|
||||||
syslog(LOG_ERR, "Problem after restoring image\n");
|
syslog(LOG_ERR, "Problem after restoring image\n");
|
||||||
db.Close();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
db.Close(); // Cierra conexión
|
db.Close(); // Cierra conexión
|
||||||
return true;
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
// ________________________________________________________________________________________________________
|
// ________________________________________________________________________________________________________
|
||||||
//
|
//
|
||||||
|
@ -1893,6 +1921,7 @@ static bool RESPUESTA_EjecutarScript(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
Database db;
|
Database db;
|
||||||
Table tbl;
|
Table tbl;
|
||||||
char *iph, *ido,*cfg;
|
char *iph, *ido,*cfg;
|
||||||
|
struct og_dbi *dbi;
|
||||||
bool res = true;
|
bool res = true;
|
||||||
|
|
||||||
if (!db.Open(usuario, pasguor, datasource, catalog)) {
|
if (!db.Open(usuario, pasguor, datasource, catalog)) {
|
||||||
|
@ -1902,10 +1931,19 @@ static bool RESPUESTA_EjecutarScript(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbi = og_dbi_open(&dbi_config);
|
||||||
|
if (!dbi) {
|
||||||
|
syslog(LOG_ERR, "cannot open connection database (%s:%d)\n",
|
||||||
|
__func__, __LINE__);
|
||||||
|
db.Close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
iph = copiaParametro("iph",ptrTrama); // Toma dirección ip
|
iph = copiaParametro("iph",ptrTrama); // Toma dirección ip
|
||||||
ido = copiaParametro("ido",ptrTrama); // Toma identificador del ordenador
|
ido = copiaParametro("ido",ptrTrama); // Toma identificador del ordenador
|
||||||
|
|
||||||
if (!respuestaEstandar(ptrTrama, iph, ido, db, tbl)) {
|
if (!respuestaEstandar(ptrTrama, iph, ido, dbi)) {
|
||||||
|
og_dbi_close(dbi);
|
||||||
liberaMemoria(iph);
|
liberaMemoria(iph);
|
||||||
liberaMemoria(ido);
|
liberaMemoria(ido);
|
||||||
syslog(LOG_ERR, "failed to register notification\n");
|
syslog(LOG_ERR, "failed to register notification\n");
|
||||||
|
@ -1920,14 +1958,14 @@ static bool RESPUESTA_EjecutarScript(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
|
|
||||||
liberaMemoria(iph);
|
liberaMemoria(iph);
|
||||||
liberaMemoria(ido);
|
liberaMemoria(ido);
|
||||||
|
og_dbi_close(dbi);
|
||||||
|
|
||||||
if (!res) {
|
if (!res)
|
||||||
syslog(LOG_ERR, "Problem updating client configuration\n");
|
syslog(LOG_ERR, "Problem updating client configuration\n");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
db.Close(); // Cierra conexión
|
db.Close(); // Cierra conexión
|
||||||
return true;
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
// ________________________________________________________________________________________________________
|
// ________________________________________________________________________________________________________
|
||||||
// Función: RESPUESTA_InventarioHardware
|
// Función: RESPUESTA_InventarioHardware
|
||||||
|
@ -1948,6 +1986,7 @@ static bool RESPUESTA_InventarioHardware(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
Table tbl;
|
Table tbl;
|
||||||
bool res;
|
bool res;
|
||||||
char *iph, *ido, *idc, *npc, *hrd, *buffer;
|
char *iph, *ido, *idc, *npc, *hrd, *buffer;
|
||||||
|
struct og_dbi *dbi;
|
||||||
|
|
||||||
if (!db.Open(usuario, pasguor, datasource, catalog)) {
|
if (!db.Open(usuario, pasguor, datasource, catalog)) {
|
||||||
db.GetErrorErrStr(msglog);
|
db.GetErrorErrStr(msglog);
|
||||||
|
@ -1956,10 +1995,19 @@ static bool RESPUESTA_InventarioHardware(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbi = og_dbi_open(&dbi_config);
|
||||||
|
if (!dbi) {
|
||||||
|
syslog(LOG_ERR, "cannot open connection database (%s:%d)\n",
|
||||||
|
__func__, __LINE__);
|
||||||
|
db.Close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
iph = copiaParametro("iph",ptrTrama); // Toma dirección ip del cliente
|
iph = copiaParametro("iph",ptrTrama); // Toma dirección ip del cliente
|
||||||
ido = copiaParametro("ido",ptrTrama); // Toma identificador del cliente
|
ido = copiaParametro("ido",ptrTrama); // Toma identificador del cliente
|
||||||
|
|
||||||
if (!respuestaEstandar(ptrTrama, iph, ido, db, tbl)) {
|
if (!respuestaEstandar(ptrTrama, iph, ido, dbi)) {
|
||||||
|
og_dbi_close(dbi);
|
||||||
liberaMemoria(iph);
|
liberaMemoria(iph);
|
||||||
liberaMemoria(ido);
|
liberaMemoria(ido);
|
||||||
syslog(LOG_ERR, "failed to register notification\n");
|
syslog(LOG_ERR, "failed to register notification\n");
|
||||||
|
@ -1980,14 +2028,14 @@ static bool RESPUESTA_InventarioHardware(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
liberaMemoria(npc);
|
liberaMemoria(npc);
|
||||||
liberaMemoria(idc);
|
liberaMemoria(idc);
|
||||||
liberaMemoria(buffer);
|
liberaMemoria(buffer);
|
||||||
|
og_dbi_close(dbi);
|
||||||
|
|
||||||
if(!res){
|
if (!res)
|
||||||
syslog(LOG_ERR, "Problem updating client configuration\n");
|
syslog(LOG_ERR, "Problem updating client configuration\n");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
db.Close(); // Cierra conexión
|
db.Close(); // Cierra conexión
|
||||||
return true;
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
// ________________________________________________________________________________________________________
|
// ________________________________________________________________________________________________________
|
||||||
// Función: actualizaHardware
|
// Función: actualizaHardware
|
||||||
|
@ -2299,6 +2347,7 @@ static bool RESPUESTA_InventarioSoftware(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
Table tbl;
|
Table tbl;
|
||||||
bool res;
|
bool res;
|
||||||
char *iph, *ido, *npc, *idc, *par, *sft, *buffer;
|
char *iph, *ido, *npc, *idc, *par, *sft, *buffer;
|
||||||
|
struct og_dbi *dbi;
|
||||||
|
|
||||||
if (!db.Open(usuario, pasguor, datasource, catalog)) {
|
if (!db.Open(usuario, pasguor, datasource, catalog)) {
|
||||||
db.GetErrorErrStr(msglog);
|
db.GetErrorErrStr(msglog);
|
||||||
|
@ -2307,10 +2356,19 @@ static bool RESPUESTA_InventarioSoftware(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbi = og_dbi_open(&dbi_config);
|
||||||
|
if (!dbi) {
|
||||||
|
syslog(LOG_ERR, "cannot open connection database (%s:%d)\n",
|
||||||
|
__func__, __LINE__);
|
||||||
|
db.Close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
iph = copiaParametro("iph",ptrTrama); // Toma dirección ip
|
iph = copiaParametro("iph",ptrTrama); // Toma dirección ip
|
||||||
ido = copiaParametro("ido",ptrTrama); // Toma identificador del ordenador
|
ido = copiaParametro("ido",ptrTrama); // Toma identificador del ordenador
|
||||||
|
|
||||||
if (!respuestaEstandar(ptrTrama, iph, ido, db, tbl)) {
|
if (!respuestaEstandar(ptrTrama, iph, ido, dbi)) {
|
||||||
|
og_dbi_close(dbi);
|
||||||
liberaMemoria(iph);
|
liberaMemoria(iph);
|
||||||
liberaMemoria(ido);
|
liberaMemoria(ido);
|
||||||
syslog(LOG_ERR, "failed to register notification\n");
|
syslog(LOG_ERR, "failed to register notification\n");
|
||||||
|
@ -2332,14 +2390,14 @@ static bool RESPUESTA_InventarioSoftware(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
liberaMemoria(idc);
|
liberaMemoria(idc);
|
||||||
liberaMemoria(par);
|
liberaMemoria(par);
|
||||||
liberaMemoria(sft);
|
liberaMemoria(sft);
|
||||||
|
og_dbi_close(dbi);
|
||||||
|
|
||||||
if(!res){
|
if (!res)
|
||||||
syslog(LOG_ERR, "cannot update software\n");
|
syslog(LOG_ERR, "cannot update software\n");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
db.Close(); // Cierra conexión
|
db.Close(); // Cierra conexión
|
||||||
return true;
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
// ________________________________________________________________________________________________________
|
// ________________________________________________________________________________________________________
|
||||||
// Función: actualizaSoftware
|
// Función: actualizaSoftware
|
||||||
|
|
Loading…
Reference in New Issue