{"id":195542,"date":"2020-07-18T10:19:26","date_gmt":"2020-07-18T02:19:26","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=195542"},"modified":"2020-07-06T09:21:39","modified_gmt":"2020-07-06T01:21:39","slug":"disable-selinux","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/disable-selinux.html","title":{"rendered":"SELinux\u5982\u4f55\u6c38\u4e45\u7981\u7528"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u4f5c\u4e3aLinux\u5b89\u5168\u6a21\u5757(LSM)\u6846\u67b6\u7684\u4e00\u90e8\u5206\u5b9e\u73b0\uff0c\u8be5\u6846\u67b6\u53ef\u8bc6\u522b\u5404\u79cd\u5185\u6838\u5bf9\u8c61\u4ee5\u53ca\u5bf9\u8fd9\u4e9b\u5bf9\u8c61\u6267\u884c\u7684\u654f\u611f\u64cd\u4f5c\u3002\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u68c0\u67e5SELinux\u72b6\u6001\u7684\u6b65\u9aa4\uff0c\u5e76\u5b66\u4e60\u5982\u4f55\u5728CentOS\u6216RHEL\u6216Fedora\u7cfb\u7edf\u4e2d\u6765\u7981\u7528SELinux\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
1. \u524d\u8a00<\/strong><\/div>\n

\u672c\u6587\u4e3b\u8981\u8bb2\u89e3\u5982\u4f55\u4e34\u65f6\u6216\u6c38\u4e45\u5730\u7981\u7528SELinux\u3002<\/p>\n

\"\"<\/p>\n

Linux\u88ab\u8ba4\u4e3a\u662f\u5f53\u4eca\u6700\u5b89\u5168\u7684\u64cd\u4f5c\u7cfb\u7edf\u4e4b\u4e00\uff0c\u8fd9\u662f\u56e0\u4e3a\u5b83\u6770\u51fa\u7684\u5b89\u5168\u7279\u6027\uff0c\u5982SELinux(\u5b89\u5168\u589e\u5f3a\u7684Linux)\u3002<\/p>\n

\u5bf9\u4e8e\u521d\u5b66\u8005\uff0cSELinux\u88ab\u63cf\u8ff0\u4e3a\u5728\u5185\u6838\u4e2d\u6267\u884c\u7684\u5f3a\u5236\u8bbf\u95ee\u63a7\u5236(MAC)\u5b89\u5168\u7ed3\u6784\u3002SELinux\u63d0\u4f9b\u4e86\u4e00\u79cd\u5f3a\u5236\u6267\u884c\u67d0\u4e9b\u5b89\u5168\u7b56\u7565\u7684\u65b9\u6cd5\uff0c\u5426\u5219\u7cfb\u7edf\u7ba1\u7406\u5458\u5c06\u65e0\u6cd5\u6709\u6548\u5730\u5b9e\u73b0\u8fd9\u4e9b\u7b56\u7565\u3002<\/p>\n

\u5f53\u60a8\u5b89\u88c5RHEL\/CentOS\u6216\u5176\u4ed6\u884d\u751f\u5de5\u5177\u65f6\uff0cSELinux\u670d\u52a1\u662f\u9ed8\u8ba4\u542f\u7528\u7684\uff0c\u56e0\u6b64\u60a8\u7cfb\u7edf\u4e0a\u7684\u4e00\u4e9b\u5e94\u7528\u7a0b\u5e8f\u53ef\u80fd\u4e0d\u652f\u6301\u8fd9\u79cd\u5b89\u5168\u673a\u5236\u3002\u56e0\u6b64\uff0c\u8981\u4f7f\u6b64\u7c7b\u5e94\u7528\u7a0b\u5e8f\u6b63\u5e38\u8fd0\u884c\uff0c\u5fc5\u987b\u7981\u7528\u6216\u5173\u95edSELinux\u3002<\/p>\n

\u91cd\u8981\u63d0\u793a:\u5982\u679c\u60a8\u4e0d\u60f3\u7981\u7528SELinux\uff0c\u90a3\u4e48\u60a8\u5e94\u8be5\u9605\u8bfb\u4ee5\u4e0b\u5185\u5bb9\uff0c\u4ee5\u5b9e\u73b0\u5bf9\u6587\u4ef6\u548c\u670d\u52a1\u7684\u5f3a\u5236\u6027\u8bbf\u95ee\u63a7\u5236\uff0c\u4ee5\u4f7f\u5176\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n

\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u68c0\u67e5SELinux\u72b6\u6001\u7684\u6b65\u9aa4\uff0c\u5e76\u5728CentOS \u6216 RHEL\u6216Fedora\u4e2d\u7981\u7528SELinux\u3002<\/p>\n

\u9996\u5148\u8981\u505a\u7684\u662f\u68c0\u67e5\u7cfb\u7edf\u4e0aSELinux\u7684\u72b6\u6001\uff0c\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b8c\u6210\uff1a<\/p>\n

sestatus\r\n<\/pre>\n

\u63a5\u4e0b\u6765\uff0c\u5728\u7cfb\u7edf\u4e0a\u7981\u7528SELinux\uff0c\u8fd9\u53ef\u4ee5\u662f\u4e34\u65f6\u7684\uff0c\u4e5f\u53ef\u4ee5\u662f\u6c38\u4e45\u7684\uff0c\u8fd9\u53d6\u51b3\u4e8e\u60a8\u60f3\u8981\u5b9e\u73b0\u7684\u76ee\u6807\u3002<\/p>\n

2. \u5982\u4f55\u4e34\u65f6\u7981\u7528SELinux<\/strong><\/div>\n

\u8981\u4e34\u65f6\u7981\u7528SELinux\uff0c\u4ee5root\u7528\u6237\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff1a<\/p>\n

echo 0 > \/selinux\/enforce \r\n<\/pre>\n

\u6216\u8005\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528setenforce\u5de5\u5177\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n

setenforce 0\r\n<\/pre>\n

\u5426\u5219\uff0c\u4f7f\u7528Permissive\u9009\u9879\u800c\u4e0d\u662f0\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n

setenforce Permissive\r\n<\/pre>\n

\u4e0a\u8ff0\u65b9\u6cd5\u53ea\u5728\u4e0b\u4e00\u6b21\u91cd\u65b0\u5f15\u5bfc\u4e4b\u524d\u6709\u6548\uff0c\u56e0\u6b64\u8981\u6c38\u4e45\u7981\u7528SELinux\uff0c\u7ee7\u7eed\u5f80\u4e0b\u770b\u3002<\/p>\n

3. \u5982\u4f55\u6c38\u4e45\u7981\u7528SELinux<\/strong><\/div>\n

\u8981\u6c38\u4e45\u7981\u7528SELinux\uff0c\u8bf7\u4f7f\u7528\u60a8\u6700\u559c\u6b22\u7684\u6587\u672c\u7f16\u8f91\u5668\u6253\u5f00\/etc\/sysconfig\/selinux\u6587\u4ef6\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n

vi \/etc\/sysconfig\/selinux\r\n<\/pre>\n

\u7136\u540e\u5c06\u914d\u7f6eSELinux=enforcing\u6539\u4e3aSELinux=disabled\uff0c\u5982\u4e0b\u56fe\u6240\u793a\u3002<\/p>\n

SELINUX=disabled\r\n<\/pre>\n

\u7136\u540e\uff0c\u4fdd\u5b58\u5e76\u9000\u51fa\u6587\u4ef6\uff0c\u4e3a\u4e86\u4f7f\u914d\u7f6e\u751f\u6548\uff0c\u9700\u8981\u91cd\u65b0\u542f\u52a8\u7cfb\u7edf\uff0c\u7136\u540e\u4f7f\u7528sestatus\u547d\u4ee4\u68c0\u67e5SELinux\u7684\u72b6\u6001\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n

sestatus\r\n<\/pre>\n
4. \u603b\u7ed3<\/strong><\/div>\n

\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u8bb2\u8ff0\u4e86\u5982\u4f55\u5728CentOS\u6216RHEL\u6216Fedora\u4e0a\u7981\u7528SELinux\u7684\u7b80\u5355\u6b65\u9aa4\u3002\u53e6\u5916\uff0c\u4e86\u89e3\u66f4\u591a\u5173\u4e8eSELinux\u7684\u4fe1\u606f\u5c06\u975e\u5e38\u6709\u5e2e\u52a9\uff0c\u7279\u522b\u662f\u5bf9\u4e8e\u90a3\u4e9b\u5bf9\u63a2\u7d22Linux\u4e2d\u7684\u5b89\u5168\u7279\u6027\u611f\u5174\u8da3\u7684\u4eba\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u672c\u6587\u4e3b\u8981\u8bb2\u89e3\u5982\u4f55\u4e34\u65f6\u6216\u6c38\u4e45\u5730\u7981\u7528SELinux\u3002 Linux\u88ab\u8ba4\u4e3a\u662f\u5f53\u4eca\u6700\u5b89\u5168\u7684\u64cd\u4f5c\u7cfb\u7edf\u4e4b\u4e00\uff0c\u8fd9\u662f\u56e0\u4e3a\u5b83\u6770\u51fa\u7684 […]<\/p>\n","protected":false},"author":1329,"featured_media":195544,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-195542","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/195542","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1329"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=195542"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/195542\/revisions"}],"predecessor-version":[{"id":195547,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/195542\/revisions\/195547"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/195544"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=195542"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=195542"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=195542"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}