SELinux Log
SElinux Log
[root@localhost setest]# yum install setroubleshoot-server
[root@localhost setest]#servicee messagebus restart
[root@a23-0-0-100 ~]# vim /var/log/messages 에 들어가서 맨 마지막 부분으로가 에러 난 부분의 sealert부분을 복사해 명령어로 실행
sealert -l 3c13a852-458e-48ff-8a73-fe8528ef523e
위에 연습했을 때 바꾼 경로 다시 원래대로 변경
/setest -> /var/www/html
[root@a23-0-0-100 ~]# cd /var/www/html
[root@a23-0-0-100 html]# ls -Z setest.html
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 setest.html
> admin_home_t 로 변경하면 접속 불가능
[root@a23-0-0-100 html]# chcon -t admin_home_t setest.html
[root@a23-0-0-100 html]# ls -Z setest.html
-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 setest.html
> 에러 발생 후 메세지 확인 후 sealert 부분 복사 해서 명령어 실행
[root@a23-0-0-100 html]# vim /var/log/messages
[root@a23-0-0-100 html]# sealert -l 3c13a852-458e-48ff-8a73-fe8528ef523e
> 그러면 아래같은 메세지가 뜨는데 /sbin/restorecon -v /var/www/html/setest.html 이 부분을 명령어로 실행 후 웹브라우저 다시 실행하면 에러 났던 부분이 정상 작동 된다.
***** 플러그인 restorecon (99.5 confidence) 제안 *********************************
If 레이블을 수정하고자 합니다.
/var/www/html/setest.html 디폴트 레이블은 default_t이 되어야 합니다.
Then restorecon을 실행할 수 있습니다.
Do
# /sbin/restorecon -v /var/www/html/setest.html
[root@a23-0-0-100 html]# /sbin/restorecon -v /var/www/html/setest.html
> 특정 boolean 정책 조회
[root@a23-0-0-100 html]# getsebool -a
[root@a23-0-0-100 html]# semanage boolean -l
[root@a23-0-0-100 html]# getsebool httpd_can_sendmail
[root@a23-0-0-100 html]# vim /var/www/html/mail.php 안에 아래 내용 작성
<?php
$result = mail('root','selinux test','hello');
if($result){
echo "메일전송완료";
}else{
echo "메일전송실패";
}
?>
> php 없으면 yum 으로 받기
[root@a23-0-0-100 html]# yum install php
> 웹페이지 접속하면 메일전송실패 가 뜸
> boolean 정책 조회해보면 off, 비활성화 되어 있어서 메일전송실패 뜬걸 알 수있다.
[root@a23-0-0-100 html]# getsebool httpd_can_sendmail
httpd_can_sendmail --> off
[root@a23-0-0-100 html]# semanage boolean -l | grep "httpd_can_sendmail"
httpd_can_sendmail (비활성 , 비활성 ) Allow http daemon to send mail
> 성공시키려면 setsebool 을 아래처럼 설정 후 다시 확인해보면 메일전송완료가 뜨는 것을 확인 할 수 있다.
[root@a23-0-0-100 html]# setsebool httpd_can_sendmail true
> 외부에서 사용자계정으로 접속하기
>ftp_home_dir = 사용자 계정 접속 및 홈 디렉토리에 읽기와 쓰기 허용
[root@a23-0-0-100 vsftpd]# setsebool ftp_home_dir true
[root@a23-0-0-100 vsftpd]#