Blame SOURCES/mod_security-2.9.2-remote-rules-timeout.patch

996d8a
diff --git a/apache2/apache2_config.c b/apache2/apache2_config.c
996d8a
index ce97950..5d4e9b5 100644
996d8a
--- a/apache2/apache2_config.c
996d8a
+++ b/apache2/apache2_config.c
996d8a
@@ -2345,6 +2345,24 @@ static const char *cmd_remote_rules(cmd_parms *cmd, void *_dcfg, const char *p1,
996d8a
 }
996d8a
 
996d8a
 
996d8a
+static const char *cmd_remote_timeout(cmd_parms *cmd, void *_dcfg, const char *p1)
996d8a
+{
996d8a
+    directory_config *dcfg = (directory_config *)_dcfg;
996d8a
+    long int timeout;
996d8a
+
996d8a
+    if (dcfg == NULL) return NULL;
996d8a
+
996d8a
+    timeout = strtol(p1, NULL, 10);
996d8a
+    if ((timeout == LONG_MAX)||(timeout == LONG_MIN)||(timeout < 0)) {
996d8a
+        return apr_psprintf(cmd->pool, "ModSecurity: Invalid value for SecRemoteTimeout: %s", p1);
996d8a
+    }
996d8a
+
996d8a
+    remote_rules_timeout = timeout;
996d8a
+
996d8a
+    return NULL;
996d8a
+}
996d8a
+
996d8a
+
996d8a
 static const char *cmd_status_engine(cmd_parms *cmd, void *_dcfg, const char *p1)
996d8a
 {
996d8a
     if (strcasecmp(p1, "on") == 0) {
996d8a
@@ -3658,6 +3677,14 @@ const command_rec module_directives[] = {
996d8a
         "Abort or Warn"
996d8a
     ),
996d8a
 
996d8a
+    AP_INIT_TAKE1 (
996d8a
+        "SecRemoteTimeout",
996d8a
+        cmd_remote_timeout,
996d8a
+        NULL,
996d8a
+        CMD_SCOPE_ANY,
996d8a
+        "timeout in seconds"
996d8a
+    ),
996d8a
+
996d8a
 
996d8a
     AP_INIT_TAKE1 (
996d8a
         "SecXmlExternalEntity",
996d8a
diff --git a/apache2/mod_security2.c b/apache2/mod_security2.c
996d8a
index b6e98e9..1410ac7 100644
996d8a
--- a/apache2/mod_security2.c
996d8a
+++ b/apache2/mod_security2.c
996d8a
@@ -79,6 +79,8 @@ msc_remote_rules_server DSOLOCAL *remote_rules_server = NULL;
996d8a
 #endif
996d8a
 int DSOLOCAL remote_rules_fail_action = REMOTE_RULES_ABORT_ON_FAIL;
996d8a
 char DSOLOCAL *remote_rules_fail_message = NULL;
996d8a
+unsigned long int DSOLOCAL remote_rules_timeout = NOT_SET;
996d8a
+
996d8a
 
996d8a
 int DSOLOCAL status_engine_state = STATUS_ENGINE_DISABLED;
996d8a
 
996d8a
diff --git a/apache2/modsecurity.h b/apache2/modsecurity.h
996d8a
index f170034..d9de1f0 100644
996d8a
--- a/apache2/modsecurity.h
996d8a
+++ b/apache2/modsecurity.h
996d8a
@@ -150,6 +150,7 @@ extern DSOLOCAL msc_remote_rules_server *remote_rules_server;
996d8a
 #endif
996d8a
 extern DSOLOCAL int remote_rules_fail_action;
996d8a
 extern DSOLOCAL char *remote_rules_fail_message;
996d8a
+extern DSOLOCAL unsigned long int remote_rules_timeout;
996d8a
 
996d8a
 extern DSOLOCAL int status_engine_state;
996d8a
 
996d8a
diff --git a/apache2/msc_remote_rules.c b/apache2/msc_remote_rules.c
996d8a
index 8a6df9e..af437d1 100644
996d8a
--- a/apache2/msc_remote_rules.c
996d8a
+++ b/apache2/msc_remote_rules.c
996d8a
@@ -353,6 +353,11 @@ int msc_remote_download_content(apr_pool_t *mp, const char *uri, const char *key
996d8a
         /* We want Curl to return error in case there is an HTTP error code */
996d8a
         curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
996d8a
 
996d8a
+        /* In case we want different timeout than a default one */
996d8a
+        if (remote_rules_timeout != NOT_SET){
996d8a
+            curl_easy_setopt(curl, CURLOPT_TIMEOUT, remote_rules_timeout);
996d8a
+        }
996d8a
+
996d8a
         res = curl_easy_perform(curl);
996d8a
 
996d8a
         if (res != CURLE_OK)