Hi guys,

think I found a bug using Ubuntu 16.04, can you confirm this?

what I get in the log:
Jul 3 01:21:40 postfix/cleanup[10334]: warning: mysql query failed: Commands
out of sync; you can't run this command now
Jul 3 01:21:40 postfix/cleanup[10334]: warning:
mysql:/etc/postfix/sql/aliases.cf lookup error for "x...@xxx.xx"
Jul 3 01:21:40 postfix/cleanup[10334]: warning: EF7AE1C0FCE:
virtual_alias_maps map lookup problem for y...@yyy.yy -- message n$

Configuration:
virtual_alias_maps = mysql:/etc/postfix/sql/aliases.cf

and the query in that file:
query = CALL get_aliases_destinations('%u', '%d')

the stored procedure in the database could be as simple as
CREATE PROCEDURE `get_aliases_destinations`(IN user VARCHAR(64), IN domain
VARCHAR(255))
BEGIN
 SELECT CONCAT(destination_username, '@', destination_domain) AS
destinations FROM aliases WHERE source_username = user AND source_domain =
domain AND enabled = true;
END

The bare select itself as query does work fine.
The crucial thing is that x...@xxx.xx already is the alias destination, so the
first query worked fine. In fact postalias -q .... returns valid results.
I believe this occurs because of the mysql library returning an second empty
result set which is not removed/cleared by postfix.
See this discussion which describes a similar issue:
http://stackoverflow.com/questions/6583020/mysql-stored-procedure-caused-com
mands-out-of-sync
I'm not familiar with the postfix sources but I think a possible fix could
be inserted into the plmysql_query function in dict_mysql.c similar to what
is discussed in the link and a dozen similar mysql api issues on the web.

 

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to