{"id":3893,"date":"2012-01-31T21:45:39","date_gmt":"2012-01-31T12:45:39","guid":{"rendered":"http:\/\/mimumimu.net\/blog\/?p=3893"},"modified":"2012-04-21T18:22:43","modified_gmt":"2012-04-21T09:22:43","slug":"selinux-%e3%81%a7-restorecon-%e3%81%97%e3%81%a6%e3%81%82%e3%81%86%e3%81%82%e3%81%86%e3%80%82","status":"publish","type":"post","link":"https:\/\/mimumimu.net\/blog\/2012\/01\/31\/selinux-%e3%81%a7-restorecon-%e3%81%97%e3%81%a6%e3%81%82%e3%81%86%e3%81%82%e3%81%86%e3%80%82\/","title":{"rendered":"SELinux \u3067 restorecon \u3057\u3066\u3042\u3046\u3042\u3046\u3002"},"content":{"rendered":"<p>\u3082\u3046\u3001\u6bce\u56de\u306e\u3054\u3068\u304f\u5fd8\u308c\u308b\u306e\u3067\u3001\u5099\u5fd8\u9332\u3002<\/p>\n<p>\u52d5\u304b\u306a\u3044 \u2013&gt; \/var\/log\/audit\/audit.log* \u3092\u898b\u306b\u884c\u304f\u3002    <br \/>\u6bce\u5ea6\u306e\u3054\u3068\u304f\u300c\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u304c\u3061\u3052\u30fc\u305c\u304a\u5144\u3055\u3093\u300d\u3068\u66f8\u304b\u308c\u3066\u308b\u3002<\/p>\n<p>\u305d\u306e\u3068\u304d\u306b\u3001 chcon \u3067\u7247\u4ed8\u3051\u3066\u3057\u307e\u3046\u306e\u304c\u79c1\u306e\u3072\u3069\u304f\u60aa\u3044\u7656\uff57<\/p>\n<p>\u3044\u3084\u306d\u3001\u306a\u3093\u304b\u306e\u62cd\u5b50\u306b restorecon \u3057\u3066\u3001    <br \/>\u3076\u3063\u98db\u3070\u3057\u3066\u3057\u307e\u3046\u308f\u3051\u3067\u3059\u3088\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u305d\u308c\u3082\u542b\u3081\u3066\u5e45\u5e83\u304f\u3001\u3044\u308d\u3044\u308d\u5099\u5fd8\u9332\u3002<\/p>\n<p>&#160;<\/p>\n<h3>\uff0a\u30d5\u30a1\u30a4\u30eb\u95a2\u9023\u3002<\/h3>\n<h4>chcon (<u>CH<\/u>ange file selinux security <u>CON<\/u>text)<\/h4>\n<p>\u30d5\u30a1\u30a4\u30eb\u3068\u304b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u5909\u3048\u308b\u3002    <br \/><u><strong>\u4e00\u6642\u7684\u306b<\/strong><\/u>\u305d\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u5bfe\u3057\u3066\u3001<u>\u7279\u5b9a\u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u5272\u308a\u5f53\u3066\u308b\u6642\u306b\u4f7f\u3046<\/u>\u3068\u826f\u3055\u305d\u3046<\/p>\n<p># chcon \u2013t httpd_sys_content_t \/home\/hogehoge\/public_html\/ \u2013R    <\/p>\n<p>&#160;<\/p>\n<h4>ls \u2013aZ<\/h4>\n<p>\u30d5\u30a1\u30a4\u30eb\u30fb\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u8868\u793a\u3059\u308b\u3002    <br \/>\u30fb\u30fb\u8981\u306f Z \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u3064\u3051\u308b\u3002<\/p>\n<p># ls \u2013Z   <br \/>drwxr-xr-x. hogehoge hogehoge unconfined_u:object_r:httpd_user_content_t:s0 public_html    <\/p>\n<h4>&#160;<\/h4>\n<h4>restorecon (<u>RESTORE<\/u> file(s) default selinux security <u>CON<\/u>text)<\/h4>\n<p>\u30d5\u30a1\u30a4\u30eb\u3068\u304b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u30c7\u30d5\u30a9\u30eb\u30c8\u8a2d\u5b9a\u306b\u623b\u3059\u3002    <br \/>\u5f8c\u8ff0\u3059\u308b semanage \u3067\u6052\u4e45\u7684\u306b\u5909\u66f4\u3057\u305f\u5834\u5408\u306f\u3001\u305d\u306e\u8a2d\u5b9a\u306b\u623b\u308b\u3002<\/p>\n<p><u>(chcon \u306e\u5909\u66f4\u306f\u3001restorecon \u3067\u5fa9\u5143\u3055\u308c\u308b\u969b\u306b\u7834\u68c4\u3055\u308c\u308b\u3002)<\/u><\/p>\n<p># restorecon \/home\/hogehoge\/public_html\/ \u2013R    <\/p>\n<h4>&#160;<\/h4>\n<h4>semanage (<u>SE<\/u>linux&#160; policy <u>MANAGE<\/u>ment tool)<\/h4>\n<p>\u30d5\u30a1\u30a4\u30eb\u3068\u304b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u306f\u3058\u3081\u3068\u3059\u308b\u3001\u69d8\u3005\u306a\u8a2d\u5b9a\u3092<u><strong>\u6052\u4e45\u7684\u306b<\/strong><\/u>\u5909\u66f4\u3059\u308b\u3002     <br \/>\u3053\u306e\u30b3\u30de\u30f3\u30c9\u3067\u5909\u66f4\u3057\u305f\u5185\u5bb9\u306f\u3001\u4eca\u5f8c\u3082\u30c7\u30d5\u30a9\u30eb\u30c8\u8a2d\u5b9a\u3068\u3057\u3066\u4fdd\u6301\u3055\u308c\u308b\u3002<\/p>\n<p>\uff08\u30dd\u30fc\u30c8\u306b\u95a2\u3057\u3066\u306f\u5f8c\u8ff0\uff09<\/p>\n<p>\u8a2d\u5b9a\u53d6\u5f97 ( \u2013l \u3092\u4f7f\u3046 ) :   <br \/># semanage fcontext \u2013l<\/p>\n<p>\u8ffd\u52a0 ( \u2013a \u3092\u4f7f\u3046 )\uff1a    <br \/># semanage fcontext \u2013a \u2013t httpd_sys_content_t \u201c\/home\/hogehoge\/public_html\/(\/.*)?\u201d<\/p>\n<p>\u524a\u9664 ( \u2013d \u3092\u4f7f\u3046 )\uff1a    <br \/># semanage fcontext \u2013d \u2013t httpd_sys_content_t \u201c\/home\/hogehoge\/public_html\/(\/.*)?\u201d<\/p>\n<p>\u53cd\u6620\u3055\u305b\u308b ( restorecon \u3092\u4f7f\u3046 ):    <br \/># restorecon \/home\/hogehoge\/public_html\/ \u2013RF<\/p>\n<p>&#160;<\/p>\n<h3>\uff0a\u5b9f\u884c\u6a29\u9650\u95a2\u9023\u3002<\/h3>\n<h4>setenforce ( modify the mode selinux is running in. )<\/h4>\n<p>Enforcing (\u5236\u7d04\u304c\u65bd\u884c\u3055\u308c\u3066\u308b\u72b6\u614b) \u3068 Permissive (\u5236\u7d04\u304c\u65bd\u884c\u3055\u308c\u3066\u3044\u306a\u3044[\u8a31\u53ef\u3055\u308c\u3066\u3044\u308b] \u72b6\u614b)    <br \/>\u306e2\u3064\u3092<u><strong>\u4e00\u6642\u7684\u306b<\/strong><\/u>\u5207\u308a\u66ff\u3048\u308b\u3002<\/p>\n<p>\u6052\u4e45\u7684\u306b\u5909\u66f4\u3059\u308b\u5834\u5408\u306f\u3001 \/etc\/selinux\/config \u306e SELINUX \u3092\u66f8\u304d\u63db\u3048\u308b\u3002<\/p>\n<p>\u6709\u52b9\u306b\u3059\u308b\uff1a    <br \/># setenforce 1<\/p>\n<p>\u7121\u52b9\u306b\u3059\u308b\uff1a    <br \/># setenforce 0<\/p>\n<p>&#160;<\/p>\n<h4>getenforce ( <u>GET<\/u> the current mode of selinux )<\/h4>\n<p>\u73fe\u5728\u3001\u5236\u7d04\u304c\u65bd\u884c\u3055\u308c\u3066\u3044\u308b (Enforcing) \u304b\u8a31\u53ef\u3055\u308c\u3066\u3044\u308b (Permissive) \u304b\u3001    <br \/>\u305d\u3082\u305d\u3082\u52d5\u3044\u3066\u306a\u3044\u304b (Disable) \u3092\u8fd4\u3059\u3002<\/p>\n<p># getenforce    <br \/>Enforcing<\/p>\n<p>&#160;<\/p>\n<h4>setsebool (<u>SET<\/u> <u>SE<\/u>linux <u>BOOL<\/u>ean value)<\/h4>\n<p>\u30dd\u30ea\u30b7\u30fc\u3092\u5909\u66f4\u3057\u3066\u3001\u7279\u5b9a\u306e\u52d5\u4f5c\u3092\u8a31\u53ef\u3057\u305f\u308a\u4e0d\u8a31\u53ef\u306b\u3057\u305f\u308a\u3068\u3044\u3046\u8a2d\u5b9a\u304c\u3067\u304d\u308b\u3002<\/p>\n<p># setsebool \u2013P ftp_home_dir on<\/p>\n<p>&#160;<\/p>\n<h4>getsebool (<u>GET<\/u> <u>SE<\/u>linux <u>BOOL<\/u>ean value)<\/h4>\n<p>\u30dd\u30ea\u30b7\u30fc\u3092\u53d6\u5f97\u3057\u305f\u308a\u3001\u5168\u5217\u6319\u3057\u305f\u308a\u3059\u308b\u3002<\/p>\n<p>\u5168\u5217\u6319\uff1a   <br \/># getsebool \u2013a<\/p>\n<p>\u7279\u5b9a\u306e\u8981\u7d20\u3092\u53d6\u5f97\uff1a   <br \/># getsebool ftp_home_dir<\/p>\n<p>&#160;<\/p>\n<h4>ps \u2013Z<\/h4>\n<p>\u30d7\u30ed\u30bb\u30b9\u306e\u30c9\u30e1\u30a4\u30f3\u3092\u53d6\u5f97\u3059\u308b\u3002   <br \/>\u30fb\u30fb\u30fb\u8981\u306f \u2013Z \u3092\u3064\u3051\u308b\u3002<\/p>\n<p># ps \u2013Z   <br \/>unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 15287 pts\/0 00:00:00 bash<\/p>\n<p>&#160;<\/p>\n<h3>\uff0a\u901a\u4fe1\u30dd\u30fc\u30c8\u95a2\u9023<\/h3>\n<h4>semanage (<u>SE<\/u>linux policy <u>MANAGE<\/u>ment tool)<\/h4>\n<p>\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u306f\u5148\u8ff0\u3002\u30d7\u30ed\u30bb\u30b9\u304c\u4f7f\u7528\u3059\u308b\u30dd\u30fc\u30c8\u306a\u3093\u304b\u3082\u3053\u3053\u3067\u8a2d\u5b9a\u3002<\/p>\n<p>\u30dd\u30fc\u30c8\u306e\u8a2d\u5b9a\u3092\u53d6\u5f97\uff1a   <br \/># semanage port \u2013l<\/p>\n<p>\u30dd\u30fc\u30c8\u306e\u8a2d\u5b9a\u3092\u8ffd\u52a0 ( FTP \u3092 11111 \u30dd\u30fc\u30c8\u3067\u52d5\u4f5c\u53ef\u80fd\u306b\u3059\u308b )   <br \/># semanage port \u2013a \u2013t ftp_port_t \u2013p tcp 11111<\/p>\n<p>\u30dd\u30fc\u30c8\u306e\u8a2d\u5b9a\u524a\u9664   <br \/># semanage port \u2013d \u2013t ftp_port_t \u2013p tcp 11111<\/p>\n<p>&#160;<\/p>\n<p>\u3068\u308a\u3042\u3048\u305a\u3001\u3053\u3093\u306a\u611f\u3058\u3067\u3002\u3067\u3042\u3067\u3042\u3002   <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3082\u3046\u3001\u6bce\u56de\u306e\u3054\u3068\u304f\u5fd8\u308c\u308b\u306e\u3067\u3001\u5099\u5fd8\u9332\u3002 \u52d5\u304b\u306a\u3044 \u2013&gt; \/var\/log\/audit\/audit.log* \u3092\u898b\u306b\u884c\u304f\u3002 \u6bce\u5ea6\u306e\u3054\u3068\u304f\u300c\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u304c\u3061\u3052\u30fc\u305c\u304a\u5144\u3055\u3093\u300d\u3068\u66f8\u304b\u308c\u3066\u308b\u3002 \u305d\u306e\u3068\u304d\u306b\u3001 chcon \u3067\u7247 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[88,89],"class_list":["post-3893","post","type-post","status-publish","format-standard","hentry","category-unix-linux","tag-restorecon","tag-selinux"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/mimumimu.net\/blog\/wp-json\/wp\/v2\/posts\/3893","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mimumimu.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mimumimu.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mimumimu.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mimumimu.net\/blog\/wp-json\/wp\/v2\/comments?post=3893"}],"version-history":[{"count":0,"href":"https:\/\/mimumimu.net\/blog\/wp-json\/wp\/v2\/posts\/3893\/revisions"}],"wp:attachment":[{"href":"https:\/\/mimumimu.net\/blog\/wp-json\/wp\/v2\/media?parent=3893"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mimumimu.net\/blog\/wp-json\/wp\/v2\/categories?post=3893"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mimumimu.net\/blog\/wp-json\/wp\/v2\/tags?post=3893"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}