git subrepo commit (merge) mailcow/src/mailcow-dockerized

subrepo: subdir:   "mailcow/src/mailcow-dockerized"
  merged:   "32243e56"
upstream: origin:   "https://github.com/mailcow/mailcow-dockerized.git"
  branch:   "master"
  commit:   "e2b4b6f6"
git-subrepo: version:  "0.4.3"
  origin:   "???"
  commit:   "???"
Change-Id: I51e2016ef5ab88a8b0bdc08551b18f48ceef0aa5
diff --git a/mailcow/src/mailcow-dockerized/data/conf/mysql/my.cnf b/mailcow/src/mailcow-dockerized/data/conf/mysql/my.cnf
index 9f52068..b4c3488 100644
--- a/mailcow/src/mailcow-dockerized/data/conf/mysql/my.cnf
+++ b/mailcow/src/mailcow-dockerized/data/conf/mysql/my.cnf
@@ -7,7 +7,7 @@
 #innodb_large_prefix            = TRUE
 #sql_mode=IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
 max_allowed_packet      = 192M
-max-connections         = 350
+max-connections         = 550
 key_buffer_size         = 0
 read_buffer_size        = 192K
 sort_buffer_size        = 2M
@@ -25,6 +25,8 @@
 skip-name-resolve
 log-warnings            = 0
 event_scheduler         = 1
+interactive_timeout     = 3610
+wait_timeout            = 3610
 
 [client]
 default-character-set = utf8mb4
diff --git a/mailcow/src/mailcow-dockerized/data/conf/postfix/main.cf b/mailcow/src/mailcow-dockerized/data/conf/postfix/main.cf
index b4f34b4..a445b60 100644
--- a/mailcow/src/mailcow-dockerized/data/conf/postfix/main.cf
+++ b/mailcow/src/mailcow-dockerized/data/conf/postfix/main.cf
@@ -15,7 +15,7 @@
 alias_maps = hash:/etc/aliases
 alias_database = hash:/etc/aliases
 relayhost =
-mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 172.22.1.0/24 [fe80::]/10 [fc00::]/7
+mynetworks_style = subnet
 mailbox_size_limit = 0
 recipient_delimiter = +
 inet_interfaces = all
@@ -27,7 +27,7 @@
 maximal_queue_lifetime = 5d
 delay_warning_time = 4h
 message_size_limit = 104857600
-milter_default_action = accept
+milter_default_action = tempfail
 milter_protocol = 6
 minimal_backoff_time = 300s
 plaintext_reject_code = 550
diff --git a/mailcow/src/mailcow-dockerized/data/conf/rspamd/custom/bulk_header.map b/mailcow/src/mailcow-dockerized/data/conf/rspamd/custom/bulk_header.map
index e9dc206..39aa7fe 100644
--- a/mailcow/src/mailcow-dockerized/data/conf/rspamd/custom/bulk_header.map
+++ b/mailcow/src/mailcow-dockerized/data/conf/rspamd/custom/bulk_header.map
@@ -17,3 +17,4 @@
 /.*light-house-traffic.*/i
 /.*newsletterplus.*/i
 /.*X-Chpo.*/i
+/.*List-Unsubscribe:.*@nl\..*/i
diff --git a/mailcow/src/mailcow-dockerized/data/conf/rspamd/dynmaps/settings.php b/mailcow/src/mailcow-dockerized/data/conf/rspamd/dynmaps/settings.php
index 0569db9..274e9da 100644
--- a/mailcow/src/mailcow-dockerized/data/conf/rspamd/dynmaps/settings.php
+++ b/mailcow/src/mailcow-dockerized/data/conf/rspamd/dynmaps/settings.php
@@ -26,9 +26,8 @@
 }

 

 // Check if db changed and return header

-/*

-$stmt = $pdo->prepare("SELECT MAX(UNIX_TIMESTAMP(UPDATE_TIME)) AS `db_update_time` FROM information_schema.tables

-  WHERE (`TABLE_NAME` = 'filterconf' OR `TABLE_NAME` = 'settingsmap')

+$stmt = $pdo->prepare("SELECT GREATEST(COALESCE(MAX(UNIX_TIMESTAMP(UPDATE_TIME)), 1), COALESCE(MAX(UNIX_TIMESTAMP(CREATE_TIME)), 1)) AS `db_update_time` FROM `information_schema`.`tables`

+  WHERE (`TABLE_NAME` = 'filterconf' OR `TABLE_NAME` = 'settingsmap' OR `TABLE_NAME` = 'sogo_quick_contact' OR `TABLE_NAME` = 'alias')

     AND TABLE_SCHEMA = :dbname;");

 $stmt->execute(array(

   ':dbname' => $database_name

@@ -43,7 +42,6 @@
 } else {

   header('Last-Modified: '.gmdate('D, d M Y H:i:s', $db_update_time).' GMT', true, 200);

 }

-*/

 

 function parse_email($email) {

   if (!filter_var($email, FILTER_VALIDATE_EMAIL)) return false;

@@ -51,6 +49,30 @@
   return array('local' => substr($email, 0, $a), 'domain' => substr($email, $a));

 }

 

