Skip to content

Commit 3e2de93

Browse files
fix: $myhostname.localhost virtual mailbox domain
- Ensure double-bounces originate from a valid DNS name. Some sites check whether the domain part of the address resolves via DNS. We use double-bounce@$myhostname for this purpose. - Use a fictional internal routing domain name, $myhostname.localhost, where POSTFIX_ORIGIN was previously used. This simplifies configuration scenarios where the LDAP user domain is also a mail domain. We assume $myhostname.localhost is never used as a mail domain, since it cannot be registered in DNS and .localhost is reserved by RFC 2606. - Update the test suite to expect a slightly different error message when the user domain is not accessible. Remove the user_domain test suite, as that scenario no longer occurs.
1 parent 68c80d6 commit 3e2de93

File tree

14 files changed

+28
-364
lines changed

14 files changed

+28
-364
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,12 @@ For instance, to speed up testing on a local machine:
289289
installation steps. The `--variable` option is required to find the
290290
existing Mail instance.
291291

292-
SSH_KEYFILE=~/.ssh/id_ecdsa bash test-module.sh 10.5.4.1 ghcr.io/nethserver/mail:bug-6977 --exclude udomORremove --variable MID:mail1
292+
SSH_KEYFILE=~/.ssh/id_ecdsa bash test-module.sh 10.5.4.1 ghcr.io/nethserver/mail:bug-6977 --exclude udomORmodule --variable MID:mail1
293293

294294
3. Select a subset of tests and suite with `--include`, `--test`, or
295295
`--suite` flags. For example, run only the SMTP test suite:
296296

297-
SSH_KEYFILE=~/.ssh/id_ecdsa bash test-module.sh 10.5.4.1 ghcr.io/nethserver/mail:bug-6977 --exclude udomORremove --variable MID:mail1 --suite smtp
297+
SSH_KEYFILE=~/.ssh/id_ecdsa bash test-module.sh 10.5.4.1 ghcr.io/nethserver/mail:bug-6977 --exclude udomORmodule --variable MID:mail1 --suite smtp
298298

299299
## Migration from nethserver-mail (NS7)
300300

