2011年5月30日月曜日

bind-9.8.0-P2へのバージョンアップ手順

bind9-8.0-P2へのバージョンアップをしてみた。既存環境はbind9.7.3です。

1.ソースファイルの入手
[root@hoge src]#wget http://ftp.isc.org/isc/bind9/9.8.0-P2/bind-9.8.0-P2.tar.gz
2.展開
[root@hoge src]#tar -zxvf bind-9.8.0-P2.tar.gz
3.コンパイル
configureのオプションは環境にあわせること。バージョンアップ前のオプションを調べるためには
ソースディレクトリのconfig.statusファイルを見るとよい。(named -Vでも確認可能だそうで)
[root@hoge src]#cd bind-9.8.0-P2
[root@hoge bind-9.8.0-P2]#./configure --prefix=/usr/local/bind980P2 --disable-ipv6 --disable-openssl-version-check --enable-threads CFLAGS=-DDIG_SIGCHASE
[root@hoge bind-9.8.0-P2]#make
[root@hoge bind-9.8.0-P2]#make install
4.既存のbindプロセス(named)を停止
[root@hoge local]#/etc/init.d/named stop
5.シンボリックリンクの差替え
今回の環境は、bindのバージョン別に/usr/localの下にインストールを行っていて、使用するバージョンを/usr/local/bindとしてシンボリックリンクを貼っているので。。。
[root@hoge local]#pwd
/usr/local
[root@hoge local]#ls -la
合計 108
drwxr-xr-x 15 root root 4096  5月 30 09:58 .
drwxr-xr-x 15 root root 4096  5月 13 04:12 ..
drwxr-xr-x  2 root root 4096  5月 11 20:58 bin
lrwxrwxrwx  1 root root   18  3月  8 11:42 bind -> /usr/local/bind973
drwxr-xr-x  9 root root 4096  1月 22 02:10 bind972p3
drwxr-xr-x  9 root root 4096  3月  8 11:41 bind973
drwxr-xr-x  9 root root 4096  5月 30 09:58 bind980P2
drwxr-xr-x  2 root root 4096  5月 11 20:58 etc
drwxr-xr-x  2 root root 4096  5月 11 20:58 games
drwxr-xr-x  2 root root 4096  5月 11 20:58 include
drwxr-xr-x  2 root root 4096  5月 11 20:58 lib
drwxr-xr-x  2 root root 4096  5月 11 20:58 lib64
drwxr-xr-x  2 root root 4096  5月 11 20:58 libexec
drwxr-xr-x  2 root root 4096  5月 11 20:58 sbin
drwxr-xr-x  4 root root 4096  5月 11 20:58 share
drwxr-xr-x  5 root root 4096  5月 30 09:52 src
[root@hoge local]#rm bind
rm: remove シンボリックリンク `bind'? y
[root@hoge local]#ls -l
合計 92
drwxr-xr-x 2 root root 4096  5月 11 20:58 bin
lrwxrwxrwx 1 root root   20  5月 30 10:03 bind -> /usr/local/bind980P2
drwxr-xr-x 9 root root 4096  1月 22 02:10 bind972p3
drwxr-xr-x 9 root root 4096  3月  8 11:41 bind973
drwxr-xr-x 9 root root 4096  5月 30 09:58 bind980P2
drwxr-xr-x 2 root root 4096  5月 11 20:58 etc
drwxr-xr-x 2 root root 4096  5月 11 20:58 games
drwxr-xr-x 2 root root 4096  5月 11 20:58 include
drwxr-xr-x 2 root root 4096  5月 11 20:58 lib
drwxr-xr-x 2 root root 4096  5月 11 20:58 lib64
drwxr-xr-x 2 root root 4096  5月 11 20:58 libexec
drwxr-xr-x 2 root root 4096  5月 11 20:58 sbin
drwxr-xr-x 4 root root 4096  5月 11 20:58 share
drwxr-xr-x 5 root root 4096  5月 30 09:52 src
6.bindプロセス(named)を起動
[root@hoge local]#/etc/init.d/named start
7.確認
[root@hoge local]#/usr/local/bind/sbin/named -v
BIND 9.8.0-P2

BIND 9.8.0-P2がでましたね。

でましたね。
http://jprs.jp/tech/security/2011-05-27-bind9-vuln-large-rrsig-and-ncache.html

2011年5月26日木曜日

opensshでchroot

同僚が以下のようなことをやりたいらしい。

  • サーバへのアップロードをsftpかscpかでやりたい
  • アップロードで使うユーザはシェルでのログインを許可したくない
  • アップロードで使うユーザは、自身のホーム以外に移動させたくない


そもそも、sftpとscpは何が違うのかという点は、ここが詳しい。
(同僚曰く、scpよりsftpが早いと言っていたが、この記事を読む限り、scpが高速のようでな。。。)
機能的にはsftpが充実してるようなので、sftpがいいではないかと。

この要件をまとめると、sftpでchrootを使うようにしたいということになるだろうか。
とりあえず、試してみる。
試した環境は、"CentOS release 5.5 (Final) "、64bit版。


インストール

こちらによると、opensshの4.9以降がchrootに対応しているとのことだが、CentOSの標準パッケージだと、これ以前のバージョンが入っているので、入れ替える必要がある。
ソースコンパイルで入れればよいのだが、他のサーバへ横展開することも考えて、rpmを作ってみた。

opensshのソースコードを入手
ここあたりから、ダウンロードして、/usr/src/redhat/SOURCESへ置く。

展開
#cd /usr/src/redhat/SOURCEStar zxvf openssh-5.8p2.tar.gz
x11-ssh-askpassを入手
ここからダウンロードして、/usr/src/redhat/SOURCESへ置く。

必要パッケージのインストール
今回試した環境の場合、以下のものが必要だった

yum install libX11-devel.x86_64
yum install pam-devel.i386
yum install libXt-devel-1.0.2-3.2.el5.x86_64
yum install gtk2-devel

rpmの生成
rpmbuild -bb openssh-5.8p2/contrib/redhat/openssh.spec

/usr/src/redhat/RPMS/x86_64の下にrpmファイルが生成されるはず。

# cd /usr/src/redhat/RPMS/x86_64
# ls 
openssh-5.8p2-1.x86_64.rpm                openssh-clients-5.8p2-1.x86_64.rpm    
openssh-askpass-5.8p2-1.x86_64.rpm        openssh-debuginfo-5.8p2-1.x86_64.rpm
openssh-askpass-gnome-5.8p2-1.x86_64.rpm  openssh-server-5.8p2-1.x86_64.rpm


生成したrpmでアップデートする


#rpm -Uvh openssh-5.8p2-1 openssh-clients-5.8p2-1 openssh-askpass-5.8p2-1 openssh-server-5.8p2-1

sshデーモンを再起動

#/etc/init.d/sshd stop
#/etc/init.d/sshd start