Jailのクリーンブート/シャットダウンのためにRCフレームワークを改良しました

修正

#jail_example_exec_start="/bin/sh /etc/rc"
command to execute in jail for starting
#jail_example_exec_stop="/bin/sh /etc/rc.shutdown"
command to execute in jail for stopping

commit log

Improve the RC framework for the clean booting/shutdown of Jails:
Jailのクリーンブート/シャットダウンのためにRCフレームワークを改良しました:

  1. Feature: for flexibility reasons and as a prerequisite to clean shutdowns, allow the configuration of a stop/shutdown command via rc.conf variable "jail__exec_stop" in addition to the start/boot command (rc.conf variable "jail__exec_start"). For backward compatibility reasons, rc.conf variable "jail__exec" is still supported, too.
    特徴:柔軟性のために、そしてクリーンシャットダウンを行なうのに不可欠であるために、start/bootコマンド(rc.conf変数「jail__exec_start」)に加えて、rc.conf変数「jail__exec_stop」によってstop/shutdownコマンドの設定を認めました。後方互換性により、rc.conf変数「jail__exec」はまだ同じようにサポートされています。
  2. Debug: Add the used boot/shutdown commands to the debug output of the /etc/rc.d/jail script, too.
    デバッグ:/etc/rc.d/jailスクリプトのdebug出力に使用されたboot/shutdownコマンドをまた加えました。
  3. Security: Run the Jail start/boot command in a cleaned environment to not leak information from the host to the Jail during startup.
    セキュリティ:スタートアップ時にホストからJailに情報を漏らさないためにクリーンにした環境(変数)でJail start/bootコマンドを実行します。
  4. Feature: Run the Jail stop/shutdown command "jail__exec_stop" on "/etc/rc.d/jail stop " to allow a graceful shutdown of the Jail before its processes are just killed.
    特徴:プロセスが殺される前にJailを礼儀正しくシャットダウンさせるために「/etc/rc.d/jail stop 」でJail boot/shutdownコマンド「jail__exec_stop」を実行します。
  5. Bugfix: When killing the remaining Jail processes give the processes time to actually perform their termination sequence. Without this the subsequent umount(8) operations usually fail because the resources are still in use. Additionally, if after trying to TERM-inate the processes there are still processes hanging around, finally just KILL them.
    バグフィクス:残っているJailプロセスを殺すとき、それらの終了工程を実際に実行するためのプロセスタイムを与えます。リソースがまだ使用中であるので通常失敗するその後のumount(8)操作はこれには含まれません。さらに、もしまだプロセスがあってプロセスの終了(TERMシグナル)を後に試みた場合、最終的にまさしくKILLします。
  6. Bugfix: In rc.shutdown, if running inside a Jail, skip the /etc/rc.d/* scripts which are flagged with the KEYWORD "nojail" to allow the correct operation of rc.shutdown under jail__exec_stop="/bin/sh /etc/rc.shutdown". This is analogous to what /etc/rc does inside a Jail.
    バグフィクス:rc.shutdownにおいて、Jail内では、jail__exec_stop="/bin/sh /etc/rc.shutdown"の下でrc.shutdownの正確なオペレーションを行なうためにキーワード「nojail」フラグが立っている/etc/rc.d/*スクリプトをスキップします。これは、/etc/rcがJail内で行うことと類似しています。

Now the following typical host-configuration for two Jails works as expected and correctly boots and shutdowns the Jails:
予想されるように2個のJails機構のための以下の典型的なホスト設定はJailsを正しくブートとシャットダウンします:

#  /etc/rc.conf:
jail_enable="YES"
jail_list="foo bar"
jail_foo_rootdir="/j/foo"
jail_foo_hostname="foo.example.com"
jail_foo_ip="192.168.0.1"
jail_foo_devfs_enable="YES"
jail_foo_mount_enable="YES"
jail_foo_exec_start="/bin/sh /etc/rc"
jail_foo_exec_stop="/bin/sh /etc/rc.shutdown"
jail_bar_rootdir="/j/bar"
jail_bar_hostname="bar.example.com"
jail_bar_ip="192.168.0.2"
jail_bar_devfs_enable="YES"
jail_bar_mount_enable="YES"
jail_bar_exec_start="/path/to/kjailer -v"
jail_bar_exec_stop="/bin/sh -c 'killall kjailer && sleep 60'"
#  /etc/fstab.foo
/v/foo /j/foo/v/foo nullfs rw 0 0
#  /etc/fstab.bar
/v/bar /j/bar/v/bar nullfs rw 0 0
Reviewed by
freebsd-hackers
MFC after
2 weeks

$FreeBSD: src/etc/defaults/rc.conf,v 1.234 2004/12/14 14:36:35 rse Exp $
$FreeBSD: src/etc/defaults/rc.conf,v 1.212.2.8 2004/12/28 10:43:33 rse Exp $