Skip to content

Commit dc81e4f

Browse files
author
Felipe Zimmerle
committed
Informs problems and successfully loaded external resources during reload
Resources load mechanism as the SecRemoteRuels were not showing information about the loaded rules while Apache was reloaded. This patch add such information to reload in the same way that it was showing on restart.
1 parent fe22446 commit dc81e4f

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
DD mmm YYYY - 2.9.????? (To be released)
22
-----------------------
33

4+
* Informs about external resources loaded/failed while reloading Apache.
5+
[ModSecurity team]
46
* Adds missing 'ModSecurity:' prefix in some warnings messages.
57
[Walter Hop and ModSecurity team]
68
* Refactoring external resources download warn messages. Holding the message

apache2/mod_security2.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -762,14 +762,15 @@ static int hook_post_config(apr_pool_t *mp, apr_pool_t *mp_log, apr_pool_t *mp_t
762762
"it by set SecStatusEngine to On.");
763763
}
764764
#endif
765+
}
765766

766-
if (remote_rules_fail_message != NULL)
767-
{
768-
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, NULL, "ModSecurity: " \
769-
"Problems loading external resources: %s",
770-
remote_rules_fail_message);
771-
}
772-
767+
/**
768+
* Checking if it is not the first time that we are in this very function.
769+
* We want to show the messages below during the start and the reload.
770+
*
771+
*/
772+
if (first_time != 1)
773+
{
773774
#ifdef WITH_REMOTE_RULES
774775
if (remote_rules_server != NULL)
775776
{
@@ -789,6 +790,12 @@ static int hook_post_config(apr_pool_t *mp, apr_pool_t *mp_log, apr_pool_t *mp_t
789790
}
790791
}
791792
#endif
793+
if (remote_rules_fail_message != NULL)
794+
{
795+
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, NULL, "ModSecurity: " \
796+
"Problems loading external resources: %s",
797+
remote_rules_fail_message);
798+
}
792799
}
793800

794801
srand((unsigned int)(time(NULL) * getpid()));

apache2/re_operators.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,12 @@ static int msre_op_pmFromFile_param_init(msre_rule *rule, char **error_msg) {
12931293

12941294
res = msc_remote_download_content(rule->ruleset->mp, fn, NULL,
12951295
&chunk, error_msg);
1296-
if (res == -1)
1296+
if (res == -2)
1297+
{
1298+
/* If download failed but SecRemoteRulesFailAction is set to Warn. */
1299+
return 1;
1300+
}
1301+
else if (res < 0)
12971302
{
12981303
return 0;
12991304
}

0 commit comments

Comments
 (0)