窓使いの憂鬱 から YAMY に切り替えた

会社での話。
PCリプレースで WinXP から Win7 になったので窓使いの憂鬱が使えなくなって困っていた。
いろいろ代替案を探した結果、そのまま窓使いの憂鬱の設定ファイルを使えるYAMY(Yet Another Mado tsukai no Yuutsu)という窓使いの憂鬱の派生ソフトがあった…。灯台下暗し。
いまのところ窓使いの憂鬱と変わらない使用感で快適。

Tinderbox環境構築

Tinderbox User Guide を参考に作業を実施する。

Tinderbox用のjail作成

ezjail-adminを使用して作った。

$ sudo ezjail-admin create -f basic tinderbox.dip.jp 192.168.11.5

以下の作業は、このjail内で行った。

Perl5.8のインストール

jail$ cd /usr/ports/lang/perl5.8
jail$ sudo make install clean

MySQL5.5のインストール

jail$ cd /usr/ports/databases/mysql55-server
jail$ sudo make install clean

MySQL設定ファイルの配置と起動

jail$ sudo cp /usr/local/share/mysql/my-medium.cnf /usr/local/etc/my.cnf
jail$ sudo /usr/local/etc/rc.d/mysql-server forcestart

DBD::mysqlのインストール

jail$ cd /usr/ports/databases/p5-DBD-mysql55
jail$ sudo make install clean

まだ途中。webインタフェース入れないつもりなので、PHP関連のインストールは飛ばす。
404 Not Foundから再開する予定。

2011/03/03 再開。

Tinderboxyを展開

ダウンロードしたtinderboxを展開する。

