彼氏のLinuxのキーリピートが早すぎだった、打てない。。。
WindowsXP上のVMware Playerで、CentOS5.4をインストールして動かしました。
しかし、インストール完了後、ログインしようとしても、キーリピートが敏感すぎてログインできません。
rootと打とうとすると、rrrrrrooooooooooooooooootttttttとかなります。
ログインさえできれば、GNOMEのキーボードの設定で、キーリピートをOFFにできるのですが、肝心のログインすらできない状態で困りました。
解決した方法
AMD Athlon X2限定ですが、 AMD Dual-Core Optimizer を入れたら直りました。
ホストOSの再起動が必要です。
また、インストールは自己責任でお願いします。
ダメだった方法
他のシュチュエーションでは有効かもしれませんので、紹介。
keyboard.typematicMinDelayの設定
vmxファイルにkeyboard.typematicMinDelayを定義する。
VMwareのコミュニティで、紹介されていたが、現象変わらず。
keyboard.typematicMinDelay = 2000000
http://communities.vmware.com/message/222274
http://communities.vmware.com/message/240817
CPUスピードの指定
これもVMwareのコミュニティに載っていたが、現象変わらず。
host.cpukHz = 2500000 # CPUスピード値は環境により異なる。例は2.5GHz
host.noTSC = TRUE
ptsc.noTSC = TRUE
kbdrateの設定
kbdrateコマンドでキーリポートの間隔を延ばす方法。
シングルユーザーモードで起動し、/etc/rc.localにkbdrateを実行するように定義したが、ログイン画面には効かなかった。
キーリピートOFF
これは試してませんが、以下のコマンドを/etc/rc.localに入れれば、もしかして。
xset r off
XenのDomain-Uディスク拡張(LVMを使用しない)
XenのDomain-Uのディスク拡張方法として、LVMで構築されたゲストの拡張方法はよく見かけますが、LVMを使用していないゲストのディスク拡張方法があまり見つからず、e2fsckでエラーが出まくり、ハマっていたのですが、以下のページで紹介されていた方法をそのままやったらできました。
http://www.jaddog.org/2009/08/12/expanding-a-xen-disk-images-space/
環境は、Red Hat Enterprise Linux 5.4です。xenのバージョンは、xen-3.0.3-94.el5_4.3を使用しています。
xenのバージョンや依存したような作業ではないと思うので、他のディストリビューションでも試す価値はあると思います。
ポイントは、xm block-attachです。
ちなみに、Linuxのコマンドライン操作をはてなダイアリーで貼り付けるときは、何記法が一番見やすいのかな。
■拡張前のDomain-Uのディスクの状況
[root@domu1 ~]# df -h Filesystem サイズ 使用 残り 使用% マウント位置 /dev/xvda3 34G 31G 1.4G 96% / /dev/xvda1 99M 18M 77M 19% /boot tmpfs 1.1G 0 1.1G 0% /dev/shm
■ディスク拡張を行います。
[root@xen-dom0 images]# xm shutdown domu1 [root@xen-dom0 images]# mv domu1.img domu1.img.old [root@xen-dom0 images]# dd if=/dev/zero of=zero-40gb.img bs=1024k count=40960 [root@xen-dom0 images]# cat domu1.img.old zero-40gb.img > domu1.img
ここまでの手順は一般的に紹介されています。
ゲストを落として、ddコマンドで作成したファイルをイメージファイルと結合して、
拡張したディスクイメージファイルを作成します。
ddコマンドは、例の場合は40GBのファイルを作成します。+1GBならcountは1024に指定します。値を変えて、追加したいディスクサイズに変更してください。
この後の手順では、e2fsckを行うのですが、以下の方法では失敗します。
■e2fsckが失敗してしまうパターン
(1)イメージファイルをfsckしてもダメ
[root@xen-dom0 images]# e2fsck -fv domu1.img e2fsck 1.39 (29-May-2006) Couldn't find ext2 superblock, trying backup blocks... e2fsck: Bad magic number in super-block while trying to open /dev/loop0 The superblock could not be read or does not describe a correct ext2 filesystem. If the device is valid and it really contains an ext2 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock: e2fsck -b 8193 <device>
(2)ループバックにマウントしてfsckしてもダメ
[root@xen-dom0 images]# losetup /dev/loop0 pre-kp-cmsp01.img [root@xen-dom0 images]# e2fsck -fv /dev/loop0 e2fsck 1.39 (29-May-2006) Couldn't find ext2 superblock, trying backup blocks... e2fsck: Bad magic number in super-block while trying to open /dev/loop0 The superblock could not be read or does not describe a correct ext2 filesystem. If the device is valid and it really contains an ext2 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock: e2fsck -b 8193 <device>
■イメージファイルのアタッチ
正解は、xm-block attachです。attachした後であれば、fsckが通ります。
[root@xen-dom0 images]# modprobe xenblk [root@xen-dom0 images]# xm block-attach 0 'file:/var/lib/xen/images/domu1.img' xvda w
■アタッチの状況を確認(xvda1は/boot,xvda3が/です。xvda3を拡張します。)
[root@xen-dom0 images]# fdisk -l /dev/xvda Disk /dev/xvda: 84.8 GB, 84892712960 bytes 255 heads, 63 sectors/track, 10320 cylinders Units = シリンダ数 of 16065 * 512 = 8225280 bytes デバイス Boot Start End Blocks Id System /dev/xvda1 * 1 13 104391 83 Linux /dev/xvda2 14 535 4192965 82 Linux swap / Solaris /dev/xvda3 536 5099 36660330 83 Linux
■fsckでディスクチェック(swapを除く)
[root@xen-dom0 images]# e2fsck -f /dev/xvda1 e2fsck 1.39 (29-May-2006) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /boot: 40/26104 files (10.0% non-contiguous), 20964/104388 blocks [root@xen-dom0 images]# e2fsck -f /dev/xvda3 e2fsck 1.39 (29-May-2006) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /: 295171/9166080 files (3.9% non-contiguous), 8352833/9165082 blocks
[root@xen-dom0 images]# tune2fs -O^has_journal /dev/xvda3 tune2fs 1.39 (29-May-2006) [root@xen-dom0 images]# tune2fs -O^has_journal /dev/xvda1 tune2fs 1.39 (29-May-2006)
■fdiskでディスク拡張
fdiskで拡張対象のパーティションを一度削除して、再作成します。
私の環境の場合3(xvda3)ですが、環境によってパーティションは変わりますので、気をつけましょう。fdiskの操作方法が分らない人は、調べてからやりましょう。
[root@xen-dom0 images]# fdisk /dev/xvda このディスクのシリンダ数は 10320 に設定されています。 間違いではないのですが、1024 を超えているため、以下の場合 に問題を生じうる事を確認しましょう: 1) ブート時に実行するソフトウェア (例. バージョンが古い LILO) 2) 別の OS のブートやパーティション作成ソフト (例. DOS FDISK, OS/2 FDISK) コマンド (m でヘルプ): p Disk /dev/xvda: 84.8 GB, 84892712960 bytes 255 heads, 63 sectors/track, 10320 cylinders Units = シリンダ数 of 16065 * 512 = 8225280 bytes デバイス Boot Start End Blocks Id System /dev/xvda1 * 1 13 104391 83 Linux /dev/xvda2 14 535 4192965 82 Linux swap / Solaris /dev/xvda3 536 5099 36660330 83 Linux コマンド (m でヘルプ): d 領域番号 (1-4): 3 コマンド (m でヘルプ): n コマンドアクション e 拡張 p 基本領域 (1-4) p 領域番号 (1-4): 3 最初 シリンダ (536-10320, default 536): Using default value 536 終点 シリンダ または +サイズ または +サイズM または +サイズK (536-10320, default 10320): Using default value 10320 コマンド (m でヘルプ): w 領域テーブルは交換されました! ioctl() を呼び出して領域テーブルを再読込みします。 ディスクを同期させます。
■fsckで再チェック
[root@xen-dom0 images]# e2fsck -f /dev/xvda3 e2fsck 1.39 (29-May-2006) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /: 295171/9166080 files (3.9% non-contiguous), 8320031/9165082 blocks
[root@xen-dom0 images]# tune2fs -j /dev/xvda1 tune2fs 1.39 (29-May-2006) Creating journal inode: done This filesystem will be automatically checked every -1 mounts or 0 days, whichever comes first. Use tune2fs -c or -i to override. [root@xen-dom0 images]# tune2fs -j /dev/xvda3 tune2fs 1.39 (29-May-2006) Creating journal inode: done This filesystem will be automatically checked every -1 mounts or 0 days, whichever comes first. Use tune2fs -c or -i to override.
■リサイズ
[root@xen-dom0 images]# resize2fs -f /dev/xvda3 resize2fs 1.39 (29-May-2006) Resizing the filesystem on /dev/xvda3 to 19649503 (4k) blocks. The filesystem on /dev/xvda3 is now 19649503 blocks long.
■最後にディタッチ
[root@xen-dom0 images]# xm block-detach 0 xvda
■ゲストの起動
[root@xen-dom0 images]# xm create domu1 Using config file "/etc/xen/domu1". Started domain domu1
■Domain-Uディスクの確認
[root@domu1 ~]# df -h Filesystem サイズ 使用 残り 使用% マウント位置 /dev/xvda3 73G 31G 39G 45% / /dev/xvda1 99M 18M 77M 19% /boot tmpfs 1.1G 0 1.1G 0% /dev/shm
yslow2.0.5をインストール直後、firefox3.5.7がクラッシュ
Firefox 3.6がリリースされましたが、まだ3.5.7を使ってます。
yslowの2.0.5がリリースされていたので、インストールしたら、
その直後からFirefoxが起動しなくなりました。
正確には起動して、クラッシュを繰り返します。
firebugとyslowのバージョン間の問題でしょうか。
とりあえず、プロファイルマネージャを立ち上げ、新たなプロファイルを作成して、起動してます。プロファイルマネージャの起動方法は、コマンドラインから以下のコマンドを実行します。
firefox.exe -ProfileManager
起動したら、新しいプロファイルを作成しましょう。
新しいプロファイルでは、プラグインが何もインストールされていない素の状態になるので起動できます。
起動してから、Firefoxを3.6にアップして、クラッシュした方のプロファイルで起動したけど、現象は変わらず、起動できませんでした。
修正パッチが提供されるのを待つか。
firefox3.6を入れて思ったけど、もうchromeでもいいかなと。
Tips&トラブルシュート
データベースファイルの格納場所
最も重要なこととして、データベースをどこに格納するかという問題があります。
データベースファイル自体が、侵入者に改ざんされてしまっては、全く意味がありません。
そのため、データベースファイルはリモートサーバやReadOnlyの外部メディアに置くことが推奨されています。
正規表現を使った監視対象の設定
aide.confに定義する監視対象は、正規表現も使った表現も可能です。
以下の例の場合、全ファイル、パーミッション、ユーザーおよびグループのチェックに加え、/etcディレクトリ配下は加えてatimeの値チェックも行います。ただし、/etc/hoge.confはチェックを行いません。
/ p+u+g
=/etc p+u+g+a
!/etc/hoge.conf
詳細は、 AIDE Manual を参照してください。
運用(定期チェック)
改ざんチェックおよびデータベースファイルの更新(aide --update)を行います。
改ざんを検知した場合は、管理者へメール通知を行います。
管理者は、内容を確認し、問題がなければ、データベースファイルを更新します。
(mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz)
定期チェック用スクリプト
RHELでは、定期チェックのスクリプトが提供されないため、自作する必要があります。
Debian系で提供されている定期チェックスクリプトを、RHEL用に修正します。
パラメタファイル(/etc/default/aide)
後述の定期チェックスクリプトのパラメタファイルです。
結果の通知先(MAILTO)を実際にメールを送付したい宛先に設定してください。
# These settings are mainly for the wrapper scripts around aide, # such as aideinit and /etc/cron.daily/aide # This is the email address reports get mailed to MAILTO=root # Set this to suppress mailings when there's nothing to report #QUIETREPORTS=1 # This parameter defines which aide command to run from the cron script. # Sensible values are "update" and "check". # Default is "check", ensuring backwards compatibility. # Since "update" does not take any longer, it is recommended to use "update", # so that a new database is created every day. The new database needs to be # manually copied over the current one, though. COMMAND=update # This parameter defines how many lines to return per e-mail. Output longer # than this value will be truncated in the e-mail sent out. LINES=1000 # This parameter gives a grep regular expression. If given, all output lines # that _don't_ match the regexp are listed first in the script's output. This # allows to easily remove noise from the aide report. NOISE="" # This parameter defines which options are given to aide in the daily # cron job. The default is "-V4". AIDEARGS=""
定期チェックスクリプト(/etc/cron.daily/aide)
クーロンで、 aide --update を定期実行、結果をメールで通知します。
#!/bin/bash PATH="/sbin:/usr/sbin:/bin:/usr/bin" LOGDIR="/var/log/aide" LOGFILE="aide.log" CONFFILE="/etc/aide.conf" ERRORLOG="error.log" ERRORTMP=`mktemp -t "$ERRORLOG".XXXXXXXXXX` [ -f /usr/sbin/aide ] || exit 0 AIDEARGS="-V4" if [ -f /etc/default/aide ]; then . /etc/default/aide fi FQDN=`hostname -f` DATE=`date +"at %Y-%m-%d %H:%M"` # default values MAILTO="${MAILTO:-root}" DATABASE="${DATABASE:-/var/lib/aide/aide.db.gz}" LINES="${LINES:-1000}" COMMAND="${COMMAND:-check}" if [ ! -f $DATABASE ]; then ( echo "Fatal error: The AIDE database does not exist!" echo "This may mean you haven't created it, or it may mean that someone has removed it." ) | /usr/bin/mail -s "Daily AIDE report for $FQDN" $MAILTO exit 0 fi aide $AIDEARGS --$COMMAND >"$LOGDIR/$LOGFILE" 2>"$ERRORTMP" RETVAL=$? if [ -n "$QUIETREPORTS" ] && [ $QUIETREPORTS -a \! -s $LOGDIR/$LOGFILE -a \! -s $ERRORTMP ]; then # Bail now because there was no output and QUIETREPORTS is set exit 0 fi (cat << EOF; This is an automated report generated by the Advanced Intrusion Detection Environment on $FQDN ${DATE}. EOF # include error log in daily report e-mail if [ "$RETVAL" != "0" ]; then cat > "$LOGDIR/$ERRORLOG" << EOF; ***************************************************************************** * aide returned a non-zero exit value * ***************************************************************************** EOF echo "exit value is: $RETVAL" >> "$LOGDIR/$ERRORLOG" else touch "$LOGDIR/$ERRORLOG" fi < "$ERRORTMP" cat >> "$LOGDIR/$ERRORLOG" rm -f "$ERRORTMP" if [ -s "$LOGDIR/$ERRORLOG" ]; then errorlines=`wc -l "$LOGDIR/$ERRORLOG" | awk '{ print $1 }'` if [ ${errorlines:=0} -gt $LINES ]; then cat << EOF; **************************************************************************** * aide has returned many errors. * * the error log output has been truncated in this mail * **************************************************************************** EOF echo "Error output is $errorlines lines, truncated to $LINES." head -$LINES "$LOGDIR/$ERRORLOG" echo "The full output can be found in $LOGDIR/$ERRORLOG." else echo "Errors produced ($errorlines lines):" cat "$LOGDIR/$ERRORLOG" fi else echo "AIDE produced no errors." fi # include de-noised log if [ -n "$NOISE" ]; then NOISTEMP=`mktemp -t aidenoise.XXXXXXXXXX` NOISTEMP2=`mktemp -t aidenoise.XXXXXXXXXX` sed -n '1,/^Detailed information about changes:/p' "$LOGDIR/$LOGFILE" | \ grep '^\(changed\|removed\|added\):' | \ grep -v "^added: THERE WERE ALSO [0-9]\+ FILES ADDED UNDER THIS DIRECTORY" > $NOISETMP2 if [ -n "$NOISE" ]; then < $NOISETMP2 grep -v "^\(changed\|removed\|added\):$NOISE" > $NOISETMP rm -f $NOISETMP2 echo "De-Noised output removes everything matching $NOISE." else mv $NOISETMP2 $NOISETMP echo "No noise expression was given." fi if [ -s "$NOISETMP" ]; then loglines=`< $NOISETMP wc -l | awk '{ print $1 }'` if [ ${loglines:=0} -gt $LINES ]; then cat << EOF; **************************************************************************** * aide has returned long output which has been truncated in this mail * **************************************************************************** EOF echo "De-Noised output is $loglines lines, truncated to $LINES." < $NOISETMP head -$LINES echo "The full output can be found in $LOGDIR/$LOGFILE." else echo "De-Noised output of the daily AIDE run ($loglines lines):" cat $NOISETMP fi else echo "AIDE detected no changes after removing noise." fi rm -f $NOISETMP echo "============================================================================" fi # include non-de-noised log if [ -s "$LOGDIR/$LOGFILE" ]; then loglines=`wc -l "$LOGDIR/$LOGFILE" | awk '{ print $1 }'` if [ ${loglines:=0} -gt $LINES ]; then cat << EOF; **************************************************************************** * aide has returned long output which has been truncated in this mail * **************************************************************************** EOF echo "Output is $loglines lines, truncated to $LINES." head -$LINES "$LOGDIR/$LOGFILE" echo "The full output can be found in $LOGDIR/$LOGFILE." else echo "Output of the daily AIDE run ($loglines lines):" cat "$LOGDIR/$LOGFILE" fi else echo "AIDE detected no changes." fi ) | /bin/mail -s "Daily AIDE report for $FQDN" $MAILTO
監視ポリシー(aide.conf)
監視ポリシーは、インストール時の標準のものでも、例えば/etcや/bin配下などの広範囲にチェックを行ってくれます。
ただし、標準では、/var/logや/root配下もチェックしますので、
ユーザーのログイン、rootがコマンドを実行しただけで、改ざんとして通知されます。
こうした検知が煩わしい、もしくは独自ファイルの監視を行いたい場合、カスタマイズが必要です。
例えば、以下の例の場合、全てのファイルに関して、パーミッション、ユーザー、グループに変更があった場合、改ざんとして検知されます。
/ p+u+g
詳細は、manコマンドで確認してください。