public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Commit
[Web, Postfix] Move TLS policy to mailbox attributes
ab720bf1
data/Dockerfiles/postfix/postfix.sh | 4 ++--
data/web/inc/functions.mailbox.inc.php | 16 ++++++++++------
2 files changed, 12 insertions(+), 8 deletions(-)
Diff
diff --git a/data/Dockerfiles/postfix/postfix.sh b/data/Dockerfiles/postfix/postfix.sh
index 2d3d0e64..88b7b94f 100755
--- a/data/Dockerfiles/postfix/postfix.sh
+++ b/data/Dockerfiles/postfix/postfix.sh
@@ -39,7 +39,7 @@ query = SELECT IF(EXISTS(
SELECT CONCAT('%u', '@', target_domain) FROM alias_domain
WHERE alias_domain='%d'
)
- ) AND json_extract(`attributes`, '$.tls_enforce_in') = '1' AND mailbox.active = '1'
+ ) AND json_extract(attributes, '$.tls_enforce_in') = '1' AND mailbox.active = '1'
), 'reject_plaintext_session', NULL) AS 'tls_enforce_in';
EOF
@@ -58,7 +58,7 @@ query = SELECT GROUP_CONCAT(transport SEPARATOR '') AS transport_maps
WHERE alias_domain = '%d'
)
)
- AND json_extract(`attributes`, '$.tls_enforce_out') = '1'
+ AND json_extract(attributes, '$.tls_enforce_out') = '1'
AND mailbox.active = '1'
), 'smtp_enforced_tls:', 'smtp:') AS 'transport'
UNION ALL
diff --git a/data/web/inc/functions.mailbox.inc.php b/data/web/inc/functions.mailbox.inc.php
index 00d0f99c..f0d10397 100644
--- a/data/web/inc/functions.mailbox.inc.php
+++ b/data/web/inc/functions.mailbox.inc.php
@@ -1154,8 +1154,8 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
try {
$stmt = $pdo->prepare("UPDATE `mailbox` SET `attributes` = JSON_SET(`attributes`, '$.tls_enforce_out', :tls_out), `attributes` = JSON_SET(`attributes`, '$.tls_enforce_in', :tls_in) WHERE `username` = :username");
$stmt->execute(array(
- ':tls_out' => $tls_enforce_out,
- ':tls_in' => $tls_enforce_in,
+ ':tls_out' => intval($tls_enforce_out),
+ ':tls_in' => intval($tls_enforce_in),
':username' => $username
));
}
@@ -2392,7 +2392,7 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
return $mailboxes;
break;
case 'tls_policy':
- $policydata = array();
+ $attrs = array();
if (isset($_data) && filter_var($_data, FILTER_VALIDATE_EMAIL)) {
if (!hasMailboxObjectAccess($_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role'], $_data)) {
return false;
@@ -2402,9 +2402,9 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
$_data = $_SESSION['mailcow_cc_username'];
}
try {
- $stmt = $pdo->prepare("SELECT JSON_EXTRACT(`attributes`, '$.tls_enforce_out') AS `tls_enforce_out`, JSON_EXTRACT(`attributes`, '$.tls_enforce_in') AS `tls_enforce_in` FROM `mailbox` WHERE `username` = :username");
+ $stmt = $pdo->prepare("SELECT `attributes` FROM `mailbox` WHERE `username` = :username");
$stmt->execute(array(':username' => $_data));
- $policydata = $stmt->fetch(PDO::FETCH_ASSOC);
+ $attrs = $stmt->fetch(PDO::FETCH_ASSOC);
}
catch(PDOException $e) {
$_SESSION['return'] = array(
@@ -2413,7 +2413,11 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
);
return false;
}
- return $policydata;
+ $attrs = json_decode($attrs['attributes'], true);
+ return array(
+ 'tls_enforce_in' => $attrs['tls_enforce_in'],
+ 'tls_enforce_out' => $attrs['tls_enforce_out']
+ );
break;
case 'filters':
$filters = array();