Once upon a time, Chris Adams <cma@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@domain1.com'
when '%l' = '10.0.9.74' then '%u@domain2.net'
else '%u' end
-- Chris Adams <cma@cmadams.net>