Skip to content

Commit 3b8f575

Browse files
committed
migrate legacy postfix mysql query interface to "new" interface
1 parent 09d8e8a commit 3b8f575

16 files changed

+43
-70
lines changed
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
user = {mysql_server_ispconfig_user}
22
password = {mysql_server_ispconfig_password}
33
dbname = {mysql_server_database}
4-
table = mail_access
5-
select_field = access
6-
where_field = source
7-
additional_conditions = and type = 'client' and active = 'y'
8-
hosts = {mysql_server_ip}
4+
hosts = {mysql_server_ip}
5+
query = select access from mail_access where source = '%s' and type = 'client' and active = 'y'
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
user = {mysql_server_ispconfig_user}
22
password = {mysql_server_ispconfig_password}
33
dbname = {mysql_server_database}
4-
table = mail_domain
5-
select_field = domain
6-
where_field = domain
7-
additional_conditions = and active = 'y' and server_id = {server_id}
8-
hosts = {mysql_server_ip}
4+
hosts = {mysql_server_ip}
5+
query = select domain from mail_domain where domain = '%s' and active = 'y' and server_id = {server_id}
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
user = {mysql_server_ispconfig_user}
22
password = {mysql_server_ispconfig_password}
33
dbname = {mysql_server_database}
4-
table = mail_user
5-
select_field = email
6-
where_field = email
7-
additional_conditions = and postfix = 'y' and server_id = {server_id}
8-
hosts = {mysql_server_ip}
4+
hosts = {mysql_server_ip}
5+
query = select email from mail_user where email = '%s' and postfix = 'y' and disabledeliver = 'n' and server_id = {server_id}
6+
union
7+
select cc as email from mail_user where email = '%s' and postfix = 'y' and disabledeliver = 'y' and server_id = {server_id}

install/tpl/mysql-virtual_forwardings.cf.master

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,20 @@ user = {mysql_server_ispconfig_user}
22
password = {mysql_server_ispconfig_password}
33
dbname = {mysql_server_database}
44
hosts = {mysql_server_ip}
5-
query = SELECT u.email as target FROM mail_forwarding as s INNER JOIN mail_user as u ON (u.email = CONCAT('%u@', SUBSTRING_INDEX(s.destination,'@',-1))) WHERE s.source = '@%d' AND s.type = 'aliasdomain' AND s.active = 'y' AND u.disabledeliver = 'n' AND s.server_id = {server_id} UNION SELECT s.destination as target FROM mail_forwarding as s WHERE s.source = '%s' AND s.type IN ('alias', 'forward') and s.active = 'y' AND s.server_id = {server_id} UNION SELECT s.destination as target FROM mail_forwarding as s INNER JOIN mail_forwarding as f ON (f.source = CONCAT('%u@', SUBSTRING_INDEX(s.destination,'@',-1))) WHERE s.source = '@%d' AND s.type = 'aliasdomain' AND s.active = 'y' AND f.active = 'y' AND s.server_id = {server_id} UNION SELECT s.destination as target FROM mail_forwarding as s WHERE s.source = '@%d' AND s.type IN ('catchall') and s.active = 'y' AND s.server_id = {server_id} UNION SELECT s.destination as target FROM mail_forwarding as s INNER JOIN mail_forwarding as t ON (t.source = s.destination AND t.type = 'catchall') WHERE s.source = '@%d' AND s.type = 'aliasdomain' and s.active = 'y' AND t.active = 'y' AND s.server_id = {server_id}
5+
query = SELECT u.email as target FROM mail_forwarding as s
6+
INNER JOIN mail_user as u ON (u.email = CONCAT('%u@', SUBSTRING_INDEX(s.destination,'@',-1)))
7+
WHERE s.source = '@%d' AND s.type = 'aliasdomain' AND s.active = 'y' AND u.disabledeliver = 'n' AND s.server_id = {server_id}
8+
UNION
9+
SELECT s.destination as target FROM mail_forwarding as s
10+
WHERE s.source = '%s' AND s.type IN ('alias', 'forward') and s.active = 'y' AND s.server_id = {server_id}
11+
UNION
12+
SELECT s.destination as target FROM mail_forwarding as s
13+
INNER JOIN mail_forwarding as f ON (f.source = CONCAT('%u@', SUBSTRING_INDEX(s.destination,'@',-1)))
14+
WHERE s.source = '@%d' AND s.type = 'aliasdomain' AND s.active = 'y' AND f.active = 'y' AND s.server_id = {server_id}
15+
UNION
16+
SELECT s.destination as target FROM mail_forwarding as s
17+
WHERE s.source = '@%d' AND s.type IN ('catchall') and s.active = 'y' AND s.server_id = {server_id}
18+
UNION
19+
SELECT s.destination as target FROM mail_forwarding as s
20+
INNER JOIN mail_forwarding as t ON (t.source = s.destination AND t.type = 'catchall')
21+
WHERE s.source = '@%d' AND s.type = 'aliasdomain' and s.active = 'y' AND t.active = 'y' AND s.server_id = {server_id}
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
user = {mysql_server_ispconfig_user}
22
password = {mysql_server_ispconfig_password}
33
dbname = {mysql_server_database}
4-
table = mail_user
5-
select_field = gid
6-
where_field = email
7-
additional_conditions = and postfix = 'y' and server_id = {server_id}
8-
hosts = {mysql_server_ip}
4+
hosts = {mysql_server_ip}
5+
query = select gid from mail_user where email = '%s' and postfix = 'y' and server_id = {server_id}
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
user = {mysql_server_ispconfig_user}
22
password = {mysql_server_ispconfig_password}
33
dbname = {mysql_server_database}
4-
table = mail_user
5-
select_field = CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/')
6-
where_field = login
7-
additional_conditions = and postfix = 'y' and server_id = {server_id}
84
hosts = {mysql_server_ip}
5+
query = select CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/') from mail_user where login = '%s' and postfix = 'y' and server_id = {server_id}

