메뉴 건너뛰기

리눅스 관련 모음

본문시작

2012.06.07 15:24

selinux 관련 명령모음.

조회 수 36271 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

국산 통나무 수공예 남원제기, 남원목기

자료가 도움이 되셨다면
혼수용품제수용품 필요시
남원제기 공식 홈페이지 http://남원제기.kr
남원목기 공식 홈페이지 http://otchil.kr
에서 구매 해 주세요
정성껏 모시겠습니다.
 

1. getsebool -a 하면 SELinux 의 모든 boolean 값에 대한 상태를 출력해준다.

 allow_polyinstantiation --> off
allow_postfix_local_write_mail_spool --> off
allow_ptrace --> off
allow_rsync_anon_write --> off
allow_saslauthd_read_shadow --> off
..............
..................
 
2. setsebool  -P allow_rsync_anon_write 1
    allow_rsync_anon_write --> on
 
3. SELinux 상태 변경을 요할 경우

1.     /etc/sysconfig/selinux 파일 수정

#vi /etc/sysconfig/selinux 에서 다음 파일 수정
           SELINUX=enforcing 을 disabled 나 permissive 로 수정

           기본 설정 값은 enforcing 로 되어 있다.
SELINUX=enforcing (사용함)
SELINUX=perimssive (보안경고만 사용)
SELINUX=disabled (사용안함)
           위 값 설정 후 시스템 재부팅

 

4. 현재 상태에서만 보안 설정에 대한 활성화 및 비활성화를 설정 할 수 있다.시스템 재부팅 후 원래 상태로 돌아 온다. (휘발성)

           

    #  setenforce 0     (비활성화 disabled)

    #  setenforce 1     (활성화 enforcing

 
5. SELinux 상태 상태 확인

           #sestatus –v

[root@selinux proc]# sestatus

 

SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   enforcing  <------ 보안모드
Mode from config file:          enforcing
Policy version:                 21
Policy from config file:        targeted

 

6. # ls -lZ 또는 ll -Z /etc/selinux

-rw-r--r--  root    root   system_u:object_r:selinux_config_t config

drwxr-xr-x  root    root   system_u:object_r:selinux_config_t targeted


           _u : 신분(identify)필드 , _r : 역할(role)필드 , _t :유형(type) 필드

 

7.  SELinux 문맥 변경

       문맥 변경 명령 chcon 을 이용한다.

       하위 디렉토리에 똑 같은 유형을 넣을 때 –R 옵션을 이용한다.


Centos -role file 위치: /etc/selinux/target/contexts/files/file_contexts

 

-t : 해당 파일에 대한 role 설정

-R : 하위 디렉토리 내 모든 파일에 대한 같은 role 설정


           # chcon –t httpd_user_content_t /home/www/index.htm


위 명령 chcon 명령을 이용하여 해당 /home/www/index.htm 파일에 httpd_user_content_t 유형을 설정

 


8. SELinux 문맥 복구

       변경된 문맥 복구를 위해서는 restorecon 명령을 이용 한다.


# restorecon –Rv /home/www/index.htm


[root@selinux data]# ls -lZ

-rw-r--r--  root     root     root:object_r:httpd_user_content_t index.htm

[root@selinux data]# restorecon -Rv index.htm

restorecon reset context /data/index.htm:root:object_r:httpd_user_content_t->system_u:object_r:default_t

[root@selinux data]# ls -lZ

-rw-r--r--  root     root     system_u:object_r:default_t      index.htm

 

9. SELinux 로그 파일

 

    SELinux log  ---> /var/log/audit/audit.log

 

           audit(timestamp) : SELinux 검사 메세지이며 타임 스탬프 형식으로 기록한다.
           avc : SELinux 벡터 캐시 액세스를 나타나며 거의모든 기록은 이 캐시이다.
           denied | accepted : 해당 액션이 허가되었는지 거부되었는지를 나타낸다.
           { read | write | unlink | .....} 이 필드는 파일을 읽기,쓰기, unlink 등 정책을 로딩등의 액션 종류을 출력'
           for pid=<PID> : 접근하는 액션의 프로세스 ID를 나타낸다.
           exe=<executable> : 실행되는 프로세스의 경로를 나타낸다.
           name=<name> : 액션을 시도하는 타켓의 이름을 나타낸다.
           dev=<device> : 타켓 파일이 위치한 디바이스를 나타낸다.
           ino=<inode-number> : 액션 타켓의 inode를 나타낸다.
           scontext=<security context> : 프로세스의 보안상태(문맥)을 나타낸다. 사용자,규칙,타입을 가지고 있다.
           tcontext=<target context> : 액션 타켓(파일이나 디렉토리등에 사용되는)의 보안상태(문맥)을 나타낸다.
           tclass=<target class> : 타켓 오브젝트(디렉토리,파일,디바이스,노드같은)의 클래스를 나타낸다.

 

▣로그를 분석해 보면..

SELinux 로그는 프로세스가 거부 되었을때 기록을 한다.(허거되었을때도 기록이 가능하지만)

기본정책이 거부를 허가로 변경해서도 로그를 기록할수도 있다.

아래는 SELinux의 로그 기록이다.(기본적으로 /var/log/messages에 기록된다.)


kernel: audit(1114070701.193:0): avc:  denied  { read } for  pid=24216 exe=/usr/libexec/mysqld

