Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 292224 - mail-mta/postfix-2.6.5 init script handles multiple instances incorrectly
Summary: mail-mta/postfix-2.6.5 init script handles multiple instances incorrectly
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Net-Mail Packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 316577
  Show dependency tree
 
Reported: 2009-11-07 07:33 UTC by Michael Orlitzky
Modified: 2012-02-07 12:22 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch for builtin multi-instance support (postfix-initd.patch,1.59 KB, patch)
2010-04-03 21:52 UTC, Michael Orlitzky
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Orlitzky gentoo-dev 2009-11-07 07:33:54 UTC
New to Postfix v2.6.x is multi-instance support[1]. Prior to 2.6, multiple instances had to be managed by hand, and Gentoo had one of the best implementations of this:

1. Users would copy their Postfix config to another directory, say,
   /etc/postfix.new.

2. They would modify /etc/postfix/main.cf, alerting it of the new
   instance.

3. Any necessary modifications were made to the configuration in
   /etc/postfix.new.

4. A new symlink /etc/init.d/postfix.new -> /etc/init.d/postfix was
   created, and the init script would handle the configuration differences
   on its own.

Now, Postfix tries to abstract some of this away behind the 'postmulti' wrapper[2]. Typically, one,

1. Modifies main.cf to add multi-instance support;

2. Creates a new configuration directory, /etc/postfix-new (WARNING: Postfix
   does not like instance names which contain periods. Generally, they can be
   replaced with hyphens);

3. Makes any necessary configuration changes in the new instance.

Other (previously-separate) instances can be imported in to this new framework as well[3].

When the user runs "postfix start", Postfix calls the 'postmulti' wrapper which handles starting all of the instances. In fact, the default implementation will just pass all 'postfix' commands (start, stop, reload) to each instance.

The bug here is that Gentoo's init script still handles multiple instances in the old way. We are backwards-compatible, but if the user sets up multiple instances in the new framework, the init script will still do the following, for example:

  /usr/sbin/postfix -c ${CONF_DIR} start >/dev/null 2>&1

which (explicitly) tells Postfix to start only the instance contained in $CONF_DIR. If there are multiple instances defined using the new framework, they won't be started.

To fix this for the new multi-instance support, the $CONF_DIR parameter can simply be removed. To maintain backwards compatibility, though, we should check that the Postfix init script is called via /etc/init.d/postfix and not /etc/init.d/postfix.new (or whatever the other instance is called). If called via /etc/init.d/postfix, we can skip passing "-c $CONF_DIR"; otherwise, pass it.


References:

[1] ftp://mirrors.loonybin.net/pub/postfix/official/postfix-2.6.5.RELEASE_NOTES

[2] http://www.postfix.org/postmulti.1.html

[3] http://www.postfix.org/MULTI_INSTANCE_README.html
Comment 1 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2010-04-03 21:12:00 UTC
Michael, Did you have a patch available?
Comment 2 Michael Orlitzky gentoo-dev 2010-04-03 21:52:15 UTC
Created attachment 226479 [details, diff]
Patch for builtin multi-instance support

This is the patch I'm running against the init script. Unfortunately, it's not backwards compatible. To move away from the old-style multiple instances, users will have to update a few things manually:

1. Stop everything.

2. Rename the secondary instance config directories so that they don't contain periods. At least when I went through the process, Postfix would barf on instances named e.g. postfix.alt, which was the documented name in previous Gentoo releases. postfix-alt, with a hyphen, works.

3. Import the old instance into the new framework. This is outlined in the MULTI_INSTANCE_README.

4. There is an implied step #4, "fix everything that went wrong." The postmulti import makes some assumptions about your layout. If they weren't correct, main.cf will probably need to be updated. At this point, you should be able to start the instance manually.

5. Optionally enable the new instance and/or add it to a group.


However, it should be possible to make the init script backwards-compatible (completely untested of course):

If CONF_DIR is simply /etc/postfix, avoid passing -c CONF_DIR to all of the invocations in the init script. This works when there is a single instance, since /etc/postfix is the default, and it also works when there are multiple new-style instances, because Postfix handles them automatically.

If CONF_DIR is not /etc/postfix, then the user is using an old-style (Gentoo) multiple instance, and we can safely pass CONF_DIR to all of the commands. Possibly spit out a warning that the user should update his config someday.
Comment 3 Tobias Scherbaum (RETIRED) gentoo-dev 2010-04-04 12:20:16 UTC
As the "new" multiple instances support in Postfix itself is backwards compatible to our "old" multiple instances support i'd like to keep it that way for our 2.6.x series ebuilds.

For the 2.7.x series (which i'll bump to today or tomorrow) i'll include the proposed patch and will submit a news item for review so users get a chance to know about this change before upgrading.
Comment 4 Eray Aslan gentoo-dev 2011-06-15 10:29:20 UTC
+*postfix-2.9_pre20110605 (15 Jun 2011)
+
+  15 Jun 2011; Eray Aslan <eras@gentoo.org> +postfix-2.9_pre20110605.ebuild,
+  +files/postfix.rc6.2.6:
+  Version bump. Add multi instance support.
+

Only lightly tested.  Please test if you can.

As a side note, the postmulti upgrade warning in init script gets old quickly.  Probably best to remove it.
Comment 5 Michael Orlitzky gentoo-dev 2011-06-15 15:10:18 UTC
I don't have any old multi-instance boxes that need converting anymore, but it seems to work fine on the ones that I already switched to the new multi-instance style.
Comment 6 Eray Aslan gentoo-dev 2012-02-07 12:22:07 UTC
Fixed in >=postfix-2.9.0.  Closing.