SELINUX에 대하여 - 2편-
작성자 정보
- 웹관리자 작성
- 작성일
컨텐츠 정보
- 10,330 조회
- 0 추천
- 목록
본문
SELINUX에 대하여 - 2편- | ||
| ||
차례(전체목차)1. SELInux(Security-Enhanced Linux) 란?2. SELinux 정책이란 무엇인가? 3. SELinux 설치여부 확인 4. SELinux 기본설정 - /etc/sysconfig/selinux 5. SELinux 서비스 설정 - setenforce 6. SELinux 서비스 설정 - chcon 7. SELinux 서비스 설정 - setsebool 8. 사용중인 정책을 교체하는 방법은? 9. SELinux LOG 10. Audit2allow 11. avc : denied 12. 참고문헌 또는 URL | ||
| ||
"setenforce 0" 이라고 명령을 내리는것은 SELINUX=permissive 와 동일한 결과이며, "setenforce 1" 은 enforcing 모드를 의미한다. 시스템에서 SELinux 를 완전히 사용하지 않으려면 /etc/sysconfig/selinux 파일에서 SELINUX=disabled 처럼 설정하거나 시스템 부팅시에 부트로더의 파라미터로 selinux=0 이라고 주고 부팅하면 된다. (grub 을 사용하는 경우라면 grub 화면에서 e 를 누르고 편집모드로 들어간뒤에 kernel 줄의 맨 뒤에 selinux=0 을 적어주고 ESC, 그리고 b 를 눌러서 부팅하면 된다.) sentenforce 명령은 sysadm_r 권한을 갖고 수행해야 한다; 그러기 위해, newrole 명령을 사용하거나, 아니면, su -를 사용하여 root 로 사용자 전환을 하면, 자동으로 sysadm_r 권한을 얻을 수 있다. | ||
| ||
아파치를 사용중에 분명히 디렉토리를 생성했는데도 에러가 난다면 아래처럼 http_user_content_t 를 해당 DocumentRoot 에 적용해줌으로 해결해 줄수있다. chcon -R -t httpd_user_content_t /home/사용자계정/public_html | ||
| ||
allow_ypbind=1 dhcpd_disable_trans=0 httpd_disable_trans=1 httpd_enable_cgi=1 httpd_enable_homedirs=1 httpd_ssi_exec=1 httpd_tty_comm=0 httpd_unified=1 mysqld_disable_trans=0 named_disable_trans=1 named_write_master_zones=1 nscd_disable_trans=1 ntpd_disable_trans=0 portmap_disable_trans=0 postgresql_disable_trans=0 snmpd_disable_trans=0 squid_disable_trans=0 syslogd_disable_trans=0 winbind_disable_trans=0 ypbind_disable_trans=0 RHEL4의 경우 전환가능한 시스템의 SELinux 설정값들을 나타내는 파일은 /etc/selinux/targeted/booleans 파일이다. 파일안의 각 항목은 system-config-securitylevel 이라는 어플리케이션이나 setsebool 이라는 명령을 이용해서 변경시킬수 있으며 setsebools 을 이용하는 경우 -P 옵션을 사용하지 않으면 설정파일은 변경되지 않고 현재의 설정만 바뀌지만 -P 옵션을 같이 사용하면 /etc/selinux/targeted/booleans 파일의 내용까지 같이 변경되어 시스템 리부팅후에도 적용된다. | ||
| ||
연구 목적으로 시험 장비(test machine)에서 새 정책을 시도하는 이외, 생산 시스템(production system)에서는 다른 정책으로 교체하기 전에 현황을 심각하게 고려해야 한다. 교체 작업은 간단하다. 이는 매우 안전한 방법이지만, 우선 시험 시스템에서 일차 시도해 보는 것이 바람직하다. 한 가지 방법은 system-config-securitylevel을 사용하여 정책을 바꾸고 재명명(relabel)하도록 파일 시스템을 설정하는 것이다. 수작업 절차는 다음과 같다: 1. /etc/selinux/config을 편집하고 SELINUXTYPE=policyname으로 정책 유형을 바꾼다. 2. 재부팅하여 돌아올 수 있는 지 확인하기위해, SELINUX=permissive모드로 설정한다. 이렇게 하면, SELinux는 정확한 정책하에서 가동될 것이지만, 만일 부정확한 파일 문맥 명명(labeling)과 같은 문제가 있으면 로그인하도록 할 것이다. 3. sysadm_r 역할을 갖춘 root로 파일 시스템을 재명명한다(relabel): id -Z root:sysadm_r:sysadm_t fixfiles relabel 4. 시스템을 재부팅한다. 새 정책하에서의 재시작은 모든 시스템 프로세스가 적절한 문맥에서 시작되고 정책 변경으로 인한 모든 문제가 드러나게 한다. 5. sestatus -v 명령으로 발효된 변경사항을 확인한다. Permissive 모드로 가동된 새 시스템에서, avc: denied 메시지를 /var/log/messages에서 확인한다. 이들은 새 정책하에 문제없이 시스템이 가동되도록 해결해야 할 문제들을 표시해 준다. 6. 새 정책하에서 시스템이 만족스럽게 돌아갈 때, SELINUX=enforcing 으로 바꿔 실행 권한을 부여한다. 실시간에 enforcing을 활성화 시키기 위해 재부팅하거나 setenforce 1 을 실행한다. | ||
| ||
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 이 로그는 아래와 같이 해석할수 있다. - 읽기 요청이 거부되었다. - PID 24216을 가진 프로세스가 read를 시도한다 - 해당프로세스는 /usr/libexec/mysqld 이다 - /dev/cciss/c0d0p6 에서 작동되고 있다 - inode 는 16408이다. - 프로세스의 SELinux 문맥은 user_u:system_r:mysqld_t 이다. - tcontext=root:object_r:var_lib_t : 이파일이 읽기를 시도하는 파일은 var_lib_t 타입의 root 소유파일이다. SELinux LOG 각 항목의 의미 audit(timestamp) - This field states that it's an audit message from SELinux and that it was logged at timestamp time (in seconds since Jan. 1st, 1970). avc - This message was from the SELinux access vector cache. Pretty much every message you are likely to see is from this cache. denied | accepted - This field indicates whether the action was denied or accepted. You may see logs of accepted messages in some cases (like reloading the policy). { read | write | unlink | ... } - This field shows the type of action that was attempted, such as reading a file, writing, unlinking, loading policy, etc. for pid=<pid> - This is the process ID that attempted the action. exe=<executable>- This is the path to the executable that started the process. name=<name> - This is the name of the target on which the action was attempted. dev=<device> - This is the device on which the target file is located. ino=<inode-number> - This is the inode of the target of the action. scontext=<security context> - This is the process's security context. This contains user, role, and type. tcontext=<target context> - This is the security context of the target of this action, for example, the file, directory, etc. tclass=<target class> - This is the class of the target object, such as directory, file, device node, or something else. | ||
| ||
audit2allow명령은 세가지 방법으로 입력을 받을 수 있다. 기본은 표준입력 (stdin)이다. -i 옵션을 사용하면 /var/log/messages 로부터 입력을 읽을 수 있고 -d옵션을 사용하면 dmesg 출력으로부터 입력을 읽을 수 있다. | ||
| ||
| ||
| ||
The Un-Official SELinux FAQ - http://www.crypt.gen.nz/selinux/faq.html SELinux link zoo - http://www.crypt.gen.nz/selinux/links.html Ubuntu Linux SELinux pages - https://www.ubuntulinux.org/wiki/SELinux 2005.8 Sys Admin Magazine - http://www.samag.com/documents/s=9820/sam0508a/0508a.htm NSA SELinux FAQ - http://www.nsa.gov/selinux/info/faq.cfm SELinux community page - http://selinux.sourceforge.net UnOfficial FAQ - http://www.crypt.gen.nz/selinux/faq.html Writing SE Linux policy HOWTO - https://sourceforge.net/docman/display_doc.php?docid=21959&group_id=21266 Getting Started with SE Linux HOWTO: the new SE Linux (Debian) - https://sourceforge.net/docman/display_doc.php?docid=20372&group_id=21266 | ||
![]() |
관련자료
-
이전
-
다음