How to change Postfix config dir without recompilation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

How to change Postfix config dir without recompilation

Boris Rybalkin
Hello,

As I understand from the documentation to change default config dir I
need to use DEF_CONFIG_DIR flag and recompile.
What is the reason to not support ability to change it (cmd param?)
without recomppilation?


--
Boris Rybalkin
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: How to change Postfix config dir without recompilation

Viktor Dukhovni

> On Aug 20, 2017, at 3:25 PM, Boris Rybalkin <[hidden email]> wrote:
>
> As I understand from the documentation to change default config dir I
> need to use DEF_CONFIG_DIR flag and recompile.
> What is the reason to not support ability to change it (cmd param?)
> without recomppilation?

You can override the default configuration directory on the command
line:

        # postfix -c /etc/postfix-foo start|stop|reload|...
        # postqueue -c /etc/postfix-foo -p|-i <id>|-s site|...

However

  * having to do that all the time is a nuisance

  * System start scripts likely don't know about the
    alternate configuration directory.

  * For security reasons the sendmail(1) (really the underlying
    postdrop(1)) command won't accept non-default configuration
    directories that are not "blessed" by the main.cf file
    located in the compile-time default directory.

So, in practice, you really should have a working Postfix configuration
in the default directory.   If you include something along the lines of:

   /etc/postfix/main.cf:
        alternate_config_directories = /etc/postfix-foo

Then the Postfix instance in /etc/postfix-foo can be used as you see
fit.  See MULTI_INSTANCE_README for additional information:

   http://www.postfix.org/MULTI_INSTANCE_README.html

--
        Viktor.

Reply | Threaded
Open this post in threaded view
|

Re: How to change Postfix config dir without recompilation

Boris Rybalkin
I see so it is actually not hard-coded and can be changed if
configured properly.

Thanks

On Sun, Aug 20, 2017 at 8:33 PM, Viktor Dukhovni
<[hidden email]> wrote:

>
>> On Aug 20, 2017, at 3:25 PM, Boris Rybalkin <[hidden email]> wrote:
>>
>> As I understand from the documentation to change default config dir I
>> need to use DEF_CONFIG_DIR flag and recompile.
>> What is the reason to not support ability to change it (cmd param?)
>> without recomppilation?
>
> You can override the default configuration directory on the command
> line:
>
>         # postfix -c /etc/postfix-foo start|stop|reload|...
>         # postqueue -c /etc/postfix-foo -p|-i <id>|-s site|...
>
> However
>
>   * having to do that all the time is a nuisance
>
>   * System start scripts likely don't know about the
>     alternate configuration directory.
>
>   * For security reasons the sendmail(1) (really the underlying
>     postdrop(1)) command won't accept non-default configuration
>     directories that are not "blessed" by the main.cf file
>     located in the compile-time default directory.
>
> So, in practice, you really should have a working Postfix configuration
> in the default directory.   If you include something along the lines of:
>
>    /etc/postfix/main.cf:
>         alternate_config_directories = /etc/postfix-foo
>
> Then the Postfix instance in /etc/postfix-foo can be used as you see
> fit.  See MULTI_INSTANCE_README for additional information:
>
>    http://www.postfix.org/MULTI_INSTANCE_README.html
>
> --
>         Viktor.
>



--
Boris Rybalkin
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: How to change Postfix config dir without recompilation

Viktor Dukhovni

> On Aug 20, 2017, at 4:30 PM, Boris Rybalkin <[hidden email]> wrote:
>
> I see so it is actually not hard-coded and can be changed if
> configured properly.

Well, naturally the "default" is hard-coded, but you can use
other directories explicitly to run *additional* instances of
Postfix.  The primary (default) instance can be used as just
a null-client instance for local mail submission, as commands
that run sendmail(1) to submit email (e.g. cron) won't know
to use some other configuration directory.

See MULTI_INSTANCE_README and the manpages of various
"post*" commands that typically take "-c" arguments:

  * postfix
  * postconf
  * postqueue
  * postsuper

  * postalias
  * postmap
  * postcat
  * postkick
  * postlog
  * posttls-finger

--
        Viktor.

Reply | Threaded
Open this post in threaded view
|

Re: How to change Postfix config dir without recompilation

Boris Rybalkin
Let's say I am packaging all those tools myself and I would like to build a relocatable package, is it possible to not have null-client?

I have a config regeneration tool which will recreate all the configs with a given new config root.

