Different realm for different listeners?

Chris Adams cma at cmadams.net
Fri Mar 13 14:56:51 UTC 2015


Once upon a time, Chris Adams <cma at cmadams.net> said:
> All my users are in MySQL.  Reading the docs, I see that "%l" expands to
> the local IP address "almost everywhere".  If that's available in the
> userdb SQL expansion, I could write a (somewhat convoluted) SQL
> statement that adds a domain based on the local IP.  Does that sound
> like it'll work?  Not quite as "elegant" as just setting
> auth_default_realm in separate listeners, but should work I guess.

Just a follow-up for the archives: this worked.  This is my
MySQL password_query:

password_query = \
        SELECT username AS user, password, \
        concat('/srv/mail/',maildir) AS userdb_home, 1000 AS userdb_uid, \
        1000 AS userdb_gid \
        FROM mailbox WHERE active = 1 AND username = case \
          when '%d' <> '' then '%u' \
          when '%l' = '10.0.9.73' then '%u at domain1.com' \
          when '%l' = '10.0.9.74' then '%u at domain2.net' \
          else '%u' end

-- 
Chris Adams <cma at cmadams.net>


More information about the dovecot mailing list