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

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