LoginSignup
13
13

More than 1 year has passed since last update.

Postfix 2.12 の compatibility_level

Last updated at Posted at 2014-12-16

Postfix Advent Calendar 2014の 16日目の記事です。

Postfix 2.12で追加される(予定)の compatibility_level の話です。

Postfixのバージョンアップ時、パラメータのデフォルト値や挙動が変わる事があります。本来ならばバージョンアップ時はRELEASE_NOTESをよく読んで変更点を確認するべきではあります。しかし、それをおろそかにして痛い目にあった人が多かったのか、Postfix 2.12からcompatibility_levelという機能が追加になります。

Postfixを2.12にバージョンアップした後、設定を変更せずにPostfixを起動すると以下のような警告メッセージが表示されます。

# postfix start
postfix: warning: Postfix is running with backwards-compatible default settings
postfix: warning: See http://www.postfix.org/COMPATIBILITY_README.html for details
postfix: warning: To disable backwards compatibility use "postconf compatibility_level=2" and "postfix reload"
postfix/postfix-script: starting the Postfix mail system

これはmain.cfにcompatibility_levelがセットされていない、もしくは動作しているPostfixのcompatibility_levelより低いため、互換モードで動作している事をあらわしています。
Postfix 2.12 を新規インストールした場合は main.cf にcompatibility_level = 2が設定されているためこの警告メッセージは出ません。
また、互換モードの動作が適用された時にログにも記録されます。以下の例はappend_dot_mydomain=yesが適用された時の物です。

postfix/trivial-rewrite[1233]: using backwards-compatible default setting append_dot_mydomain=yes to rewrite "host" to "host.example.jp"

compatibility_levelで動作が変わる設定

compatibility_levelによって、以下の設定のデフォルトでの動作が変わります。

[main.cf]

  • append_dot_mydomain
compatibility_level デフォルト値
0 yes
1以上 no
  • relay_domains
compatibility_level デフォルト値
1以下 $mydestination
2以上 なし
  • fast_flush_domains

    デフォルト値が $relay_domainsである為relay_domainsの影響を受ける

  • mynetworks_style

compatibility_level デフォルト値
1以下 subnet
2以上 host
  • smtputf8_enable
compatibility_level デフォルト値
0 no
1以上 yes

[master.cf]

  • 各サービスのchroot設定
compatibility_level デフォルト値
0 yes
1以上 no

これらの設定はmain.cfに設定の記述がない時(master.cfのchroot設定は - の時) に適用されます。
main.cfでデフォルト値と同じ値を設定した場合はその値が使われます。

実際のデフォルト値

postconf コマンドで実際のデフォルト値がどのようになっているか見てみます。

% postconf -d append_dot_mydomain
append_dot_mydomain = ${{$compatibility_level} < {1} ? {yes} : {no}}

Postfix 2.12 ではパラメータ展開が拡張されて、以下の形式が増えました。

${name?{value1}:{value2}}
nameが空でない時はvalue1に、空の時はvalue2に展開される
${{value3}=={value4}?{value1}:{value2}}
value3とvalue4を比較し、条件を満たすときはvalue1に、満たさない場合はvalue2に展開される。条件には ==, !=, <, <=, >, >= が使える
つまり`append_dot_mydomain`のデフォルト値は`compatibility_level`が1より小さい時は`yes`に、それ以外の時は`no`になるようにパラメータ展開で設定されています。 パラメータ展開で条件式を使えるようになったのを知った時はどんな使い方をするか疑問だったのですが、こんな所で使われていたんですね。

警告メッセージの抑制方法

compatibility_levelでの警告メッセージを抑制するには、main.cfでcompatibility_levelを設定します。
Postfix 2.12の場合は2を設定します。
当然互換モードは適用されなくなりますので、前述の各パラメータの値を確認し、必要ならば設定を変更しましょう。

将来的のバージョンアップでも警告は必要ない場合はcompatibility_level = 9999を設定します。
この場合「変更はすべて受け入れる」という覚悟も必要です。

13
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
13