From 5d457399e6cb8d3cd95f79ab8260d6b0d97ce1ee Mon Sep 17 00:00:00 2001 From: Sleeps Date: Fri, 12 Jun 2026 14:27:08 +0100 Subject: [PATCH 1/2] Updated virtual_dom_groups Fixed the sql which only ever returned 1 user (on my system anyway) and updated so the fail is handled instantly as the old code continued on to the next router until it hit the catchall.. --- .../router/250_vexim_virtual_domains | 57 +++++++++---------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/docs/debian-conf.d/router/250_vexim_virtual_domains b/docs/debian-conf.d/router/250_vexim_virtual_domains index 5980072..4b4b360 100644 --- a/docs/debian-conf.d/router/250_vexim_virtual_domains +++ b/docs/debian-conf.d/router/250_vexim_virtual_domains @@ -76,39 +76,37 @@ virtual_domains: # then anyone on the internet can write to it # else only members can write to it # -# If not public non member sender will receive a "550 Unknown user" message +# If not public non member sender will receive a "User unknown" message virtual_dom_groups: driver = redirect domains = +local_domains + condition = ${lookup mysql{select count(*) from groups g, domains d \ + where d.enabled = '1' and d.domain = '${quote_mysql:$domain}' and \ + d.domain_id = g.domain_id and g.enabled = '1' and \ + g.name = '${quote_mysql:$local_part}'}{yes}{no}} allow_fail - senders = ${if eq{Y}{${lookup mysql{select g.is_public \ - from groups g, domains d \ - where d.enabled = '1' and d.domain = '${quote_mysql:$domain}' and \ - d.domain_id = g.domain_id and g.enabled = '1' and \ - g.name = '${quote_mysql:$local_part}'}}} \ - {$sender_address} \ - {${lookup mysql{select concat_ws('@', u.localpart, d.domain) \ - from domains d, groups g, group_contents c, users u \ - where d.enabled = '1' and d.domain = '${quote_mysql:$domain}' and \ - d.domain_id = g.domain_id and g.name = '${quote_mysql:$local_part}' and \ - g.enabled = '1' and \ - g.is_public = 'N' and c.member_id = u.user_id and \ - d.domain_id = u.domain_id and u.enabled = '1' \ - and u.username = '${quote_mysql:$sender_address}' limit 1}}}} - data = ${lookup mysql{ \ - select concat_ws('@', u.localpart, d.domain) \ - from domains d, groups g, group_contents c, users u \ - where d.enabled = '1' and \ - d.domain = '${quote_mysql:$domain}' and \ - d.domain_id = g.domain_id and \ - g.enabled = '1' and \ - g.id = c.group_id and \ - c.member_id = u.user_id and \ - d.domain_id = u.domain_id and \ - u.enabled = '1' and \ - g.name = '${quote_mysql:$local_part}'} } - # using local_part_suffixes enables possibility to use user-"something" localparts - # which could cause you trouble if you're creating email-adresses with dashes in between. + data = ${lookup mysql{select \ + case \ + when g.is_public = '1' then \ + (select group_concat(concat_ws('@', u.localpart, dom.domain) separator ',') \ + from group_contents c, users u, domains dom \ + where c.group_id = g.id and c.member_id = u.user_id and \ + u.enabled = '1' and u.domain_id = dom.domain_id and dom.enabled = '1') \ + when exists( \ + select 1 from group_contents c, users u \ + where c.group_id = g.id and c.member_id = u.user_id and \ + u.enabled = '1' and u.username = '${quote_mysql:$sender_address}') \ + then \ + (select group_concat(concat_ws('@', u.localpart, dom.domain) separator ',') \ + from group_contents c, users u, domains dom \ + where c.group_id = g.id and c.member_id = u.user_id and \ + u.enabled = '1' and u.domain_id = dom.domain_id and dom.enabled = '1') \ + else ':fail: User unknown' \ + end \ + from groups g, domains d \ + where d.enabled = '1' and d.domain = '${quote_mysql:$domain}' and \ + d.domain_id = g.domain_id and g.enabled = '1' and \ + g.name = '${quote_mysql:$local_part}'}} .ifdef VEXIM_LOCALPART_SUFFIX local_part_suffix = VEXIM_LOCALPART_SUFFIX local_part_suffix_optional @@ -117,6 +115,7 @@ virtual_dom_groups: reply_transport = address_reply pipe_transport = address_pipe + virtual_domains_catchall: driver = redirect domains = +local_domains From 7a1f2ff3fe4fcd8eb6c004f2ef62f4e56fb2858f Mon Sep 17 00:00:00 2001 From: Sleeps Date: Fri, 12 Jun 2026 14:31:05 +0100 Subject: [PATCH 2/2] Migrate 'is_public' column to use TINYINT in groups --- setup/migrations/migrate-groups-to-use-1-0 | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 setup/migrations/migrate-groups-to-use-1-0 diff --git a/setup/migrations/migrate-groups-to-use-1-0 b/setup/migrations/migrate-groups-to-use-1-0 new file mode 100644 index 0000000..1e59cd5 --- /dev/null +++ b/setup/migrations/migrate-groups-to-use-1-0 @@ -0,0 +1,8 @@ +UPDATE `groups` SET `is_public` = CASE + WHEN `is_public` = 'Y' THEN 1 + WHEN `is_public` = 'N' THEN 0 + ELSE 1 +END; + +ALTER TABLE `groups` +MODIFY COLUMN `is_public` TINYINT(1) NOT NULL DEFAULT 1;