+function normalize_email($email) {

+  $email = strtolower(str_replace('/', '\/', $email));

+  $gm = "@gmail.com";

+  if (substr_compare($email, $gm, -strlen($gm)) == 0) {

+    $email = explode('@', $email);

+    $email[0] = str_replace('.', '', $email[0]);

+    $email = implode('@', $email);

+  } 

+  $gm_alt = "@googlemail.com";

+  if (substr_compare($email, $gm_alt, -strlen($gm_alt)) == 0) {

+    $email = explode('@', $email);

+    $email[0] = str_replace('.', '', $email[0]);

+    $email[1] = str_replace('@', '', $gm);

+    $email = implode('@', $email);

+  }

+  if (str_contains($email, "+")) {

+    $email = explode('@', $email);

+    $user = explode('+', $email[0]);

+    $email[0] = $user[0];

+    $email = implode('@', $email);

+  }

+  return $email;

+}

+

 function wl_by_sogo() {

   global $pdo;

   $rcpt = array();

@@ -65,7 +87,7 @@
       }

       // Explicit from, no mime_from, no regex - envelope must match

       // mailcow white and blacklists also cover mime_from

-      $rcpt[$row['user']][] = str_replace('/', '\/', $contact);

+      $rcpt[$row['user']][] = normalize_email($contact);

     }

   }

   return $rcpt;

diff --git a/mailcow/src/mailcow-dockerized/data/conf/rspamd/local.d/metadata_exporter.conf b/mailcow/src/mailcow-dockerized/data/conf/rspamd/local.d/metadata_exporter.conf
index b6aa150..47373d9 100644
--- a/mailcow/src/mailcow-dockerized/data/conf/rspamd/local.d/metadata_exporter.conf
+++ b/mailcow/src/mailcow-dockerized/data/conf/rspamd/local.d/metadata_exporter.conf
@@ -26,7 +26,7 @@
   mailcow_rcpt = <<EOD
 return function(task)
   local action = task:get_metric_action('default')
-  if task:has_symbol('NO_LOG_STAT') or (action == 'reject' or action == 'add header' or action == 'rewrite subject') then
+  if task:has_symbol('NO_LOG_STAT') or (action == 'soft reject' or action == 'reject' or action == 'add header' or action == 'rewrite subject') then
     return false
   else
     if task:get_symbol("RCPT_MAILCOW_DOMAIN") then
diff --git a/mailcow/src/mailcow-dockerized/data/conf/rspamd/local.d/mime_types.conf b/mailcow/src/mailcow-dockerized/data/conf/rspamd/local.d/mime_types.conf
index 5d82982..08a08b6 100644
--- a/mailcow/src/mailcow-dockerized/data/conf/rspamd/local.d/mime_types.conf
+++ b/mailcow/src/mailcow-dockerized/data/conf/rspamd/local.d/mime_types.conf
@@ -14,7 +14,7 @@
   ps1 = 4,
   ace = 4,
   arj = 4,
-  cab = 3,
+  cab = 20,
   vbs = 20,
   hta = 4,
   shs = 4,
diff --git a/mailcow/src/mailcow-dockerized/data/conf/rspamd/lua/rspamd.local.lua b/mailcow/src/mailcow-dockerized/data/conf/rspamd/lua/rspamd.local.lua
index b007f09..6318bd2 100644
--- a/mailcow/src/mailcow-dockerized/data/conf/rspamd/lua/rspamd.local.lua
+++ b/mailcow/src/mailcow-dockerized/data/conf/rspamd/lua/rspamd.local.lua
@@ -1,10 +1,3 @@
--- Load sendgrid ID validator, thanks to https://github.com/fatalbanana
-local rspamd_util = require 'rspamd_util'
-local f = '/etc/rspamd/lua/ivm-sg.lua'
-if rspamd_util.file_exists(f) then
-  dofile(f)
-end
-
 rspamd_config.MAILCOW_AUTH = {
 	callback = function(task)
 		local uname = task:get_user()
@@ -500,7 +493,7 @@
   type = 'postfilter',
   callback = function(task)
     local from = task:get_header('From')
-    if from and monitoring_hosts:get_key(from) then
+    if from and (monitoring_hosts:get_key(from) or from == "watchdog@localhost") then
       task:set_flag('no_log')
       task:set_flag('no_stat')
     end
diff --git a/mailcow/src/mailcow-dockerized/data/conf/sogo/sogo.conf b/mailcow/src/mailcow-dockerized/data/conf/sogo/sogo.conf
index 2513f49..1d6a9d3 100644
--- a/mailcow/src/mailcow-dockerized/data/conf/sogo/sogo.conf
+++ b/mailcow/src/mailcow-dockerized/data/conf/sogo/sogo.conf
@@ -77,6 +77,9 @@
     SOGoMaximumFailedLoginInterval = 900;
     SOGoFailedLoginBlockInterval = 900;
 
+    GCSChannelCollectionTimer = 60;
+    GCSChannelExpireAge = 60;
+
     MySQL4Encoding = "utf8mb4";
   //SOGoDebugRequests = YES;
   //SoDebugBaseURL = YES;