{"id":5127,"date":"2019-10-18T18:39:42","date_gmt":"2019-10-18T10:39:42","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=5127"},"modified":"2019-10-18T18:39:44","modified_gmt":"2019-10-18T10:39:44","slug":"semanage","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/semanage","title":{"rendered":"semanage\u547d\u4ee4 – \u5b89\u5168\u4e0a\u4e0b\u6587\u67e5\u8be2\u4e0e\u4fee\u6539"},"content":{"rendered":"\n

semanage\u547d\u4ee4\u662f\u7528\u6765\u67e5\u8be2\u4e0e\u4fee\u6539SELinux\u9ed8\u8ba4\u76ee\u5f55\u7684\u5b89\u5168\u4e0a\u4e0b\u6587\u3002SELinux\u7684\u7b56\u7565\u4e0e\u89c4\u5219\u7ba1\u7406\u76f8\u5173\u547d\u4ee4\uff1aseinfo\u547d\u4ee4\u3001sesearch\u547d\u4ee4\u3001getsebool\u547d\u4ee4\u3001setsebool\u547d\u4ee4\u3001semanage\u547d\u4ee4\u3002 <\/p>\n\n\n\n

\u8bed\u6cd5\u683c\u5f0f\uff1a<\/strong>semanage [\u53c2\u6570]<\/p>\n\n\n\n

\u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n
-l<\/td>\u67e5\u8be2 <\/td><\/tr>
-a<\/td>\u589e\u52a0\uff0c\u4f60\u53ef\u4ee5\u589e\u52a0\u4e00\u4e9b\u76ee\u5f55\u7684\u9ed8\u8ba4\u5b89\u5168\u4e0a\u4e0b\u6587\u7c7b\u578b\u8bbe\u7f6e <\/td><\/tr>
-m<\/td>\u4fee\u6539 <\/td><\/tr>
-d<\/td>\u5220\u9664 <\/td><\/tr><\/tbody><\/table>\n\n\n\n

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

\u67e5\u8be2\u4e00\u4e0b\/var\/www\/html\u7684\u9ed8\u8ba4\u5b89\u5168\u6027\u672c\u6587\u7684\u8bbe\u7f6e\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# semanage fcontext -l <\/pre>\n\n\n\n

\u7528semanage\u547d\u4ee4\u8bbe\u7f6e \/srv\/samba \u76ee\u5f55\u7684\u9ed8\u8ba4\u5b89\u5168\u6027\u672c\u6587\u4e3apublic_content_t\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# mkdir \/srv\/samba\nll -Zd \/srv\/samba \ndrwxr-xr-x  root root root:object_r:var_t      \/srv\/samba  <\/pre>\n\n\n\n

\u5982\u4e0a\u6240\u793a\uff0c\u9ed8\u8ba4\u7684\u60c5\u51b5\u5e94\u8be5\u662f var_t : <\/p>\n\n\n\n

[root@linuxcool ~]# semanage fcontext -l | grep '\/srv' \n\/srv\/.*                    all files   system_u:object_r:var_t:s0 \/srv\/([^\/]*\/)?ftp(\/.*)?    all files system_u:object_r:public_content_t:s0 \/srv\/([^\/]*\/)?www(\/.*)?    all files   system_u:object_r:httpd_sys_content_t:s0  \n\/srv\/([^\/]*\/)?rsync(\/.*)?   all files   system_u:object_r:public_content_t:s0 \n\/srv\/gallery2(\/.*)?         all files   system_u:object_r:httpd_sys_content_t:s0 \n\/srv   directory   system_u:object_r:var_t:s0   <\/pre>\n\n\n\n

\u4e0a\u9762\u5219\u662f\u9ed8\u8ba4\u7684 \/srv \u5e95\u4e0b\u7684\u5b89\u5168\u6027\u672c\u6587\u8d44\u6599\uff0c\u4e0d\u8fc7\uff0c\u5e76\u6ca1\u6709\u6307\u5b9a\u5230 \/srv\/samba: <\/p>\n\n\n\n

[root@linuxcool ~]# semanage fcontext -a -t public_content_t \"\/srv\/samba(\/.*)?\" \n[root@linuxcool ~]# semanage fcontext -l | grep '\/srv' \n\/srv\/samba(\/.*)?    all files  system_u:object_r:public_content_t:s0  <\/pre>\n\n\n\n

\u5c1d\u8bd5\u6062\u590d\u9ed8\u8ba4\u503c:<\/p>\n\n\n\n

[root@linuxcool ~]# restorecon -Rv \/srv\/samba* <\/pre>\n","protected":false},"excerpt":{"rendered":"

semanage\u547d\u4ee4\u662f\u7528\u6765\u67e5\u8be2\u4e0e\u4fee\u6539SELinux\u9ed8\u8ba4\u76ee\u5f55\u7684\u5b89\u5168\u4e0a\u4e0b\u6587\u3002SELinux\u7684\u7b56\u7565\u4e0e\u89c4\u5219\u7ba1\u7406\u76f8\u5173\u547d\u4ee4 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/5127"}],"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=5127"}],"version-history":[{"count":3,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/5127\/revisions"}],"predecessor-version":[{"id":5230,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/5127\/revisions\/5230"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=5127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=5127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=5127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}