install/tpl/mysql-virtual_outgoing_bcc.cf

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
user = {mysql_server_ispconfig_user}
22
password = {mysql_server_ispconfig_password}
33
dbname = {mysql_server_database}
4-
table = mail_user
5-
select_field = sender_cc
6-
where_field = email
7-
additional_conditions = and postfix = 'y' and disabledeliver = 'n' and disablesmtp = 'n' and sender_cc != ''
8-
hosts = {mysql_server_ip}
4+
hosts = {mysql_server_ip}
5+
query = select sender_cc from mail_user where email = '%s' and postfix = 'y' and disabledeliver = 'n' and disablesmtp = 'n' and sender_cc != ''
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
user = {mysql_server_ispconfig_user}
22
password = {mysql_server_ispconfig_password}
33
dbname = {mysql_server_database}
4+
hosts = {mysql_server_ip}
45
query = SELECT 'greylisting' FROM
56
(SELECT `greylisting`, 1 as `prio` FROM `mail_user` WHERE `server_id` = {server_id} AND `email` = '%s'
67
UNION SELECT `greylisting`, 2 as `prio` FROM `mail_forwarding` WHERE `server_id` = {server_id} AND `source` = '%s'
78
UNION SELECT `greylisting`, 3 as `prio` FROM `mail_forwarding` WHERE `server_id` = {server_id} AND `source` = '@%d' ORDER BY `prio` ASC LIMIT 1) as rules
89
WHERE rules.greylisting = 'y'
9-
10-
hosts = {mysql_server_ip}
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
user = {mysql_server_ispconfig_user}
22
password = {mysql_server_ispconfig_password}
33
dbname = {mysql_server_database}
4-
table = mail_access
5-
select_field = access
6-
where_field = source
7-
additional_conditions = and type = 'recipient' and active = 'y' and server_id = {server_id}
8-
hosts = {mysql_server_ip}
4+
hosts = {mysql_server_ip}
5+
query = select access from mail_access where source = '%s' and type = 'recipient' and active = 'y' and server_id = {server_id}

0 commit comments

Comments
 (0)