Monday 29 November 2010

VI 문자 대문자로 치환하기

gUw 한개 단어 치환 
gU2w 두개 단어 치환
gU$ 한 라인 치환
gU10l 10라인 치환

Friday 26 November 2010

Fighting with SELinux and Nagios

Fighting with SELinux and Nagios

Posted by Peter Sankauskas on 2nd May 2009
I can’t believe it, but I won! I have been trying to set up Nagios on a RHEL5 machine running SELinux and have been loosing the fight for the last 3 days. But today, I win! This is such a win, it is worth sharing.
Now that I have won though, I believe this is not Nagios specific at all, and if I had bothered to learn about SELinux, this may have been obvious. Anyway, the error Nagios was giving me was:
Error: Could not stat() command file ‘/usr/local/nagios/var/rw/nagios.cmd’! 
The external command file may be missing, Nagios may not be running, and/or Nagios may not be checking external commands.
An error occurred while attempting to commit your command for processing.
Return from whence you came
As you may have already guess, the solution has nothing to do with the location or permissions of the file, the file was not missing, Nagios was running, and Nagios was checking external commands. The final line of the message is great though, and I can only hope we start to see more old English in error messages.
The problem of course, was that SELinux was enabled and stopping this blatant security violation. You can check to see if SELinux is on by running:
$ /usr/sbin/getenforce
Enforcing
If you got “Permissive” or “Disabled”, then this post is not for you. To see SELinux’s side of things, check out /var/log/messages:
setroubleshoot: SELinux is preventing ping (ping_t) “read write” to /usr/local/nagios/var/spool/checkresults/checkrXH96b (usr_t). For complete SELinux messages. run sealert -l 1ffc2533-42b5-4e04-b7ab-a81bb7d02040

setroubleshoot: SELinux is preventing ping (ping_t) “read write” to /usr/local/nagios/var/spool/checkresults/checkrZxsA1 (usr_t). For complete SELinux messages. run sealert -l 178ba2d4-0822-47eb-9e32-bfaa19ee3c4b

setroubleshoot: SELinux is preventing cmd.cgi (httpd_sys_script_t) “getattr” to /usr/local/nagios/var/rw/nagios.cmd (httpd_sys_content_t). For complete SELinux messages. run sealert -l 4df0946e-8816-4b90-a7d1-37e743697b9c
As you can see, SELinux is trying to give you a hint with that sealert bit, so you should take it.
$ sealert -l 1ffc2533-42b5-4e04-b7ab-a81bb7d02040
Summary:
SELinux is preventing ping (ping_t) “read write” to
/usr/local/nagios/var/spool/checkresults/checkrXH96b (usr_t).
Detailed Description:
… (removed from post)
Raw Audit Messages
host=myhost.myisp.host type=AVC msg=audit(1241217029.141:125305): avc: denied { read write } for pid=32379 comm=”ping” path=”/usr/local/nagios/var/spool/checkresults/checkrXH96b” dev=sda3 ino=52894945 scontext=user_u:system_r:ping_t:s0 tcontext=user_u:object_r:usr_t:s0 tclass=file
host=myhost.myisp.host type=SYSCALL msg=audit(1241217029.141:125305): arch=c000003e syscall=59 success=yes exit=0 a0=153952a0 a1=15395330 a2=7fff75c5eb40 a3=0 items=0 ppid=32378 pid=32379 auid=503 uid=508 gid=508 euid=0 suid=0 fsuid=0 egid=508 sgid=508 fsgid=508 tty=(none) ses=1392 comm=”ping” exe=”/bin/ping” subj=user_u:system_r:ping_t:s0 key=(null)
That raw audit message is GOLD! There is some other information in there, but nothing about what the next step should be to create a policy and make it permanent. Using chron I have heard is a temporary fix. The solution is copying that raw audit message into an empty file and runningaudit2allow to create a policy:
$ cat > /tmp/tmp-nagiosping
host=myhost.myisp.host type=AVC msg=audit(1241217029.141:125305): avc: denied { read write } for pid=32379 comm=”ping” path=”/usr/local/nagios/var/spool/checkresults/checkrXH96b” dev=sda3 ino=52894945 scontext=user_u:system_r:ping_t:s0 tcontext=user_u:object_r:usr_t:s0 tclass=file
host=myhost.myisp.host type=SYSCALL msg=audit(1241217029.141:125305): arch=c000003e syscall=59 success=yes exit=0 a0=153952a0 a1=15395330 a2=7fff75c5eb40 a3=0 items=0 ppid=32378 pid=32379 auid=503 uid=508 gid=508 euid=0 suid=0 fsuid=0 egid=508 sgid=508 fsgid=508 tty=(none) ses=1392 comm=”ping” exe=”/bin/ping” subj=user_u:system_r:ping_t:s0 key=(null)
* Ctrl-D *
$ audit2allow -M NagiosPing < /tmp/tmp-nagiosping
******************** IMPORTANT ***********************
To make this policy package active, execute:
semodule -i NagiosPing.pp
This creates a file call NagiosPing.pp which contains the SELinux policy needed to make these errors go away. The only thing left to do is to install this policy:
$ semodule -i NagiosPing.pp
If your setup was like mine, SELinux was actually preventing 3 different actions, needing 3 different policies. HA! That is easy now – just repeat the steps until Nagios is doing your bidding.

Wednesday 24 November 2010

PuTTY Connection Manager

PuTTY Connection Manager
http://puttycm.free.fr/cms/index.php?option=com_content&view=frontpage&Itemid=62

PuTTY의 연결 정보 관리와 Tab을 제공해주어 편리하게 사용할 수 있는 유틸이다.
예전엔 유미테크 김차장님이 손수 만드신 프로그램을 사용했는데... 어딘가 다른게 있을 거라
생각했는데... ㅋ

Installing iotop on CentOS 5.5

IOTop 실행시 Python 2.5이상을 필요하지만 2.4로도 ctypes 모듈을 설치하면 사용할 수 있다.

1. 준비
먼저 ctypes 모듈을 홈페이지에서 다운로드 받는다.
http://pypi.python.org/pypi/ctypes

  1.1 컴파일러 및 헤더 설치
        설치하려면 컴파일러(GCC)가 필요하며 Python 헤더 또한 필요로 한다.
        간단히 yum 명령어로 설치한다.
      
        # yum install python-devel
        # yum install gcc

  1.2 ctypes 설치
        다음 명령을 사용하여 인스톨 한다.
        # tar zxvf ctypes-1.0.2.tar.gz
        # cd ctypes-1.0.2
        # python setup.py build
        # python setup.py install

2. IOTop 설치
iotop을 rpm명령을 사용하여 설치한다.      
# wget http://guichaz.free.fr/iotop/files/iotop-0.4.1-1.noarch.rpm
# rpm -ihv  iotop-0.4.1-1.noarch.rpm

Wednesday 17 November 2010

Linux Backup

Mondo Rescue Home Page


백업 솔루션 찾다보니 정말 오랜만에 다시보는 Mondo~ 역시 이게 좋아~ㅎㅎ



리눅스에서 백업 자동화하기

쉽게 할 수 있는 보안 분산 네트워크 백업 DIY

http://www.ibm.com/developerworks/kr/library/l-backup/index.html