From b051870ba4ef76d671d635b12d60d16d61c0533d Mon Sep 17 00:00:00 2001 From: andryyy Date: Wed, 21 Jun 2017 21:39:24 +0200 Subject: [PATCH 1/2] Limit log size as most information is written to Redis --- docker-compose.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 7f5ef447..ec99b8cc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -93,6 +93,9 @@ services: - dkim-vol-1:/data/dkim - rspamd-vol-1:/var/lib/rspamd restart: always + logging: + options: + max-size: "5m" dns: - 172.22.1.254 dns_search: mailcow-network @@ -119,6 +122,9 @@ services: - DBPASS=${DBPASS} - MAILCOW_HOSTNAME=${MAILCOW_HOSTNAME} restart: always + logging: + options: + max-size: "5m" dns: - 172.22.1.254 dns_search: mailcow-network @@ -143,6 +149,9 @@ services: - ./data/conf/sogo/:/etc/sogo/ - ./data/web/thunderbird-plugins:/thunderbird restart: always + logging: + options: + max-size: "5m" dns: - 172.22.1.254 dns_search: mailcow-network @@ -168,6 +177,9 @@ services: - DBNAME=${DBNAME} - DBUSER=${DBUSER} - DBPASS=${DBPASS} + logging: + options: + max-size: "5m" ports: - "${IMAP_PORT:-143}:143" - "${IMAPS_PORT:-993}:993" @@ -204,6 +216,9 @@ services: - "${SMTPS_PORT:-465}:465" - "${SUBMISSION_PORT:-587}:587" restart: always + logging: + options: + max-size: "5m" dns: - 172.22.1.254 dns_search: mailcow-network @@ -250,6 +265,9 @@ services: - ./data/conf/rspamd/dynmaps:/dynmaps:ro - ./data/assets/ssl/:/etc/ssl/mail/:ro - ./data/conf/nginx/:/etc/nginx/conf.d/:rw + logging: + options: + max-size: "5m" ports: - "${HTTPS_BIND:-0.0.0.0}:${HTTPS_PORT:-443}:${HTTPS_PORT:-443}" - "${HTTP_BIND:-127.0.0.1}:${HTTP_PORT:-80}:${HTTP_PORT:-80}" From cbfe5e879e20d7251a68a689f50d90d682c884fa Mon Sep 17 00:00:00 2001 From: andryyy Date: Wed, 21 Jun 2017 23:27:01 +0200 Subject: [PATCH 2/2] Fix error when adding alias with multiple alias addresses --- data/web/inc/functions.mailbox.inc.php | 68 ++++++++++++-------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/data/web/inc/functions.mailbox.inc.php b/data/web/inc/functions.mailbox.inc.php index 7d5f893f..597d9d87 100644 --- a/data/web/inc/functions.mailbox.inc.php +++ b/data/web/inc/functions.mailbox.inc.php @@ -315,10 +315,42 @@ function mailbox($_action, $_type, $_data = null) { ); return false; } + foreach ($gotos as &$goto) { + if (empty($goto)) { + continue; + } + $goto_domain = idn_to_ascii(substr(strstr($goto, '@'), 1)); + $goto_local_part = strstr($goto, '@', true); + $goto = $goto_local_part.'@'.$goto_domain; + $stmt = $pdo->prepare("SELECT `username` FROM `mailbox` + WHERE `kind` REGEXP 'location|thing|group' + AND `username`= :goto"); + $stmt->execute(array(':goto' => $goto)); + $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC)); + if ($num_results != 0) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['goto_invalid']) + ); + return false; + } + if (!filter_var($goto, FILTER_VALIDATE_EMAIL) === true) { + $_SESSION['return'] = array( + 'type' => 'danger', + 'msg' => sprintf($lang['danger']['goto_invalid']) + ); + return false; + } + } + $gotos = array_filter($gotos); + $goto = implode(",", $gotos); foreach ($addresses as $address) { if (empty($address)) { continue; } + if (in_array($address, $gotos)) { + continue; + } $stmt = $pdo->prepare("SELECT `address` FROM `alias` WHERE `address`= :address"); $stmt->execute(array(':address' => $address)); @@ -397,42 +429,6 @@ function mailbox($_action, $_type, $_data = null) { ); return false; } - foreach ($gotos as &$goto) { - if (empty($goto)) { - continue; - } - $goto_domain = idn_to_ascii(substr(strstr($goto, '@'), 1)); - $goto_local_part = strstr($goto, '@', true); - $goto = $goto_local_part.'@'.$goto_domain; - $stmt = $pdo->prepare("SELECT `username` FROM `mailbox` - WHERE `kind` REGEXP 'location|thing|group' - AND `username`= :goto"); - $stmt->execute(array(':goto' => $goto)); - $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC)); - if ($num_results != 0) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['goto_invalid']) - ); - return false; - } - if (!filter_var($goto, FILTER_VALIDATE_EMAIL) === true) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['goto_invalid']) - ); - return false; - } - if ($goto == $address) { - $_SESSION['return'] = array( - 'type' => 'danger', - 'msg' => sprintf($lang['danger']['alias_goto_identical']) - ); - return false; - } - } - $gotos = array_filter($gotos); - $goto = implode(",", $gotos); try { $stmt = $pdo->prepare("INSERT INTO `alias` (`address`, `goto`, `domain`, `active`) VALUES (:address, :goto, :domain, :active)");