diff options
Diffstat (limited to 'database/sqlite/administration/attempts.c')
-rw-r--r-- | database/sqlite/administration/attempts.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/database/sqlite/administration/attempts.c b/database/sqlite/administration/attempts.c index 0085f08..d296172 100644 --- a/database/sqlite/administration/attempts.c +++ b/database/sqlite/administration/attempts.c @@ -70,8 +70,10 @@ xmlDoc *attempts_list(eurephiaCTX *ctx, eDBfieldMap *fmap) { " registered, last_attempt, atpid" " FROM openvpn_attempts", NULL, fmap, "atpid"); - if( res == NULL ) { + if( sqlite_query_status(res) != dbSUCCESS ) { eurephia_log(ctx, LOG_ERROR, 0, "Error querying the attempts log"); + sqlite_log_error(ctx, res); + sqlite_free_results(res); return NULL; } @@ -141,13 +143,17 @@ xmlDoc *attempts_reset(eurephiaCTX *ctx, eDBfieldMap *fmap) { } res = sqlite_query_mapped(ctx, SQL_UPDATE, "UPDATE openvpn_attempts", update_vals, fmap, NULL); - if( res == NULL ) { - eurephia_log(ctx, LOG_FATAL, 0, "Could not reset the attempts count"); - ret = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL, "Could not reset the attempts count"); - } else { + if( sqlite_query_status(res) == dbSUCCESS ) { ret = eurephiaXML_ResultMsg(ctx, exmlRESULT, NULL, "Attempts count reset"); - sqlite_free_results(res); + } else { + xmlNode *err_n = NULL; + + eurephia_log(ctx, LOG_FATAL, 0, "Could not reset the attempts count"); + err_n = sqlite_log_error_xml(ctx, res); + ret = eurephiaXML_ResultMsg(ctx, exmlERROR, err_n, "Could not reset the attempts count"); + xmlFreeNode(err_n); } + sqlite_free_results(res); return ret; } @@ -172,13 +178,17 @@ xmlDoc *attempts_delete(eurephiaCTX *ctx, eDBfieldMap *fmap) { } res = sqlite_query_mapped(ctx, SQL_DELETE, "DELETE FROM openvpn_attempts", NULL, fmap, NULL); - if( res == NULL ) { - eurephia_log(ctx, LOG_FATAL, 0, "Could not remove attempts record"); - ret = eurephiaXML_ResultMsg(ctx, exmlERROR, NULL, "Could not delete the attempts record"); - } else { + if( sqlite_query_status(res) == dbSUCCESS ) { ret = eurephiaXML_ResultMsg(ctx, exmlRESULT, NULL, "Attempts record removed"); - sqlite_free_results(res); + } else { + xmlNode *err_n = NULL; + + eurephia_log(ctx, LOG_FATAL, 0, "Could not remove attempts record"); + err_n = sqlite_log_error_xml(ctx, res); + ret = eurephiaXML_ResultMsg(ctx, exmlERROR, err_n, "Could not delete the attempts record"); + xmlFreeNode(err_n); } + sqlite_free_results(res); return ret; } |