postfix/README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ Standard public TCP ports
3030
- `POSTFIX_TRUSTED_NETWORK`. Added to Postfix [mynetworks](https://www.postfix.org/postconf.5.html#mynetworks)
3131
- `POSTFIX_HOSTNAME`. Value for Postfix
3232
[myhostname](https://www.postfix.org/postconf.5.html#myhostname).
33-
- `POSTFIX_ORIGIN`. User domain name set as mailbox domain, also appended
34-
to unqualified user names by the trivial-rewrite process. See Postfix
35-
[virtual_mailbox_domains](https://www.postfix.org/postconf.5.html#virtual_mailbox_domains)
36-
and [myorigin](https://www.postfix.org/postconf.5.html#myorigin).
33+
- `POSTFIX_ORIGIN`. Selected user domain -- Not used by Postfix any more. Still used by APIs.
3734
- `POSTFIX_LDAP_HOST`, eg `127.0.0.1`
3835
- `POSTFIX_LDAP_PORT`, eg `389`
3936
- `POSTFIX_LDAP_USER`, bind DN, eg `uid=ldapservice,dc=directory,dc=nh`

postfix/etc/postfix/alias-access-check.cf

Lines changed: 0 additions & 23 deletions
This file was deleted.

postfix/etc/postfix/dovecot-sasl.cf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@
55
smtpd_sasl_type = dovecot
66
smtpd_sasl_path = /var/lib/umail/auth
77
smtpd_sasl_security_options = noanonymous
8-
smtpd_sasl_local_domain = $myorigin

postfix/etc/postfix/pcdb-init.sql

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,11 @@ CREATE TABLE domains (
2424
-- transport rules.
2525
addusers INT DEFAULT 0,
2626
-- if set to 1, the domain accepts additional user addresses like
27-
-- user@domain. The address is rewritten to user@$myorigin. See
28-
-- POSTFIX_ORIGIN in the README.
27+
-- user@domain.
2928
addgroups INT DEFAULT 0,
3029
-- if set to 1, the domain accepts additional group addresses like
3130
-- group@domain. The group members list is retrieved from LDAP and
32-
-- the address is rewritten to user1, user2, user3, etc. See
33-
-- POSTFIX_ORIGIN in the README.
31+
-- the address is rewritten to user1, user2, user3, etc.
3432
catchall TEXT DEFAULT NULL,
3533
-- fallback rewrite rule for addresses that do not match any record in
3634
-- the "destmap" table. It can be a virtual mailbox name.

postfix/usr/local/bin/reload-config

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,44 +37,22 @@ fi
3737

3838
S='$' # to escape $ in template
3939

40-
if [ -n "${POSTFIX_ORIGIN}" ]; then
41-
tmpl_virtual_mailbox_domains=${POSTFIX_ORIGIN}
42-
tmpl_virtual_mailbox_maps="inline:{{ vmail@${POSTFIX_ORIGIN} = vmail }}, "'proxy:ldap:$meta_directory/laddusers-origin.cf'
43-
tmpl_myorigin=${POSTFIX_ORIGIN}
44-
tmpl_verify_recipient_address="check_recipient_access inline:{{ ${POSTFIX_ORIGIN} = reject_unverified_recipient }}"
45-
else
46-
tmpl_virtual_mailbox_domains=
47-
tmpl_virtual_mailbox_maps=
48-
tmpl_myorigin='$myhostname'
49-
tmpl_verify_recipient_address=
50-
fi
40+
tmpl_myhostname="${POSTFIX_HOSTNAME:-$(hostname -f)}"
41+
tmpl_vdomain="${tmpl_myhostname}.localhost"
42+
tmpl_virtual_mailbox_domains="${tmpl_vdomain}"
43+
tmpl_virtual_mailbox_maps="inline:{{ vmail@${tmpl_vdomain} = vmail }}, "'proxy:ldap:$meta_directory/laddusers-origin.cf'
44+
tmpl_verify_recipient_address="check_recipient_access inline:{{ ${tmpl_vdomain} = reject_unverified_recipient }}"
45+
5146

5247
tmpl_milters="${POSTFIX_MILTERS}"
5348
tmpl_mynetworks="127.0.0.1/32 ${POSTFIX_TRUSTED_NETWORK}"
54-
tmpl_myhostname="${POSTFIX_HOSTNAME:-$(hostname -f)}"
5549
tmpl_debug_peer_list="${POSTFIX_DEBUG_PEERS:-\$mynetworks}"
5650
tmpl_relay_domains=$(pcdbquery "SELECT group_concat(domain || '=' || transport) FROM domains WHERE transport LIKE '_mtp:%'")
57-
tmpl_virtual_alias_domains=$(pcdbquery "SELECT group_concat(domain) FROM domains WHERE transport IS NULL AND domain NOT IN ('*', '${POSTFIX_ORIGIN}')")
58-
origin_flags="$(pcdbquery "SELECT addusers + (addgroups * 2) AS origin_flags FROM domains WHERE domain='${POSTFIX_ORIGIN}'")"
59-
if [ "${origin_flags}" == 1 ]; then
60-
# addusers flag: reject groups and vmail, accept users and aliases
61-
tmpl_reject_internal_myorigin="check_recipient_access inline:{{ vmail@${POSTFIX_ORIGIN} = REJECT access denied }}",'check_recipient_access pipemap:{sqlite:$meta_directory/alias-access-check.cf,proxy:ldap:$meta_directory/laddgroupmembers.cf,static:{REJECT access denied}}'
62-
elif [ "${origin_flags}" == 2 ]; then
63-
# addgroups flag: reject users and vmail, accept groups and aliases
64-
tmpl_reject_internal_myorigin="check_recipient_access inline:{{ vmail@${POSTFIX_ORIGIN} = REJECT access denied }}",'check_recipient_access pipemap:{sqlite:$meta_directory/alias-access-check.cf,proxy:ldap:$meta_directory/laddusers-origin.cf,static:{REJECT access denied}}'
65-
elif [ "${origin_flags}" == 3 ]; then
66-
# addusers+addgroups flag: reject vmail only, accept everything else
67-
tmpl_reject_internal_myorigin="check_recipient_access inline:{{ vmail@${POSTFIX_ORIGIN} = REJECT access denied }}"
68-
elif [ "${origin_flags}" == 0 ]; then
69-
# domain has no flags: reject users, groups, and vmail, accept aliases
70-
tmpl_reject_internal_myorigin="check_recipient_access inline:{{ vmail@${POSTFIX_ORIGIN} = REJECT access denied }}",'check_recipient_access pipemap:{sqlite:$meta_directory/alias-access-check.cf,unionmap:{proxy:ldap:$meta_directory/laddusers-origin.cf,proxy:ldap:$meta_directory/laddgroupmembers.cf},static:{REJECT access denied}}'
71-
else
72-
# reject everything because the domain not defined
73-
tmpl_reject_internal_myorigin="check_recipient_access inline:{{ ${POSTFIX_ORIGIN} = REJECT access denied }}"
74-
fi
75-
tmpl_domain_catchall_map=$(pcdbquery "SELECT 'inline:{' || group_concat('{@' || domain || '=' || catchall || '@${tmpl_myorigin}}', ', ') || '}' FROM domains WHERE length(catchall) > 0 AND domain != '*'")
76-
tmpl_laddgroups_domains=$(pcdbquery "SELECT group_concat(domain, ' ') FROM (SELECT domain FROM domains WHERE addgroups = 1 UNION SELECT '${POSTFIX_ORIGIN}' AS domain)")
77-
tmpl_laddusers_domains=$(pcdbquery "SELECT group_concat(domain, ' ') FROM (SELECT domain FROM domains WHERE addusers = 1 UNION SELECT '${POSTFIX_ORIGIN}' AS domain)")
51+
tmpl_virtual_alias_domains=$(pcdbquery "SELECT group_concat(domain) FROM domains WHERE transport IS NULL AND domain != '*'")
52+
tmpl_reject_internal_myorigin="check_recipient_access inline:{{ ${tmpl_vdomain} = REJECT access denied }}"
53+
tmpl_domain_catchall_map=$(pcdbquery "SELECT 'inline:{' || group_concat('{@' || domain || '=' || catchall || '@${tmpl_vdomain}}', ', ') || '}' FROM domains WHERE length(catchall) > 0 AND domain != '*'")
54+
tmpl_laddgroups_domains=$(pcdbquery "SELECT group_concat(domain, ' ') FROM (SELECT domain FROM domains WHERE addgroups = 1 UNION SELECT '${tmpl_vdomain}' AS domain)")
55+
tmpl_laddusers_domains=$(pcdbquery "SELECT group_concat(domain, ' ') FROM (SELECT domain FROM domains WHERE addusers = 1 UNION SELECT '${tmpl_vdomain}' AS domain)")
7856
tmpl_ldap_bind_dn="${POSTFIX_LDAP_USER}"
7957
tmpl_ldap_bind_pw="${POSTFIX_LDAP_PASS}"
8058
tmpl_ldap_host="${POSTFIX_LDAP_HOST}"
@@ -100,7 +78,7 @@ envsubst >/etc/postfix/laddusers.cf <"${TEMPLATES_DIR:?}/laddusers-${ldap_schema
10078
envsubst >/etc/postfix/userforwards.cf <"${TEMPLATES_DIR:?}/userforwards.cf"
10179
envsubst >/etc/postfix/laddgroupmembers.cf <"${TEMPLATES_DIR:?}/laddgroupmembers-${ldap_schema}.cf"
10280
envsubst <"${TEMPLATES_DIR:?}/laddusers-${ldap_schema}.cf" | \
103-
sed "s/^domain = .*/domain = ${tmpl_myorigin}/ ; /^# just/ d" >/etc/postfix/laddusers-origin.cf
81+
sed "s/^domain = .*/domain = ${tmpl_vdomain}/ ; /^# just/ d" >/etc/postfix/laddusers-origin.cf
10482

10583
if [ -z "${tmpl_sasl_commentout}" ] ; then
10684
cat /etc/postfix/dovecot-sasl.cf >> /etc/postfix/main.cf

postfix/usr/local/lib/templates/laddgroupmembers-ad.cf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ query_filter = (&(objectClass=group)(sAMAccountName=%u)(groupType:1.2.840.113556
1313
result_attribute = sAMAccountName
1414
special_result_attribute = member
1515
leaf_result_attribute = sAMAccountName
16-
domain = ${tmpl_laddgroups_domains} notempty.invalid
16+
domain = ${tmpl_laddgroups_domains}

postfix/usr/local/lib/templates/laddgroupmembers-rfc2307.cf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ server_port = ${tmpl_ldap_port}
1111
search_base = ${tmpl_ldap_base}
1212
query_filter = (&(objectClass=posixGroup)(cn=%u))
1313
result_attribute = memberUid
14-
domain = ${tmpl_laddgroups_domains} notempty.invalid
14+
domain = ${tmpl_laddgroups_domains}

postfix/usr/local/lib/templates/laddusers-ad.cf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ server_port = ${tmpl_ldap_port}
1111
search_base = ${tmpl_ldap_base}
1212
query_filter = (&(objectClass=user)(objectCategory=person)(sAMAccountName=%u))
1313
result_attribute = sAMAccountName
14-
domain = ${tmpl_laddusers_domains} notempty.invalid
14+
domain = ${tmpl_laddusers_domains}

postfix/usr/local/lib/templates/laddusers-rfc2307.cf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ server_port = ${tmpl_ldap_port}
1111
search_base = ${tmpl_ldap_base}
1212
query_filter = (&(objectClass=posixAccount)(objectClass=inetOrgPerson)(uid=%u))
1313
result_attribute = uid
14-
domain = ${tmpl_laddusers_domains} notempty.invalid
14+
domain = ${tmpl_laddusers_domains}

0 commit comments

Comments
 (0)