Blog >> linux >> whitepapers.
selinux 설정
APM 설치를 위한 사전 selinux 설정.
enforcing, permissive, disabled 세 가지 정책을 설정.
enforcing의 경우 보안 정책을 적용하는 것이고, permissive의 경우는 경고만 보여주고, disabled는 아예 로딩 하지 않는 것. 먼저 selinux 상태 확인을 위한
~]# sestatus
### 혹은 ###
~]# getenforce
# 임시 설정 변경
~]# setenforce 0 # permissive
~]# setenforce 1 # enforcing
# 영구적인 설정 변경
~]# vi /etc/selinux/configBashselinux 설정을 확인하기 위해 context 조회 semanage 설치 여부 확인.
패키지 명 조회하고, 설치
~]# dnf provides */semanage
~]# dnf list policycoreutils-python-utils
~]# dnf install policycoreutils-python-utils.noarchBashSELinux 컨텍스트 조회
SELinux 컨텍스트는 파일, 디렉토리 및 프로세스에 적용되는 보안 레이블.
컨텍스트는 사용자, 역할, 유형, 수준으로 구성.
SELinux 컨텍스트는 SELinux 정책에 따라 접근 제어를 수행하는 데 사용.
SELinux 정책에 위배되는 접근 시도는 차단
# 파일/디렉토리 컨텍스트 조회 : ls -Z 명령어를 사용하여 컨텍스트를 확인
~]# ls -Z /etc/passwd
# 프로세스 컨텍스트 조회 : ps -Z <프로세스ID> 또는 ps -eZ 사용
~]# ps -Z 1234 # 1234는 프로세스 ID 또는
~]# ps -eZ # 모든 프로세스 컨텍스트 조회
# 전체 시스템에 등록되어 있는 컨텍스트 정보 확인
~]# semanage fcontext -l
# 특정 파일시스템 유형 컨텍스트 확인
~]# semanage fcontext -l | grep httpd_sys_content_t
# HTTPD 관련 파일시스템 컨텍스트 확인
~]# semanage fcontext -l | grep httpd
~]# semanage fcontext -l | grep /var/www
~]# semanage fcontext -l | grep /home
# 관련 컨텍스트
~]# semanage fcontext -l | grep /host
.....
/host(/.*)? all files system_u:object_r:httpd_sys_content_t:s0
/host/[^/]+/public_html(/.*)? all files system_u:object_r:httpd_sys_rw_content_t:s0
/host/[^/]+/public_html(/.*)?/\.htaccess regular file system_u:object_r:httpd_user_htaccess_t:s0
/host/lost\+found directory system_u:object_r:lost_found_t:s0
.....Bashcp, mv 복사하거나 잘라내기를 해도 컨텍스트는 원래의 것을 따른다.
컨텍스트가 A인 파일을 컨텍스트가 B인 디렉터리에 복사해도 컨텍스트는 A이고, 잘라내기를 해도 마찬가지다.
# 컨텍스트를 변경할 때 쓰는 옵션
~]# chcon -t
# /home/user1/public_html 의 디렉터리를 httpd_sys_content_t 유형의 컨텍스트파일로 변경
~]# chcon -t httpd_sys-context_t /home/user1/public_html
# cp, mv 복사하거나 잘라내기를 해도 컨텍스트는 원래의 것을 따른다.
# 컨텍스트가 A인 파일을 컨텍스트가 B인 디렉터리에 복사해도 컨텍스트는 A이고, 잘라내기를 해도 마찬가지다.
.....
/host(/.*)? all files system_u:object_r:public_content_rw_t:s0
/host/lost\+found/.* all files <<None>>
/host/lost\+found directory system_u:object_r:lost_found_t:s0Bash- 포스트 태그:
- getenforce
- semanage
- sestatus
- 포스트 위치:
- linux
- whitepapers
<< 이전 페이지



