電源ボタン(4)

debian 玄箱/Pro

ググったら自分のサイトが出てきた(汗)。 LS-GL で良く似たことやってるやん。

/etc/init.d/Kevent.sh のコピー

hackkit:~# cp /usr/local/buffalo/etc/init.d/Kevent.sh /etc/init.d
hackkit:~# ls -l  /usr/local/buffalo/etc/init.d/Kevent.sh /etc/init.d/Kevent.sh
-rwxr-xr-x  1 root root 239 Mar  6 09:00 /etc/init.d/Kevent.sh/init.d/Kevent.sh
-rwxr-xr-x  1 root root 239 Jan 19 20:34 /usr/local/buffalo/etc/init.d/Kevent.sh
hackkit:~#

/usr/local/sbin/Keventd のコピー

/etc/init.d/Kevent.sh が呼んでいる /usr/local/sbin/Keventd を コピーする
hackkit:~# cp /usr/local/buffalo/usr/local/sbin/Keventd /usr/local/sbin
hackkit:~# ls -l /usr/local/buffalo/usr/local/sbin/Keventd /usr/local/sbin/Keventtd
-rwxr-xr-x  1 root root 251 Mar  6 07:01 /usr/local/buffalo/usr/local/sbin/Keventd
-rwxr-xr-x  1 root root 251 Mar  6 09:03 /usr/local/sbin/Keventd
hackkit:~# grep KERNEL_EVENT_TAIL /usr/local/buffalo/usr/local/bin/kuro_lib
KERNEL_EVENT_TAIL=/proc/buffalo/kernevnt
hackkit:~# vi /usr/local/sbin/Keventd 
	:
	:
hackkit:~# diff -c /usr/local/buffalo/usr/local/sbin/Keventd /usr/local/sbin/Keventd
*** /usr/local/buffalo/usr/local/sbin/Keventd   Tue Mar  6 07:01:16 2007
--- /usr/local/sbin/Keventd     Tue Mar  6 09:07:25 2007
***************
*** 1,7 ****
  #!/bin/sh


! . /usr/local/bin/kuro_lib

  if [ ! -e ${KERNEL_EVENT_TAIL} ] ; then
        exit 0
--- 1,8 ----
  #!/bin/sh


! #. /usr/local/bin/kuro_lib
! KERNEL_EVENT_TAIL=/proc/buffalo/kernevnt

  if [ ! -e ${KERNEL_EVENT_TAIL} ] ; then
        exit 0
hackkit:~#

/usr/local/bin/KeventHandller.sh の作成

/usr/local/sbin/Keventd が呼んでいる /usr/local/bin/KeventHandller.sh を 作る。
hackkit:~# vi /usr/local/bin/KeventHandller.sh
                     :
hackkit:~# cat !$
cat /usr/local/bin/KeventHandller.sh
#!/bin/sh

case $1 in
micon_interrupts)
        INT_DETAIL=`/usr/local/sbin/miconapl -a int_get_switch_status |sed -n -e "s/int=//p"`
        case ${INT_DETAIL} in
        power_sw)
                shutdown -h now
                ;;
        esac
        ;;
esac
hackkit:~# 

miconapl のスタブ作成

hackkit:~# echo 'chroot /usr/local/buffalo /usr/local/sbin/miconapl $*' > /usr/local/sbin/miconapl
hackkit:~# miconapl -a int_get_switch_status
-bash: /usr/local/sbin/miconapl: Permission denied
hackkit:~# chmod +x /usr/local/sbin/miconapl
hackkit:~# miconapl -a int_get_switch_status
#[miconapl.int_get_switch_status]
int=unknown
hackkit:~#
こんなところかな。

実行

hackkit:~# /etc/init.d/Kevent.sh start
hackkit:~# /usr/local/bin/KeventHandller.sh lanact 0 half
/usr/local/bin/KeventHandller.sh lanact 1000 full
電源ボタンを押してみる

hackkit:~# /usr/local/bin/KeventHandller.sh micon_interrupts

Broadcast message from root (Tue Mar  6 09:22:29 2007):

The system is going down for system halt NOW!
INIT: Sending processes the TERM signal
INIT: Sending Stopping periodic command scheduler: cron.
Stopping MTA: exim4.
Stopping internet superserver: inetd.
Saving the System Clock time to the Hardware Clock...
Hardware Clock updated to Tue Mar  6 09:22:36 JST 2007.
Stopping deferred execution scheduler: atd.
Stopping kernel log daemon: klogd.
Stopping system log daemon: syslogd.
Sending all processes the TERM signal...done.
Sending all processes the KILL signal...done.
Saving random seed...done.
Unmounting remote and non-toplevel virtual filesystems...done.
Deconfiguring network interfaces...done.
Cleaning up ifupdown...done.
Deactivating swap...done.
Unmounting local filesystems...done.
md: stopping all md devices.
md: md0 switched to read-only mode.
Synchronizing SCSI cache for disk sda:
System halted.
おちたたぁ!


KURO-BOX/PRO
玄人志向
楽天市場
TSUKUMO ネットショップ
Yahoo!ショッピング
Sofmap
クレバリー
TwoTop New!


電源ボタン(3)
ハックの記録
LinkStation/玄箱 をハックしよう

su できない

Copyright (C) 2003-2007 Yasunari Yamashita. All Rights Reserved.
yasunari @ yamasita.jp 山下康成@京都府向日市