summaryrefslogtreecommitdiffstats
path: root/plugin/firewall/eurephiafw.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/firewall/eurephiafw.c')
-rw-r--r--plugin/firewall/eurephiafw.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/plugin/firewall/eurephiafw.c b/plugin/firewall/eurephiafw.c
index 8b24486..774fe21 100644
--- a/plugin/firewall/eurephiafw.c
+++ b/plugin/firewall/eurephiafw.c
@@ -265,11 +265,11 @@ void eFW_StartFirewall(eurephiaCTX *ctx) {
updreq.mode = fwINITIALISE;
strncpy(updreq.rule_destination, fwdest, 64);
mqres = mq_send((*ctx->fwcfg).thrdata.msgq,
- (const char *)&updreq, sizeof(eFWupdateRequest), 1);
- if( mqres < 1 ) {
+ (const char *)&updreq, EFW_MSG_SIZE, 1);
+ if( mqres < 0 ) {
eurephia_log(ctx, LOG_ERROR, 0,
- "Could not request firewall initialisation of the %s chain: %s",
- fwdest, strerror(errno));
+ "Could not request firewall initialisation of the %s chain: (%i) %s",
+ fwdest, mqres, strerror(errno));
};
if( ctx->fwcfg->fwblacklist != NULL ) {
@@ -282,16 +282,19 @@ void eFW_StartFirewall(eurephiaCTX *ctx) {
strncpy(updreq.rule_destination, ctx->fwcfg->fwblacklist, 64);
errno = 0;
mqres = mq_send((*ctx->fwcfg).thrdata.msgq,
- (const char *)&updreq, sizeof(eFWupdateRequest), 1);
- if( mqres < 1 ) {
- eurephia_log(ctx, LOG_ERROR, 0, "Could not request flushing of the %s chain: %s",
- ctx->fwcfg->fwblacklist, strerror(errno));
+ (const char *)&updreq, EFW_MSG_SIZE, 1);
+ if( mqres < 0 ) {
+ eurephia_log(ctx, LOG_ERROR, 0, "Could not request flushing of the %s chain: (%i) %s",
+ ctx->fwcfg->fwblacklist, mqres, strerror(errno));
};
// Registering already blacklisted IP addresses into the proper firewall chain
memset(&updreq, 0, sizeof(eFWupdateRequest));
updreq.mode = fwBLACKLIST;
blacklisted = eDBget_blacklisted_ip(ctx);
+ strncpy(updreq.rule_destination, ctx->fwcfg->fwblacklist, 64);
+ strncpy(updreq.goto_destination,
+ ctx->fwcfg->fwblacklist_sendto ? ctx->fwcfg->fwblacklist_sendto : "\0", 64);
p = blacklisted;
while( p != NULL ) {
if( p->val != NULL ) {
@@ -333,8 +336,8 @@ void eFW_StopFirewall(eurephiaCTX *ctx) {
errno = 0;
mqres = mq_send((*ctx->fwcfg).thrdata.msgq,
- (const char *)&updreq, sizeof(eFWupdateRequest), 1);
- if( mqres < 1 ) {
+ (const char *)&updreq, EFW_MSG_SIZE, 1);
+ if( mqres < 0 ) {
eurephia_log(ctx, LOG_CRITICAL, 0,
"Could not request firewall flushing of the %s chain: %s",
fwdest, strerror(errno));
@@ -350,7 +353,7 @@ void eFW_StopFirewall(eurephiaCTX *ctx) {
updreq.mode = fwSHUTDOWN;
errno = 0;
mqres = mq_send((*ctx->fwcfg).thrdata.msgq,
- (const char *)&updreq, sizeof(eFWupdateRequest), 1);
+ (const char *)&updreq, EFW_MSG_SIZE, 1);
if( mqres < 1 ) {
eurephia_log(ctx, LOG_PANIC, 0,
"Could not initiate shutdown on eFW module: %s", strerror(errno));
@@ -437,7 +440,7 @@ int eFW_UpdateFirewall(eurephiaCTX *ctx, eFWupdateRequest *request ) {
request->goto_destination);
errno = 0;
mqres = mq_send((*ctx->fwcfg).thrdata.msgq,
- (const char *)request, sizeof(eFWupdateRequest), prio);
+ (const char *)request, EFW_MSG_SIZE, prio);
if( mqres < 0 ) {
eurephia_log(ctx, LOG_CRITICAL, 0,
"eFW_updateFirewall: Failed to send update request - %s",
@@ -468,7 +471,7 @@ int eFW_UpdateFirewall(eurephiaCTX *ctx, eFWupdateRequest *request ) {
errno = 0;
mqres = mq_send((*ctx->fwcfg).thrdata.msgq,
- (const char *)request, sizeof(eFWupdateRequest), prio);
+ (const char *)request, EFW_MSG_SIZE, prio);
if( mqres < 0 ) {
eurephia_log(ctx, LOG_CRITICAL, 0,
"eFW_updateFirewall: Failed to send update request - %s",