Skip to menu

리눅스 관련 모음

본문시작

2012.06.07 15:24

selinux 관련 명령모음.

Views 36271 Votes 0 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print

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

자료가 도움이 되셨다면
혼수용품제수용품 필요시
남원제기 공식 홈페이지 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
 
 
   

List of Articles
No. Category Subject Author Date Views
190 Apache-2.4.X 에서 mod_evasive-1.10.1 설치시 나오는 에러 해결... secret 햇빛소년 2013.01.11 0
189 PHP5.3 가동후 에러 메세지 secret 햇빛소년 2013.01.13 0
188 PHP CodeSniffer 코딩검사 secret 햇빛소년 2013.01.14 0
187 modcurity 에러메세지 secret 햇빛소년 2013.01.17 0
186 apache2.x.x 컴파일 에러 해결 - /usr/local/lib/liblua.a: could not read symbols: Bad value secret 햇빛소년 2013.01.19 0
185 /etc/init.d/proftpd 실행 스크립트 secret 햇빛소년 2013.06.19 0
184 [Linux Password 정책변경] linux 비밀번호 md5에서 SHA-512로 변경하기 secret 햇빛소년 2013.06.30 0
183 LGU+ 결제 Mserver 설치관련 에러 사항..... secret 햇빛소년 2013.07.18 0
182 메일계정 관련 명령어... secret 햇빛소년 2013.08.19 0
181 'post-create' on '/var/spool/abrt/................................... secret 햇빛소년 2013.08.28 0
180 XE 데이터 이전시 "댓글" 사라지는 문제 해결... secret 햇빛소년 2014.02.13 0
179 zone_resigninc:dns_journal_open -> unexpected error secret 햇빛소년 2015.02.07 0
178 [mysql] 에러 메세지 - RSA private key file not found: /mysql/data//private_key.pem. Some authentication plugins will not work. secret 햇빛소년 2014.01.20 1
177 당신이 대통령이어선 안 되는 이유 -- 청와대에 올라 온 글 [펌] secret 햇빛소년 2014.04.28 1
176 mysql 컴파일 설치 후 해야 할 일... secret 햇빛소년 2014.02.23 4
175 [mysql]에러 메세지- #1146 - Table 'mysql.innodb_index_stats' doesn't exist 해결 secret 햇빛소년 2014.01.17 157
174 IPv6 비활성화 방법 햇빛소년 2023.04.01 315
173 기가인터넷 CAT.6 인터넷 속도 100Mb 인식 문제 해결 햇빛소년 2023.03.17 342
172 그누보드 영카트 대신택배 배송조회 깨짐 현상 정확한 URL 링크 주소. 햇빛소년 2022.08.23 346
171 win8.1 F8 안전모드 부팅하기 햇빛소년 2015.02.22 740
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 Next
/ 10