{"id":3646,"date":"2019-06-29T10:01:26","date_gmt":"2019-06-29T02:01:26","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=3646"},"modified":"2020-07-02T14:01:49","modified_gmt":"2020-07-02T06:01:49","slug":"chcon","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/chcon","title":{"rendered":"chcon\u547d\u4ee4 – \u4fee\u6539\u6587\u4ef6\u7684\u5b89\u5168\u4e0a\u4e0b\u6587"},"content":{"rendered":"\n

chcon\u547d\u4ee4\u662f\u4fee\u6539\u5bf9\u8c61\uff08\u6587\u4ef6\uff09\u7684\u5b89\u5168\u4e0a\u4e0b\u6587\uff0c\u6bd4\u5982\uff1a\u7528\u6237\u3001\u89d2\u8272\u3001\u7c7b\u578b\u3001\u5b89\u5168\u7ea7\u522b\u3002\u4e5f\u5c31\u662f\u5c06\u6bcf\u4e2a\u6587\u4ef6\u7684\u5b89\u5168\u73af\u5883\u53d8\u66f4\u81f3\u6307\u5b9a\u73af\u5883\u3002<\/p>\n\n\n\n

\u8bed\u6cd5\u683c\u5f0f: <\/strong> chcon [\u53c2\u6570] <\/p>\n\n\n\n

\u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n

-h<\/td>\u5f71\u54cd\u7b26\u53f7\u8fde\u63a5\u800c\u975e\u5f15\u7528\u7684\u6587\u4ef6 <\/td><\/tr>
-R<\/td>\u9012\u5f52\u5904\u7406\u6240\u6709\u7684\u6587\u4ef6\u53ca\u5b50\u76ee\u5f55 <\/td><\/tr>
-v<\/td>\u4e3a\u5904\u7406\u7684\u6240\u6709\u6587\u4ef6\u663e\u793a\u8bca\u65ad\u4fe1\u606f <\/td><\/tr>
-u<\/td>\u8bbe\u7f6e\u6307\u5b9a\u7528\u6237\u7684\u76ee\u6807\u5b89\u5168\u73af\u5883 <\/td><\/tr>
-r<\/td>\u8bbe\u7f6e\u6307\u5b9a\u89d2\u8272\u7684\u76ee\u6807\u5b89\u5168\u73af\u5883 <\/td><\/tr>
-t<\/td>\u8bbe\u7f6e\u6307\u5b9a\u7c7b\u578b\u7684\u76ee\u6807\u5b89\u5168\u73af\u5883 <\/td><\/tr>
-l<\/td>\u8bbe\u7f6e\u6307\u5b9a\u8303\u56f4\u7684\u76ee\u6807\u5b89\u5168\u73af\u5883 <\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n

\u53c2\u8003\u5b9e\u4f8b<\/strong><\/p>\n\n\n\n

\u628aftp\u5171\u4eab\u7ed9\u533f\u540d\u7528\u6237\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# chcon -R -t public_content_t \/var\/ftp <\/pre>\n\n\n\n

\u8bbe\u7f6e\u7684FTP\u76ee\u5f55\u53ef\u4ee5\u4e0a\u4f20\u6587\u4ef6\u7684\u8bdd\uff0cSELINUX\u9700\u8981\u8bbe\u7f6e\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# chcon -t public_content_rw_t \/var\/ftp\/incoming<\/pre>\n\n\n\n

\u5141\u8bb8\u7528\u6237HTTP\u8bbf\u95ee\u5176\u5bb6\u76ee\u5f55\uff0c\u8be5\u8bbe\u5b9a\u9650\u4ec5\u4e8e\u7528\u6237\u7684\u5bb6\u76ee\u5f55\u4e3b\u9875\uff1a <\/p>\n\n\n\n

[root@linuxcool ~]# chcon -R -t httpd_sys_content_t ~user\/public_html<\/pre>\n\n\n\n

\u5c06samba\u76ee\u5f55\u5171\u4eab\u7ed9\u5176\u4ed6\u7528\u6237\uff0c\u9700\u8981\u8bbe\u7f6e\uff1a <\/p>\n\n\n\n

[root@linuxcool ~]# chcon -t samba_share_t \/directory <\/pre>\n\n\n\n

<\/p>\n","protected":false},"excerpt":{"rendered":"

chcon\u547d\u4ee4\u662f\u4fee\u6539\u5bf9\u8c61\uff08\u6587\u4ef6\uff09\u7684\u5b89\u5168\u4e0a\u4e0b\u6587\uff0c\u6bd4\u5982\uff1a\u7528\u6237\u3001\u89d2\u8272\u3001\u7c7b\u578b\u3001\u5b89\u5168\u7ea7\u522b\u3002\u4e5f\u5c31\u662f\u5c06\u6bcf\u4e2a\u6587\u4ef6\u7684\u5b89\u5168\u73af\u5883\u53d8\u66f4 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/3646"}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=3646"}],"version-history":[{"count":3,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/3646\/revisions"}],"predecessor-version":[{"id":8134,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/3646\/revisions\/8134"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=3646"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=3646"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=3646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}