chcon: '/usr/sbin/httpd' のコンテキストを変更できません。権限が拒否されました。

chcon: '/usr/sbin/httpd' のコンテキストを変更できません。権限が拒否されました。

私は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をドメインで実行するように変更しましたが、今度はhttpdをドメインunconfind_tに戻すことはできません。httpd_t

httpdがホストするPHPプロセスによって呼び出される関数が機能unconfined_tするようにhttpdをドメインに設定しました。shmget

[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種類として使用する必要があります。

おすすめ記事