前は 「etch の中で sarge を飼う」でしたけど. まあ, やっている事は同じです. 作成しているパッケージの後方互換の為に, 親環境は lenny だけど, chroot の中で etch 環境を作成します.
chrootはカーネル、ハードウェア、ネットワーク、ポート、メモリ、プロセス等々を 共有しつつ, ルートディレクトリ(/)を切り替えることでシステムを分離する技術です.
以下では
とします.
cdebootstrap と schroot を導入しておきます.
$ aptitude install cdebootstrap schroot
先ず, /var/chroot/etch に必要なパッケージを導入します.
# cdebootstrap etch /var/chroot/etch http://cdn.debian.or.jp/debian P: Retrieving Release P: Retrieving Release.gpg P: Validating Release I: Good signature from "Debian Archive Automatic Signing Key (4.0/etch) <ftpmaster@debian.org>" I: Good signature from "Etch Stable Release Key <debian-release@lists.debian.org> ... P: Deconfiguring helper cdebootstrap-helper-makedev-minimal P: Writing hosts P: Writing resolv.conf P: Writing apt sources.list
で終了.
次に環境設定. etch の頃は /etc/resolv.conf, /etc/hosts をコピーする必要 があったけれど, 不要の模様.
# chroot /var/chroot/etch bash [chroot で etch 環境へ] # vi /etc/apt/sources.list [contrib, non-free 等を追加] # dpkg-reconfigure locales [locale の設定] # aptitude install ~pstandard ~t^japanese$ ... # aptitude remove nfs-common portmap ... [不要なモノの削除]
ここで一旦再起動. 起動した後で, /etc/passwd 等を /chroot 以下に cp して, bind mount の設定を する.
# cp /etc/passwd /var/chroot/etch/etc # cp /etc/group /var/chroot/etch/etc # cp /etc/shadow /var/chroot/etch/etc # cp /etc/sudoers /var/chroot/etch/etc # vi /etc/fstab [以下の内容を追加] proc /var/chroot/etch/proc proc defaults 0 0 /tmp /var/chroot/etch/tmp none bind 0 0 /home /var/chroot/etch/home none rbind 0 0 # mount -a
/etc/schroot/schroot.conf に以下の内容を追加する.
[etch] description=Debian etch location=/var/chroot/etch priority=0 users=hogehero root-users=hogehero
users, root は実際に存在する user 名 にしておく. これで
$ schroot -c etch [chroot 環境へ login] ... $ schroot -c etch -p [環境変数を引き継いで login] ... $ schroot -c etch -p gave [直接 chroot 環境の プログラムを起動] ... $ schroot -c etch -u root [root として login]
親環境の /etc/cron.weekly あたりに
#!/bin/sh # for chroot environment CHROOT="etch" for i in $CHROOT ; do echo "[update chroot $i]" schroot -q -c $i aptitude update schroot -q -c $i aptitude update schroot -q -c $i aptitude upgrade schroot -q -c $i aptitude autoclean done
aptitude update を二回やっているのは, 偶に GPG 署名の検証に失敗するから.
親環境も chroot 環境も syslog-ng にする(sysklogd でも良いけれど) chroot 環境の設定は
$ cat /var/chroot/etch/etc/syslog-ng/syslog-ng.conf
options { long_hostnames(off); sync(0); };
source src { unix-dgram("/dev/log"); internal(); };
destination loghost{
udp("127.0.0.1" port(514));
};
log {
source(src);
destination(loghost);
};
これだけ.
親環境は udp 514 を開放して, localhost からのみ受けとるようにすれば良い.
sources s_all セクションの udp(); のコメントを外す.
$ sudo vi /etc/syslog-ng/syslog-ng.conf
...
# use the following line if you want to receive remote UDP logging messages
# (this is equivalent to the "-r" syslogd flag)
udp();
};
...
で再起動.
syslog-ng は hosts.(allow|deny) が効くので, アクセス制限は tcp_wrapper 任せで.