Just to explain why do I need all this.
This is all for syncloud.org open source project where we package popular services (mail, files, social network) for end-user's personal use on single-board computers (at the moment).
So we would like to package with zero paths in binary and be able to change location if needed.

--
Boris Rybalkin
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: How to change Postfix config dir without recompilation

Viktor Dukhovni

> On Aug 20, 2017, at 8:46 PM, Boris Rybalkin <[hidden email]> wrote:
>
> Let's say I am packaging all those tools myself and I would like to build a relocatable package, is it possible to not have null-client?

Will Postfix be responsible for delivering locally generated email
that is injected not via SMTP, but via /usr/sbin/sendmail?  If so,
the sendmail(1) command needs to know where to find the Postfix
configuration files, queue-directory etc.  Various things that
send email (like e.g. cron) will not be passing around a non-default
config directory, and in any case you still typically need the default
configuration directory in order to use (another) (non-default)
configuration directory.

Postfix is not a small relocatable application, it is a system of
multiple interacting components operating at different privilege
levels (including "root" for master(8) and local(8) so it can run
as other users), maintaining state in queue directories, listening
on network ports, ...).

> Just to explain why do I need all this.
> This is all for syncloud.org open source project where we package popular services (mail, files, social network) for end-user's personal use on single-board computers (at the moment).

Postfix should be a core component of the system (even if optional),
that is packaged in a fixed location.

> So we would like to package with zero paths in binary and be able to change location if needed.

A good idea for various software, especially to support concurrent
multiple versions, but Postfix is not the right software for this
type of deployment.

--
        Viktor.
Reply | Threaded
Open this post in threaded view
|

Re: How to change Postfix config dir without recompilation

Boris Rybalkin
As I said it is a package for users to install and use through the UI
and not for sys admins play with the shell :)
I must say dovecot looks like does not even provide a way to change
prefix at runtime.

I have build an isolated Syncloud package (with few paths hard-coded)
so it is not relocatable for now.

I hope things will change over time as zero-deps packages (like snap)
start to spread and people will tend to build less from source code
and these questions will start arising.

In case anyone is interested:
https://github.com/syncloud/3rdparty/tree/master/postfix
https://github.com/syncloud/3rdparty/tree/master/dovecot
https://github.com/syncloud/mail

Thanks

On Mon, Aug 21, 2017 at 2:28 AM, Viktor Dukhovni
<[hidden email]> wrote:

>
>> On Aug 20, 2017, at 8:46 PM, Boris Rybalkin <[hidden email]> wrote:
>>
>> Let's say I am packaging all those tools myself and I would like to build a relocatable package, is it possible to not have null-client?
>
> Will Postfix be responsible for delivering locally generated email
> that is injected not via SMTP, but via /usr/sbin/sendmail?  If so,
> the sendmail(1) command needs to know where to find the Postfix
> configuration files, queue-directory etc.  Various things that
> send email (like e.g. cron) will not be passing around a non-default
> config directory, and in any case you still typically need the default
> configuration directory in order to use (another) (non-default)
> configuration directory.
>
> Postfix is not a small relocatable application, it is a system of
> multiple interacting components operating at different privilege
> levels (including "root" for master(8) and local(8) so it can run
> as other users), maintaining state in queue directories, listening
> on network ports, ...).
>
>> Just to explain why do I need all this.
>> This is all for syncloud.org open source project where we package popular services (mail, files, social network) for end-user's personal use on single-board computers (at the moment).
>
> Postfix should be a core component of the system (even if optional),
> that is packaged in a fixed location.
>
>> So we would like to package with zero paths in binary and be able to change location if needed.
>
> A good idea for various software, especially to support concurrent
> multiple versions, but Postfix is not the right software for this
> type of deployment.
>
> --
>         Viktor.



--
Boris Rybalkin
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: How to change Postfix config dir without recompilation

Viktor Dukhovni
On Mon, Aug 21, 2017 at 10:52:25PM +0100, Boris Rybalkin wrote:

> As I said it is a package for users to install and use through the UI
> and not for sys admins play with the shell :)

Whether administration is through a Web interface, or interactive,
Postfix is still a very much a system compontent, and not designed
a relocatable application.

Modern Postfix builds look for dynamicmaps.cf in a fixed location,
the default main.cf is still used when authorizing local submission
via non-default instances (configuration directories).

>
> I hope things will change over time as zero-deps packages (like snap)
> start to spread and people will tend to build less from source code
> and these questions will start arising.

The Postfix installation location need to be known at compile time.
I don't expect this to change any time soon.

--
        Viktor.