jail$ sudo mkdir -p /tinderbox/scripts
jail$ sudo tar zxf ~/tinderbox-3.3.tar.gz -C /tinderbox/scripts/
jail$ sudo mv tinderbox-3.3/.* .
jail$ sudo mv tinderbox-3.3/* .
jail$ sudo rmdir tinderbox-3.3

tcコマンドを実行

jail$ cd /tinderbox/scripts/

以下のtcスクリプトを実行すると、何やら対話型のインストールが始まった
jail$ sudo ./tc Setup

Welcome to the Tinderbox Setup script.  This script will guide you through
some of the automated Tinderbox setup steps.  Once this script completes ,
you should review the documentation in /tinderbox/scripts/README or on the
web at http://tinderbox.marcuscom.com/ to complete your setup.

Hit <ENTER> to get started:
INFO: Checking prerequisites ...
WARN: The following option dependencies are missing.  These are required to
use the Tinderbox web front-ends.
WARN:   lang/php[45] databases/pear-MDB2 www/php[45]-session
DONE.

INFO: Creating default configuration files ...
DONE.

INFO: Beginning database configuration.
Enter database driver (mysql pgsql): mysql
Does this host have access to connect to the Tinderbox database as a database administrator? (y/N)y
Enter database admin user [root]:
Enter database host [localhost]:
Enter database name [tinderbox]:
Are these settings corrrect:
    Database Administrative User : root
    Database Host                : localhost
    Database Name                : tinderbox
(y/N)
Do you want to cache root's password, and pass it to subsequent database command calls (note: this presents a security risk) (y/N) ?y
Enter root's password : 
Confirm password for root : 
INFO: Checking for prerequisites for mysql database driver ...
ERROR: The following mandatory dependencies are missing.  These must be
installed prior to creating the Tinderbox database.
ERROR:      databases/p5-DBD-mysql[456][01] databases/mysql[456][01]-client
ERROR: Error creating the new database!  Consult the output above for more
information.

MySQLドライバとクライアントの依存チェックで失敗した。。。
databases/p5-DBD-mysql55 databases/mysql55-clientをインストールしたが、databases/p5-DBD-mysql[456][01] databases/mysql[456][01]-clientでなければならない模様…。

間違ってインストールしてしまったportsをアンインストール

p5-DBD-mysql55のアンインストール
jail$ cd /usr/ports/databases/p5-DBD-mysql55/
jail$ sudo make deinstall
===>  Deinstalling for databases/p5-DBD-mysql55
===>   Deinstalling p5-DBD-mysql55-4.017

MySQL5.5のアンインストール
jail$ cd /usr/ports/databases/mysql55-server
jail$ sudo make deinstall
===>  Deinstalling for databases/mysql55-server
===>   Deinstalling mysql-server-5.5.8

mysql55-clientのアンインストール
jail$ cd /usr/ports/databases/mysql55-client
jail$ sudo make deinstall
===>  Deinstalling for databases/mysql55-client
===>   Deinstalling mysql-client-5.5.8

databases/mysql50-serverのインストール

jail$ cd /basejail/usr/ports/databases/mysql50-server
jail$ sudo make install clean

疲れた。風呂入る。。
続きはDBD::mysqlMySQLクライアントのインストールから。

databases/p5-DBD-mysql50のインストール

jail$ cd /usr/ports/databases/p5-DBD-mysql50
jail$ sudo make install clean

databases/mysql50-clientのインストール

databases/mysql50-serverのインストール時に一緒に入るぽい。

tcコマンドを実行 (2回目)

jail$ cd /tinderbox/scripts/

jail$ sudo ./tc Setup

Welcome to the Tinderbox Setup script.  This script will guide you through
some of the automated Tinderbox setup steps.  Once this script completes ,
you should review the documentation in /tinderbox/scripts/README or on the
web at http://tinderbox.marcuscom.com/ to complete your setup.
Hit <ENTER> to get started:
INFO: Checking prerequisites ...
WARN: The following option dependencies are missing.  These are required to
use the Tinderbox web front-ends.
WARN:   lang/php[45] databases/pear-MDB2 www/php[45]-session
DONE.

INFO: Creating default configuration files ...
DONE.

INFO: Beginning database configuration.
Enter database driver (mysql pgsql): mysql
Does this host have access to connect to the Tinderbox database as a database administrator? (y/N)y
Enter database admin user [root]:
Enter database host [localhost]:
Enter database name [tinderbox]:
Are these settings corrrect:
    Database Administrative User : root
    Database Host                : localhost
    Database Name                : tinderbox
(y/N)y
Do you want to cache root's password, and pass it to subsequent database command calls (note: this presents a security risk) (y/N) ?y
Enter root's password :
Confirm password for root :
INFO: Checking for prerequisites for mysql database driver ...
WARN: The following option dependencies are missing.  These are required to
use the Tinderbox web front-end.
WARN:      databases/php5-mysql
DONE.

Enter the desired username for the Tinderbox database : tinderboxuser
Enter the desired password for tinderboxuser :
Confirm password for tinderboxuser :
Are these the settings you want:
    Database username      : tinderboxuser
    Database user password : ****
(y/N) y
INFO: Checking to see if database tinderbox already exists on localhost ...
INFO: Database tinderbox does not exist.  Creating tinderbox on localhost ...
INFO: Creating user tinderboxuser on host localhost (if required) ...
DONE.

INFO: Loading Tinderbox schema into tinderbox ...
INFO: Adding permissions to tinderbox for tinderboxuser ...
DONE.

INFO: Database configuration complete.

Congratulations!  The scripted portion of Tinderbox has completed successfully.
You should now verify the settings in /tinderbox/scripts/tinderbox.ph are
correct for your environment, then run "/tinderbox/scripts/tc init" to complete
the setup.  Be sure to checkout http://tinderbox.marcuscom.com/ for further
instructions.

今度は無事にインストールされた模様。
まだ途中。つづきはまたこんどやる。

tinderbox.ph の編集

適当。

jail$ cd /tinderbox/scripts
jail$ sudo vi tinderbox.ph
#$TINDERBOX_HOST         = 'http://tinderbox.example.com';
$TINDERBOX_HOST  = 'http://tinderbox.dip.jp';

tc init の実行

jail$ cd /tinderbox/scripts
jail$ sudo ./tc init
Enter a default cvsup host [cvsup18.FreeBSD.org]: 
Enter a default update type or command [CSUP]: 
Default update host and type have been set.  These can be changed later by
modifying /tinderbox/scripts/etc/env/GLOBAL.

ftp/lftp のインストール

jail$ cd /usr/ports/ftp/lftp
jail$ sudo make install clean

jailの作成

Tinderboxにおけるjailは特定バージョンのFreeBSDに過ぎない。
ここでは jail として 7.3-RELEASE を指定した。

jail$ cd /tinderbox/scripts
jail$ sudo ./tc createJail -j 7.3 -d "FreeBSD 7.3-RELEASE" -t 7.3-RELEASE -u LFTP -H ftp.freebsd.org
7.3: initializing tree
7.3: creating top-level directory
7.3: adding to datastore... done.
7.3: initializing new jail...
7.3: updating jail with LFTP
7.3: cleaning out /tinderbox/jails/7.3/obj
7.3: cleaning out /tinderbox/jails/7.3/tmp
7.3: creating tarball
7.3: cleaning out /tinderbox/jails/7.3/tmp
7.3: cleaning out /tinderbox/jails/7.3/obj
Cleaning up after Jail creation.  Please be patient.

結構時間が掛かるので、気長に待つ。

PortsTree の作成

jail$ cd /tinderbox/scripts
jail$ sudo ./tc createPortsTree -p FreeBSD -d "FreeBSD ports tree" -w http://www.freebsd.org/cgi/cvsweb.cgi/ports/
FreeBSD: initializing tree
FreeBSD: creating top-level directory
FreeBSD: adding to datastore... done.
FreeBSD: updating portstree with CSUP

Buildの作成

Buildはjailとportのマッピングのこと。

jail$ cd /tinderbox/scripts
jail$ sudo ./tc createBuild -b 7.3-FreeBSD -j 7.3 -p FreeBSD -d "7.3-RELEASE with FreeBSD ports tree"
Password:
7.3-FreeBSD: cleaning out /tinderbox/7.3-FreeBSD
7.3-FreeBSD: cleaning out /tinderbox/builds/7.3-FreeBSD
7.3-FreeBSD: adding Build to datastore... done.

ログの設定

jail$ cd /tinderbox/scripts
jail$ sudo ./tc configLog -d /tinderbox/logs

DBにportを登録

jail$ cd /tinderbox/scripts
jail$ sudo ./tc addPort -b 7.3-FreeBSD -d shells/bash

試しに shells/bash のパッケージを作成してみる

jail$ cd /tinderbox/scripts
jail$ sudo ./tc tinderbuild -nullfs -b 7.3-FreeBSD shells/bash
Password:
tinderbuild: creating makefile...
tinderbuild: Creating build directory for 7.3-FreeBSD
7.3-FreeBSD: cleaning out /tinderbox/7.3-FreeBSD
makeBuild: extracting jail tarball
tinderbuild: Finalizing chroot environment
mount_nullfs: Operation not permitted
tinderbuild: cannot mount ports source
tinderbuild: Cleaning up after tinderbuild.  Please be patient.

失敗した。。「mount_nullfs: Operation not permitted」とか言われてる。
「/tinderbox/scripts/lib/tinderlib.sh」で「mount -t nullfs -o ro /tinderbox/portstrees/FreeBSD/ports /tinderbox/7.3-FreeBSD/a/ports」というコマンドが失敗している模様。


調べてみたら、そもそもjail内でマウント/アンマントはできないらしい。。。
15.5. Fine Tuning and Administration
"The root user is not allowed to mount or unmount file systems from within a jail(8)."と書いてある…。

より詳しい情報は「man 8 jail」を見ると分かる。

2011/05/04 追記

jail内でのmount - 英語とプログラミング気まぐれ日記の内容を実施して、カーネルの再構築 - 英語とプログラミング気まぐれ日記したらjail内でもmount_nullfsできるようになったので続きを書く。

$ cd /tinderbox/scripts/

$ sudo ./tc tinderbuild -nullfs -b 7.3-FreeBSD shells/bash
tinderbuild: creating makefile...
tinderbuild: Creating build directory for 7.3-FreeBSD
7.3-FreeBSD: cleaning out /tinderbox/7.3-FreeBSD
makeBuild: extracting jail tarball
tinderbuild: Finalizing chroot environment
mount -t nullfs -o ro /tinderbox/portstrees/FreeBSD/ports /tinderbox/7.3-FreeBSD/a/ports
mount -t nullfs -o ro /tinderbox/jails/7.3/src /tinderbox/7.3-FreeBSD/usr/src
================================================
building packages (phase 0)
================================================
started at Wed May  4 00:59:10 JST 2011
ended at Wed May  4 01:02:20 JST 2011
phase 0 took 00:03:10
0 packages built
4.0K  of packages
================================================
building packages (phase 1)
================================================
started at Wed May  4 01:02:20 JST 2011
ended at Wed May  4 01:05:12 JST 2011
phase 1 took 00:02:52
0 packages built
4.0K  of packages
tinderbuild: Cleaning up after tinderbuild.  Please be patient.
fstat: /dev/mem: No such file or directory
fstat: /dev/mem: No such file or directory

成功したのか??
ん、マニュアルを見直したら、jailを使った場合の注意点が書いてあったORZ
404 Not Found
jail内ではmount_nullfsができないので、jail内でtinderboxを構築したい場合はchrootしろと書いてある。。。
そもそもが間違えていたぽい。。。mount_nullfsとか無理矢理許可しなくてよかった…。
もう一度この手順に従ってリベンジしてみる。
今日は疲れたから寝る。
なんかできた…。正直なんでできたのか理解してない。。

$ sudo ./tc tinderbuild -nullfs -b 7.3-FreeBSD shells/bash
tinderbuild: creating makefile...
tinderbuild: Creating build directory for 7.3-FreeBSD
7.3-FreeBSD: cleaning out /tinderbox/7.3-FreeBSD
makeBuild: extracting jail tarball
tinderbuild: Finalizing chroot environment
mount -t nullfs -o ro /tinderbox/portstrees/FreeBSD/ports /tinderbox/7.3-FreeBSD/a/ports
mount -t nullfs -o ro /tinderbox/jails/7.3/src /tinderbox/7.3-FreeBSD/usr/src
================================================
building packages (phase 0)
================================================
started at Wed May  4 02:42:37 JST 2011
ended at Wed May  4 02:45:33 JST 2011
phase 0 took 00:02:56
6 packages built
9.2M  of packages
================================================
building packages (phase 1)
================================================
started at Wed May  4 02:45:33 JST 2011
ended at Wed May  4 02:45:33 JST 2011
phase 1 took 00:00:00
6 packages built
9.2M  of packages
tinderbuild: Cleaning up after tinderbuild.  Please be patient.
fstat: /dev/mem: No such file or directory
fstat: /dev/mem: No such file or directory


$ ls ../packages/7.3-FreeBSD/shells/bash-4.1.9.tbz 
../packages/7.3-FreeBSD/shells/bash-4.1.9.tbz

こんどこそ寝るzzZ

Jail の作成

※ ezjail-adminを利用した場合の方法です。

準備 (Jail用のalias IPアドレスの付与)

$ sudo ifconfig le0  <ip_address_to_assign> netmask 255.255.255.255 alias

設定の永続化
$ sudo vim /etc/rc.conf
ifconfig_le0_alias0="inet <ip_address_to_assign> netmask 255.255.255.255"

Jailの作成

$ sudo ezjail-admin create <jailname> <ip_address_to_assign>

Jailの作成 (Flavourを利用する場合)

$ sudo ezjail-admin create -f <flavourname> <jailname> <ip_address_to_assign>

Jail の削除

作成したJailを削除したい場合の手順。
※ ezjail-adminを利用した場合の手順です。

削除対象のjailを停止しておく

$ sudo /usr/local/etc/rc.d/ezjail.sh stop jailname

削除 (実際にjailrootは消さないで、ezjailのconfigだけ消す)

$ sudo ezjail-admin delete template.dip.jp

内部では以下のコマンドが実行される:
$ rm -f "/usr/local/etc/ezjail/jailname" "/etc/fstab.jailname"

この方法だとezjailが認識しなくなっただけで、jailrootは削除されていない。
"ezjail-admin create" の "-x"オプションを利用すれば、またezjailの設定を復活させることができる。 ← 確認してないので嘘かも

削除 (jailrootも消す)

$ sudo ezjail-admin delete -w template.dip.jp

内部では以下のコマンドが実行される:
$ rm -f "/usr/local/etc/ezjail/jailname" "/etc/fstab.jailname"
$ rm -rf "/usr/jails/jailname"
    ※ ezjail_jaildir が /usr/jails の場合

参考

404 Not Found

Jailを作成したい

FreeBSD7.0でJailの作成 - 英語とプログラミング気まぐれ日記で色々ためして(書き散らかして)少しjailの作成方法が分かったので、ここで復習の意味も兼ねて清書する。
※ ほぼezjailを使ってFreeBSD jailを効率よく管理する - mteramotoの日記劣化コピーです。。

jailホスト

$ hostname -a
FreeBSD test-freebsd.dip.jp 7.3-RELEASE-p2 FreeBSD 7.3-RELEASE-p2 #0: Mon Jul 12 19:04:04 UTC 2010     root@i386-builder.daemonology.net:/usr/obj/usr/src    /sys/GENERIC  i386

プロンプトの表記ルール

jailホストの場合は「$ 」
$ command

jail内の場合は「jail$ 」
jail$ command

ezjailのインストール/設定

ezjail - Jail administration framework

ezjailのインストール

portsからインストールする。

$ whereis ezjail
ezjail: /usr/ports/sysutils/ezjail
$ cd /usr/ports/sysutils/ezjail
$ sudo make install
ezjailの設定

設定ファイルの雛形をコピーして利用する。「ezjail_ftphost」だけは明示的に近いホストを指定したほうがよい。他は明示的に指定しなくても、デフォルトのままでよさそう。

$ sudo cp  /usr/local/etc/ezjail.conf.sample /usr/local/etc/ezjail.conf

$ sudo vim /usr/local/etc/ezjail.conf
ezjail_jaildir=/usr/jails
ezjail_ftphost=ftp.jp.freebsd.org

basejailの作成

basejailはezjailで管理するすべてのjailの元になるjail。

$ sudo ezjail-admin install

と言われても、自分の場合は最初はbasejailというものを全くイメージできなかった。。要はjail内のディレクトリにこのbasejailをマウントして、これから作成するどのjail内でもbasejailを参照するという考え方らしい。イメージは以下↓

ezjailでjailを作成する度に、「${ezjail_jaildir}/basejail」が作成したjailの「${ezjail_jaildir}/jailname/basejail」にマウントされる
$ df | grep basejail
/usr/jails/basejail   6204520 3123852 2584308    55%    /usr/jails/jail1/basejail
/usr/jails/basejail   6204520 3123852 2584308    55%    /usr/jails/jail2/basejail

jail内ではマウントされたbasejailへのシムリンクが適切に作成される(以下は一例)
(jailからはbsejailがjailホストでマウントされたディレクトリであることは分からない)
jail$ ls -l / | grep basejail
drwxr-xr-x   9 root  wheel   512 Dec 26 15:47 basejail
lrwxrwxrwx   1 root  wheel    13 Dec 29 19:52 bin -> /basejail/bin
lrwxrwxrwx   1 root  wheel    14 Dec 29 19:52 boot -> /basejail/boot
lrwxrwxrwx   1 root  wheel    13 Dec 29 19:52 lib -> /basejail/lib
lrwxrwxrwx   1 root  wheel    17 Dec 29 19:52 libexec -> /basejail/libexec
lrwxrwxrwx   1 root  wheel    16 Dec 29 19:52 rescue -> /basejail/rescue
lrwxrwxrwx   1 root  wheel    14 Dec 29 19:52 sbin -> /basejail/sbin

jail$ ls -l /usr/ports
lrwxrwxrwx  1 root  wheel  19 Dec 29 19:52 /usr/ports -> /basejail/usr/ports

basejailをupdateする

同じリリース内でセキュリティパッチレベルを上げるために使用するコマンドであるfreebsd-updateを利用する。

$ sudo mkdir /usr/jails/freebsd-update

$ sudo freebsd-update -b /usr/jails/basejail -d /usr/jails/freebsd-update fetch
$ sudo freebsd-update -b /usr/jails/basejail -d /usr/jails/freebsd-update install
Installing updates... done.

jail用のalias IPアドレスの付与

$ sudo ifconfig le0  192.168.11.5 netmask 255.255.255.255 alias192.168.11.5の部分はjailに割りあてるIPアドレス

設定の永続化

$ sudo vim /etc/rc.conf
ifconfig_le0_alias0="inet 192.168.11.5 netmask 255.255.255.255"

jailの作成

$ sudo ezjail-admin create jailname 192.168.11.5
...
Warning: Some services already seem to be listening on all IP, (including 192.168.11.5)
  This may cause some confusion, here they are:
root     sshd       651   4  tcp4   *:22                  *:*
root     syslogd    541   7  udp4   *:514                 *:*

jail作成時に上記のような「Warning」が出ることがある。jailホストでIPアドレスを指定しないでListenしているサービス(上記ではsshdとsyslogd)があると警告してくれる。(jail内で同じサービスを起動しようとしたときにListenできなくなってしまうため)
jailホストではjailホスト自身のIPアドレスを明示的に指定してListenするように設定する:

syslog
$ sudo vim /etc/rc.conf
yslogd_flags="-b 192.168.11.4"
※ jailホストのIPアドレスを指定する。ここでは192.168.11.4。

sshd
$ sudo vim /etc/ssh/sshd_config
ListenAddress 192.168.11.4

jailの起動

jailの起動
$ sudo /usr/local/etc/rc.d/ezjail.sh forcestart jailname

jailの起動確認
$ jls 
   JID  IP Address      Hostname                      Path
     1  192.168.11.5    jailname           /usr/jails/jailname

jailに入れるか確認
$ sudo ezjail-admin console jailname
または以下
$ sudo jexec 1 /bin/sh

jailがboot時に自動起動されるように設定しておく

jailが無事に起動されることを確認できたら、jailホストの起動時にjailも起動されるように設定しておく。

$ sudo vim /etc/rc.conf
ezjail_enable="YES"

jail内でportsを使えるようにしておく

$ sudo ezjail-admin update -P

内部ではportsnapを利用している模様
初回(/usr/jails/basejail/usr/portsが存在しない場合)は以下が実行される
$ sudo portsnap fetch
$ sudo portsnap -p /usr/jails/basejail/usr/ports extract

次回(/usr/jails/basejail/usr/portsが存在する場合)は以下が実行される
$ sudo portsnap fetch
$ sudo portsnap -p /usr/jails/basejail/usr/ports update

jailの作成は完了したが…

以上でjailの作成が完了したが、真っ新な状態なので、当然だが、自分のアカウントも無ければ/etc/resolv.confなど、諸々の設定もされていない。毎回jailを作成する度にこれらの設定を手動で行うのはバカらしい。というかしんどい…。そこでezjailに用意されている「Flavour」という仕組みを利用する。


Flavourで具体的に何が実行されるかというと…
1. ${ezjail_jaildir}/flavours/ ディレクトリ以下のファイル(ディレクトリ含む)が ${ezjail_rootdir} ディレクトリ以下にコピーされる(ディレクトリは再帰的にコピーされる)
ezjail-admin のコードでいうと、以下のようなコマンドが実行されるイメージ:

ezjail_flavours_dir=/usr/jails/flavours/
ezjail_flavour="flavour01" # 「ezjail-admin create -f "flavour01" hostname jailip」とした場合
cd "${ezjail_flavours_dir}/${ezjail_flavour}" && find . | cpio -p -u -v "${ezjail_rootdir}" > /dev/null

flavourは「-f "flavour01 flavour02"」のように複数指定できる。
2. ${ezjail_rootdir}/ezjail.flavour が作成したjailの初回起動時にのみ実行される
初回起動時の実行が完了したら自分で自分を消す処理が挿入されているので、次からは起動されない。

Flavourの設定

雛形をコピーする
$ sudo cp -R /usr/jails/flavours/example /usr/jails/flavours/basic
sudoers

sudoが実行できるようにしておく。

$ sudo vim /usr/jails/flavours/basic/usr/local/etc/sudoers
username        ALL=(ALL) ALL
make.conf

portsがjail内で使えるようにしておく。

$ sudo vim /usr/jails/flavours/basic/etc/make.conf
WRKDIRPREFIX=           /var/tmp
DISTDIR=                /var/tmp/usr/ports/distfiles
WITHOUT_IPV6=           yes

#PACKAGES=               /usr/ports/packages
#INDEXDIR=               /usr/ports
resolve.conf
$ sudo vim /usr/jails/flavours/basic/etc/resolv.conf
nameserver 192.168.11.1
sysctl.conf
$ sudo vim /usr/jails/flavours/basic/etc/sysctl.conf
# $FreeBSD: src/etc/sysctl.conf,v 1.8.36.1 2010/02/10 00:26:20 kensmith Exp $
#
#  This file is read when going to multi-user and its contents piped thru
#  ``sysctl'' to adjust kernel values.  ``man 5 sysctl.conf'' for details.
#

# Uncomment this to prevent users from seeing information about processes that
# are being run under another UID.
#security.bsd.see_other_uids=0

security.jail.allow_raw_sockets=1
rc.conf
# Pretuned by German Engineers

# No network interfaces in jails
network_interfaces=""

# Prevent rpc
rpcbind_enable="NO"

# Prevent loads of jails doing their cron jobs at the same time
cron_flags="$cron_flags -J 15"

# Prevent syslog to open sockets
syslogd_flags="-ss"

# Prevent sendmail to try to connect to localhost
sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"

# Bring up sshd, it takes some time and uses some entropy on first startup
sshd_enable="YES"

defaultrouter="192.168.11.1"
timezoneの設定

参考: 「man 8 adjkerntz」、シリコンバレー 24時: FreeBSDにおけるタイムゾーンの手動設定方法

$ sudo touch /usr/jails/flavours/basic/etc/wall_cmos_clock

$ sudo cp /usr/share/zoneinfo/Asia/Tokyo /usr/jails/flavours/basic/etc/localtime
ezjail.flavour
#!/bin/sh
#
# BEFORE: DAEMON
#


# Users
########
#
echo -n 'encrypted_password' | pw useradd -n username -u 1001 -s /bin/sh -m -d /home/username -G wheel -c 'comment' -H 0
mkdir /home/username/.ssh && echo -n 'public_key' > /home/username/.ssh/authorized_keys && chmod 400 /home/username/.ssh/authorized_keys
chown -R username /home/username/

書きかけ。
sudoとか使えるようにするためにパッケージまたはportsのインストールも入れておきたい。
あとtinderbox調べる。