name=mysql dev=cciss/c0d0p6 ino=16408 scontext=user_u:system_r:mysqld_t

tcontext=root:object_r:var_lib_t tclass=dir


우선 읽기 요구를 거부하고 있다. (denied {read})

읽기 요구를 하는 프로셋의 ID는 24216이다. (for pid=24216)

프로세스 이름은 /usr/libexec/mysqld 이고, (exe=/usr/libexec/mysql name=mysql)

액션의 타켓은 /dev/cciss/c0d0p6 장치에서 실행되고 있다.)

액션 타켓의 inode는 16408이고, (ino=16408)

프로세스의 SELinux context는 user이고, mysqld 타입이다.(scontext=user_u:system_r:mysqld_t)

읽으려고 하는 파일은 var_lib_t 타  입의 루트 소유의 파일이다. (tcontext=root:object_r:var_lib_t)


해당 log 파일은 SELinux 활성화 및 /etc/rc.d/init.d/auditd 데몬이 활성화 되어 있어야 한다.


-       /etc/rc.d/init.d/auditd 는 chkconfig –list 및 setup 에서 확인 가능 ps –ef | grep auditd 데몬 확인

-       Auditd log 파일은 /var/log/audit/audit.log 에서 확인 가능

-       Avc 포함 된 log 는 SELinux 에 대한 권한 설정 및 보안 문제로 발생 한다. Messages 나 auditd 에.

 

!!SELinux 활성화시 auditd 와 같이 활성화 시켜 준다.

/etc/rc.d/init.d/auditd start


 ▣ SELinux yum 패키지 업데이트


           [root@selinux proc]# yum update selinux*


           selinux-policy-targeted-sources

           selinux-policy-targeted-sources.noarch 0:1.17.30-2.150.el4

          selinux-policy-targeted.noarch 0:1.17.30-2.150.el4

 


▣ SELinux 관리툴
           Semanage / setsebool / audit2allow


           #audit2allow –l –i /var/log/messages

           #audit2allow –d

           #audit2alllow –a

 

 

audit2allow -M 모듈명 < /var/log/audit/audit.log && semodule -i 모듈명.pp

 

=================

 

 

SELinux 관련 소프트웨어(툴)

policycoreutils

policycoreutils-gui

 

# sestatus -v
Once you have found your problem you can reset to the default mode by executing 
당신의
문제를 발견하시면 기본 모드로 실행하여 재설정 할 수 있습니다
# semodule -b /usr/share/selinux/targeted/base.pp
 
 
   

  1. 스팸어쎄신(spamassassin)은 설치 후 service등록과 업데이트를 한번 더 해 줘야 한다.

    Date2012.05.10 Category설치관련 By햇빛소년 Views29484
    Read More
  2. iptables 삭제명령

    Date2012.05.15 By햇빛소년 Views71453
    Read More
  3. chmod 파일 퍼미션의 다양한 조건들....

    Date2012.05.16 By햇빛소년 Views28507
    Read More
  4. cdcc 문서

    Date2012.05.30 By햇빛소년 Views32758
    Read More
  5. Red Hat / CentOS IPv6 Network Configuration

    Date2012.05.30 By햇빛소년 Views28092
    Read More
  6. DCC+razor2+pyzor how to ---[ spamassassin -D <test 2>debug ]

    Date2012.05.31 Category설치관련 By햇빛소년 Views31628
    Read More
  7. - FQDN - 올바른 Hostname 설정하기.

    Date2012.06.02 By햇빛소년 Views32835
    Read More
  8. DCC관련 명령어 모음

    Date2012.06.02 By햇빛소년 Views43924
    Read More
  9. selinux 관련 명령모음.

    Date2012.06.07 By햇빛소년 Views36271
    Read More
  10. SELinux Lockdown Part One: SELinux Users

    Date2012.06.07 By햇빛소년 Views35101
    Read More
  11. audit2allow라는 프로그램

    Date2012.06.08 By햇빛소년 Views30190
    Read More
  12. open(/var/dcc/map): Permission denied --- maillog에러 메세지 드디어 해결!!

    Date2012.06.09 By햇빛소년 Views31887
    Read More
  13. open(/var/dcc/map): Permission denied --- maillog에러 메세지 드디어 해결!! --제2편

    Date2012.06.09 By햇빛소년 Views31089
    Read More
  14. SELinux/audit2allow

    Date2012.06.11 By햇빛소년 Views33239
    Read More
  15. audit.log 관련...

    Date2012.06.15 By햇빛소년 Views28906
    Read More
  16. 리눅스의 데몬 설명

    Date2012.06.15 By햇빛소년 Views38043
    Read More
  17. procmail: Lock failure on "spamassassin.lock"

    Date2012.06.16 By햇빛소년 Views27019
    Read More
  18. /etc/security/pam_env.conf: No such file or directory

    Date2012.06.18 By햇빛소년 Views30138
    Read More
  19. procmail: Couldn't create or rename temp file "/var/spool/mail/spam/"

    Date2012.06.18 By햇빛소년 Views31403
    Read More
  20. passwd, groups, gpasswd 알아두면 좋을듯한 생소한 명령사용법.

    Date2012.06.19 By햇빛소년 Views27485
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 Next
/ 10