Hi Guys,

The dictionary interface to Postgresql found in src/global/dict_pgsql.c
does not support UTF8. It explicitly telles the database that Postfix will
send LATIN1.

With SMTPUTF8 support now in place, Postfix may try to look up addresses
with UTF8 in the local part in PostgreSQL virtual mailbox maps.

Sunch lookups now fail as the UTF8 sent by Postfix is taken as LATIN1 by
PostgreSQL. Error message from Postfix: "Recipient address rejected: User
unknown in virtual mailbox table"

As far as I can see Postfix now wraps all invocations of the Postgresql
dictionary and other dictionaries in a filter that will reject invalid
UTF8.

I suggest the following trivial patch which seems to fix the problem for
me.

Geir Pedersen.


--- foo/postfix-3.3.1/src/global/dict_pgsql.c   2017-12-27
22:53:13.000000000 +0100
+++ postfix-3.3.1/src/global/dict_pgsql.c       2018-08-23
22:09:17.710170053 +0200
@@ -644,15 +644,14 @@
                 host->hostname);

     /*
-     * XXX Postfix does not send multi-byte characters. The following piece
-     * of code is an explicit statement of this fact, and the database
server
-     * should not accept multi-byte information after this point.
+     * Tell PostgreSQL we will send UTF8.
      */
-    if (PQsetClientEncoding(host->db, "LATIN1") != 0) {
-       msg_warn("dict_pgsql: cannot set the encoding to LATIN1, skipping
%s",
-                host->hostname);
-       plpgsql_down_host(host);
-       return;
+
+    if (PQsetClientEncoding(host->db, "UTF8") != 0) {
+      msg_warn("dict_pgsql: cannot set the encoding to UTF8, skipping %s",
+               host->hostname);
+      plpgsql_down_host(host);
+      return;
     }
     /* Success. */
     host->stat = STATACTIVE;

Reply via email to