[exim] Re: Debian - dynamic local_domains?

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Jasen Betts
Fecha:  
A: exim-users
Asunto: [exim] Re: Debian - dynamic local_domains?
On 2023-06-24, Ray O'Donnell via Exim-users <exim-users@???> wrote:
> Hello,
>
> I'm new to this list, so apologies if this should be asked elsewhere -
> please point me in the right direction if so.
>
> I run a small email server hosting a number of low-traffic virtual
> domains (Exim + Dovecot). The OS is Debian 10, and Exim was installed
> from the Debian repositories.
>
> I'm using the split configuration option for Exim, and so each domain
> has to be listed manually in /etc/exim4/update-exim4.conf.conf, in
> dc_other_hostnames. When update-exim4.conf is run to generate the main
> Exim configuration file, this list gets put into a macro
> MAIN_LOCAL_DOMAINS, and this in turn gets inserted into local_domains.
>
> In my case the domains and users are stored in a PostgreSQL database, so
> I'm wondering if it's possible to generate local_domains directly from
> the database. I've tried:
>
> (i) Putting this in /etc/exim4/update-exim4.conf.conf:
>
> dc_other_hostnames=${lookup pgsql{select domain_name from domains }}
>
> (ii) Setting MAIN_LOCAL_DOMAINS in
> /etc/exim4/conf.d/main/000_localmacros, which contains various local
> settings:
>
> MAIN_LOCAL_MACROS = ${lookup pgsql{select domain_name from domains }}
>
> However, in both cases I get relay-denied errors when sending email to
> one of the hosted domains.


MAIN_LOCAL_DOMAINS is used to set this domainlist (and not used anywhere else)

   domainlist local_domains = MAIN_LOCAL_DOMAINS

https://www.exim.org/exim-html-current/doc/html/spec_html/ch-domain_host_address_and_local_part_lists.html

says list doamin list expressions are expanded before use, so you are
allowed database lookups here.

you thied this: 

    MAIN_LOCAL_DOMAINS=${lookup pgsql{select domain_name from domains }}

but this expression does not return a list in a form that exim
understands.

Exim separates the rows returned by the query using newlines, but the
domain list wants colons (by default).

try this (which tells exim to expect newlines between entries) instead.

    MAIN_LOCAL_DOMAINS=<\n${lookup pgsql{select domain_name from domains }}

or possibly this (which returns a single row with colons between names)

    MAIN_LOCAL_DOMAINS=${lookup pgsql{select string_agg(domain_name,':') from domains }}

> I could try setting local_domains directly in
> /etc/exim4/conf.d/main/01_exim4-config_listmacrosdefs, but I'm loath to
> do this as it may get clobbered by a package update.


You can create a 00_local_macros file that will not be clobbered by
package updates. (any other filename that doesnt contain "debian" or
"exim" should also be safe)

--
Jasen.
🇺🇦 Слава Україні

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@???
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/