Skip to content

Commit 527f27d

Browse files
Merge pull request #6632 from mailcow/staging
Update 2025-07
2 parents 1994b98 + 02557b2 commit 527f27d

18 files changed

+1379
-186
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ A big thank you to everyone supporting us on GitHub Sponsors—your contribution
2323
<a href="https://www.maehdros.com/" target=_blank><img
2424
src="https://avatars.githubusercontent.com/u/173894712" height="58"
2525
/></a>
26+
<a href="https://macarne.com/" target=_blank><img
27+
src="https://avatars.githubusercontent.com/u/149550368?s=200&v=4" height="58"
28+
/></a>
2629

2730
### 50$/Month Sponsors
2831
<a href="https://github.com/vnukhr" target=_blank><img

data/Dockerfiles/acme/acme.sh

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,6 @@ while true; do
159159
fi
160160
if [[ ! -f ${ACME_BASE}/acme/account.pem ]]; then
161161
log_f "Generating missing Lets Encrypt account key..."
162-
if [[ ! -z ${ACME_CONTACT} ]]; then
163-
if ! verify_email "${ACME_CONTACT}"; then
164-
log_f "Invalid email address, will not start registration!"
165-
sleep 365d
166-
exec $(readlink -f "$0")
167-
else
168-
ACME_CONTACT_PARAMETER="--contact mailto:${ACME_CONTACT}"
169-
log_f "Valid email address, using ${ACME_CONTACT} for registration"
170-
fi
171-
else
172-
ACME_CONTACT_PARAMETER=""
173-
fi
174162
openssl genrsa 4096 > ${ACME_BASE}/acme/account.pem
175163
else
176164
log_f "Using existing Lets Encrypt account key ${ACME_BASE}/acme/account.pem"
@@ -299,7 +287,7 @@ while true; do
299287
VALIDATED_CERTIFICATES+=("${CERT_NAME}")
300288

301289
# obtain server certificate if required
302-
ACME_CONTACT_PARAMETER=${ACME_CONTACT_PARAMETER} DOMAINS=${SERVER_SAN_VALIDATED[@]} /srv/obtain-certificate.sh rsa
290+
DOMAINS=${SERVER_SAN_VALIDATED[@]} /srv/obtain-certificate.sh rsa
303291
RETURN="$?"
304292
if [[ "$RETURN" == "0" ]]; then # 0 = cert created successfully
305293
CERT_AMOUNT_CHANGED=1

data/Dockerfiles/acme/obtain-certificate.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ until dig letsencrypt.org +time=3 +tries=1 @unbound > /dev/null; do
9393
sleep 2
9494
done
9595
log_f "Resolver OK"
96-
log_f "Using command acme-tiny ${DIRECTORY_URL} ${ACME_CONTACT_PARAMETER} --account-key ${ACME_BASE}/acme/account.pem --disable-check --csr ${CSR} --acme-dir /var/www/acme/"
97-
ACME_RESPONSE=$(acme-tiny ${DIRECTORY_URL} ${ACME_CONTACT_PARAMETER} \
96+
log_f "Using command acme-tiny ${DIRECTORY_URL} --account-key ${ACME_BASE}/acme/account.pem --disable-check --csr ${CSR} --acme-dir /var/www/acme/"
97+
ACME_RESPONSE=$(acme-tiny ${DIRECTORY_URL} \
9898
--account-key ${ACME_BASE}/acme/account.pem \
9999
--disable-check \
100100
--csr ${CSR} \

data/Dockerfiles/dovecot/quarantine_notify.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
from email.mime.text import MIMEText
99
from email.utils import COMMASPACE, formatdate
1010
import jinja2
11-
from jinja2 import Template
11+
from jinja2 import TemplateError
12+
from jinja2.sandbox import SandboxedEnvironment
1213
import json
1314
import redis
1415
import time
@@ -80,17 +81,22 @@ def notify_rcpt(rcpt, msg_count, quarantine_acl, category):
8081
if len(meta_query) == 0:
8182
return
8283
msg_count = len(meta_query)
84+
env = SandboxedEnvironment()
8385
if r.get('Q_HTML'):
84-
try:
85-
template = Template(r.get('Q_HTML'))
86-
except:
87-
print("Error: Cannot parse quarantine template, falling back to default template.")
88-
with open('/templates/quarantine.tpl') as file_:
89-
template = Template(file_.read())
86+
try:
87+
template = env.from_string(r.get('Q_HTML'))
88+
except Exception:
89+
print("Error: Cannot parse quarantine template, falling back to default template.")
90+
with open('/templates/quarantine.tpl') as file_:
91+
template = env.from_string(file_.read())
9092
else:
91-
with open('/templates/quarantine.tpl') as file_:
92-
template = Template(file_.read())
93-
html = template.render(meta=meta_query, username=rcpt, counter=msg_count, hostname=mailcow_hostname, quarantine_acl=quarantine_acl)
93+
with open('/templates/quarantine.tpl') as file_:
94+
template = env.from_string(file_.read())
95+
try:
96+
html = template.render(meta=meta_query, username=rcpt, counter=msg_count, hostname=mailcow_hostname, quarantine_acl=quarantine_acl)
97+
except (jinja2.exceptions.SecurityError, TemplateError) as ex:
98+
print(f"SecurityError or TemplateError in template rendering: {ex}")
99+
return
94100
text = html2text.html2text(html)
95101
count = 0
96102
while count < 15:

data/Dockerfiles/dovecot/quota_notify.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from email.mime.text import MIMEText
77
from email.utils import COMMASPACE, formatdate
88
import jinja2
9-
from jinja2 import Template
9+
from jinja2.sandbox import SandboxedEnvironment
1010
import redis
1111
import time
1212
import json
@@ -33,16 +33,24 @@
3333

3434
if r.get('QW_HTML'):
3535
try:
36-
template = Template(r.get('QW_HTML'))
37-
except:
38-
print("Error: Cannot parse quarantine template, falling back to default template.")
36+
env = SandboxedEnvironment()
37+
template = env.from_string(r.get('QW_HTML'))
38+
except Exception:
39+
print("Error: Cannot parse quota template, falling back to default template.")
3940
with open('/templates/quota.tpl') as file_:
40-
template = Template(file_.read())
41+
env = SandboxedEnvironment()
42+
template = env.from_string(file_.read())
4143
else:
4244
with open('/templates/quota.tpl') as file_:
43-
template = Template(file_.read())
45+
env = SandboxedEnvironment()
46+
template = env.from_string(file_.read())
47+
48+
try:
49+
html = template.render(username=username, percent=percent)
50+
except (jinja2.exceptions.SecurityError, jinja2.TemplateError) as ex:
51+
print(f"SecurityError or TemplateError in template rendering: {ex}")
52+
sys.exit(1)
4453

45-
html = template.render(username=username, percent=percent)
4654
text = html2text.html2text(html)
4755

4856
try:

0 commit comments

Comments
 (0)