
我是 SELiunx 概念的新手,根據RHEL7 > SELinux 使用者和管理者指南 > 3.2。無限制過程
審核日誌
type=IPC msg=audit(1624375715.312:4225): ouid=0 ogid=0 mode=0666 obj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
type=PROCTITLE msg=audit(1624375715.312:4225): proctitle=2F7573722F7362696E2F6874747064002D44464F524547524F554E44
type=AVC msg=audit(1624375724.580:4226): avc: denied { unix_read unix_write } for pid=25626 comm="httpd" key=1392707921 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 tclass=shm permissive=0
type=SYSCALL msg=audit(1624375724.580:4226): arch=c000003e syscall=29 success=no exit=-13 a0=53030951 a1=4338 a2=1b6 a3=6b items=0 ppid=25612 pid=25626 auid=4294967295 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null)
我已將 httpd 變更為在unconfind_t
網域中運行,但現在無法將 httpd 變更回httpd_t
網域。
我將 httpd 設定為unconfined_t
網域以使shmget
函數正常工作,由 httpd 託管的一個 php 進程呼叫。
[user@rhel7 ~]$ sudo chcon -t bin_t /usr/sbin/httpd
[user@rhel7 ~]$ ls -Z /usr/sbin/httpd
-rwxr-xr-x. root root system_u:object_r:bin_t:s0 /usr/sbin/httpd
[user@rhel7 ~]$ systemctl start httpd.service
……
[root@rhel7 user]# chcon -r system_r -t httpd_t /usr/sbin/httpd
chcon: failed to change context of ‘/usr/sbin/httpd’ to ‘system_u:system_r:httpd_t:s0’: Permission denied
[root@rhel7 user]#
答案1
您應該能夠運行restorecon -v /usr/sbin/httpd
將其恢復為預設值。
如果您想手動更改它,那麼您需要使用httpd_exec_t
作為文件的類型。
答案2
我遇到了類似的問題,在 RH 8.5 上以 root 身份登入時,我無法將文件更改為unconfined_t
.我意識到使用unconfined_t
並不是「解決」問題的正確方法。正確的方法是按照上述使用者的建議,使文件成為現有的正確類型的一部分,然後用於semanage fcontext
使該變更持久化,或定義新的類型和安全性策略。就您而言,您不需要新的政策,因為httpd_t
合適。
我試圖將新服務的類型更改為unconfined_t
.同樣,理想情況下我應該創建一個全新的類型和策略,但這超出了我能做的範圍。但:
chcon -t unconfined_t my_file
正在給予許可被拒絕。
對於其他尋求解決方案的人來說,我所做的是:
# setenforce 0
# chcon -t unconfined_t my_file
# setenforce 1
# getenforce
Enforcing
我不確定這是正確的方法,但它確實讓我完成了工作,稍後我將編寫一個新策略並找出用於它的類型。