{"id":264,"date":"2013-06-07T08:48:58","date_gmt":"2013-06-07T08:48:58","guid":{"rendered":"http:\/\/www.selinuxplus.com\/?p=264"},"modified":"2013-06-07T08:51:25","modified_gmt":"2013-06-07T08:51:25","slug":"selinux-%e7%ad%96%e7%95%a5%e5%8f%af%e4%bb%a5%e8%bf%99%e6%a0%b7%e5%86%99","status":"publish","type":"post","link":"http:\/\/www.selinuxplus.com\/?p=264","title":{"rendered":"selinux \u7b56\u7565\u53ef\u4ee5\u8fd9\u6837\u5199"},"content":{"rendered":"<p>\u4f60\u8fd8\u5728\u4e3aselinux\u7684\u7b56\u7565\u800c\u5fe7\u6101\u4e48\uff1f\u4e0b\u9762\u6765\u5206\u6790\u4e00\u4e2a\u5de5\u5177\uff0c\u8be5\u5de5\u5177\u53ef\u4ee5\u5feb\u901f\u7684\u5e2e\u5b9e\u73b0\u7b56\u7565\u7684\u751f\u6210\uff0c\u672c\u6587\u5c06\u4ece\u4f7f\u7528\u5230\u5b9e\u73b0\u7684\u89d2\u5ea6\u8fdb\u884c\u5206\u6790\uff0c\u6216\u8bb8\u5bf9\u4e8e\u4f60\uff0c\u53ea\u9700\u8981\u751f\u6210\u7b56\u7565\uff0c\u6216\u8bb8\u4f60\u8fd8\u5bf9\u5176\u539f\u7406\u611f\u5230\u597d\u5947\u3002\u90a3\u4e48\u4e0b\u9762\u5c31\u8f6c\u5165\u6b63\u9898\u8fdb\u884c\u7b80\u5355\u7b56\u7565\u4e4b\u6e38\uff0c\u8be5\u6587\u6863\u5c06\u5f62\u6210\u7cfb\u5217\u6765\u8bf4\u4e00\u8bf4SELINUX\u7b56\u7565\u3002\u6587\u7ae0\u5c3d\u53ef\u80fd\u7684\u901a\u4fd7\u6613\u61c2\u3002<\/p>\n<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904 <a href=\" http:\/\/www.selinuxplus.com\/?p=264\" title=\"selinuxplus.com\" target=\"_blank\">[By SELinux+]<\/a><br \/>\n1 \u7b56\u7565\u5de5\u5177<br \/>\n    \u5728F12\u6216rhel6\u4ee5\u540e\u90fd\u4f1a\u5b89\u88c5\u4e00\u4e2a\u8fd9\u6837\u7684\u5de5\u5177policycoreutils-gui\u3002\u4f60\u53ef\u4ee5\u68c0\u6d4b\u4e00\u4e0b\u4f60\u7684\u670d\u52a1\u5668\u4e0a\u6709\u6ca1\u6709\u8fd9\u4e2a\u8f6f\u4ef6\u5305\u3002\u5176\u5b9e\u4ed6\u53ea\u662fselinux\u751f\u6210\u7b56\u7565\u7684\u4e00\u90e8\u5206\u3002<br \/>\n\u5728\u4f7f\u7528\u8fd9\u4e2a\u5de5\u5177\u5f88\u7b80\u5355\uff0c\u9996\u5148\u5148\u627e\u5230\u4e00\u4e2a\u8f6f\u4ef6\u5305\uff0c\u6bd4\u5982icecast-2.3.2-5.fc15.x86_64.rpm\u7684\u8f6f\u4ef6\u5305\u3002<br \/>\n\u9996\u5148\u770b\u4e00\u4e0b\u8fd9\u4e2a\u8f6f\u4ef6\u5305\u7684\u4fe1\u606f<\/p>\n<pre class=\"lang:default decode:true \" >[root@localhost ~]# rpm -qi icecast Name        : icecast                      \r\nRelocations: (not relocatable) Version     : 2.3.2                             \r\nendor: Fedora Project Release     : 4.el5                      \r\nBuild Date: Wed 21 Oct 2009 07:28:35 PM CST Install Date: Mon 14 Mar 2011 01:01:22 PM CST   \r\nBuild Host: x86-4.fedora.phx.redhat.com \r\nGroup       : Applications\/Multimedia       \r\nSource RPM: icecast-2.3.2-4.el5.src.rpm <\/pre>\n<p>\u53ef\u4ee5\u6839\u636eicecast\u7684\u5b89\u88c5\u8def\u5f84\u5224\u65ad\u5176\u53ef\u6267\u884c\u7684\u547d\u4ee4\u5728\u54ea\u91cc\uff0c\u5229\u7528rpm \u2013qlf \u5224\u65ad\u5176\u53ef\u6267\u884c\u7684\u547d\u4ee4<\/p>\n<pre class=\"lang:default decode:true \" >[root@localhost setest]# rpm -qlf \/usr\/bin\/icecast\r\n\/etc\/icecast.xml\r\n\/etc\/logrotate.d\/icecast\r\n\/etc\/rc.d\/init.d\/icecast\r\n\/usr\/bin\/icecast\r\n\/usr\/share\/doc\/icecast-2.3.2\r\n<\/pre>\n<p>\u6839\u636e\u7ed3\u679c\u53ef\u4ee5\u770b\u5230\/usr\/bin\/icecast\u662f\u53ef\u6267\u884c\u7684\u6587\u4ef6<\/p>\n<p>2 \u751f\u6210\u7b56\u7565<br \/>\n\u4f7f\u7528seplogen \u5de5\u5177\u76f4\u63a5\u751f\u6210\u7b56\u7565<\/p>\n<pre class=\"lang:default decode:true \" >[root@localhost setest]# sepolgen \/usr\/bin\/icecast\r\nCreated the following files in:\r\n.\/\r\nicecast.te # \u6253\u5370\u5f3a\u5236\u6587\u4ef6\r\nicecast.if # \u63a5\u53e3\u6587\u4ef6\r\nicecast.fc # \u6587\u4ef6\u4e0a\u4e0b\u6587\u5b9a\u4e49\r\nicecast.sh # \u5efa\u7acb\u811a\u672c<\/pre>\n<p>\u8fd9\u6837\u5c31\u4f1a\u770b\u5230\u5f53\u524d\u6587\u4ef6\u5939\u4e0b\u751f\u6210\u56db\u4e2a\u6587\u4ef6<\/p>\n<pre class=\"lang:default decode:true \" >-rw-r--r--. 1 root root  309  7\u6708  6 09:22 icecast.fc\r\n-rw-r--r--. 1 root root 3177  7\u6708  6 09:22 icecast.if\r\n-rwxr-x---. 1 root root 1360  7\u6708  6 09:22 icecast.sh\r\n-rw-r--r--. 1 root root 1244  7\u6708  6 09:22 icecast.te<\/pre>\n<p>3 \u7b56\u7565\u8865\u5145<br \/>\n\u8fd9\u4e9b\u7b56\u7565\u6709\u6ca1\u6709\u6ca1\u6709\u987e\u53ca\u5230\u7684\u7b56\u7565\u573a\u666f\u5462\uff1f\u518d\u770b\u4e00\u4e0b\u8be5\u8f6f\u4ef6\u7684\u5b89\u88c5\u8def\u5f84\u3002<br \/>\n\u53ef\u4ee5\u4f7f\u7528rpm -qlf\u67e5\u770b\u8be5\u8f6f\u4ef6\u7684\u5b89\u88c5\u7684\u4f4d\u7f6e<\/p>\n<pre class=\"lang:default decode:true \" >[root@localhost setest]# rpm -qlf \/usr\/bin\/icecast\r\n\/etc\/icecast.xml\r\n\/etc\/logrotate.d\/icecast\r\n\/etc\/rc.d\/init.d\/icecast\r\n\/usr\/bin\/icecast\r\n\/usr\/share\/doc\/icecast-2.3.2\r\n\/usr\/share\/doc\/icecast-2.3.2\/AUTHORS\r\n\/usr\/share\/doc\/icecast-2.3.2\/COPYING\r\n\/usr\/share\/doc\/icecast-2.3.2\/ChangeLog<\/pre>\n<p>\u770b\u5230\/etc\/logrotate.d\/icecast\u7684\u4e00\u884c\uff0c\u53d1\u73b0icecast\u9700\u8981\u65e5\u5fd7\u8bbe\u7f6e\uff0c\u6253\u5f00\u8be5\u8bbe\u7f6e\u6587\u4ef6<\/p>\n<pre class=\"lang:default decode:true \" >[root@localhost setest]# more \/etc\/logrotate.d\/icecast \r\n\/var\/log\/icecast\/*log {\r\n    missingok\r\n    notifempty\r\n    sharedscripts\r\n    postrotate\r\n\t\/bin\/kill -HUP `cat \/var\/run\/icecast\/icecast.pid 2&gt;\/dev\/null` 2&gt; \/dev\/null || true\r\n    endscript\r\n}<\/pre>\n<p>\u5df2\u77e5logrotate\u662f\u4f5c\u4e3alogrotate_t\u7684\uff0c\u6240\u4ee5\u5728cecast.te\u4e2d\u6dfb\u52a0\uff1a<\/p>\n<pre class=\"lang:default decode:true \" >gen_require(`\r\n    type logrotate_t;\r\n')\r\nicecast_signal(logrotate_t)<\/pre>\n<p>\u540c\u6837\u770b\u5230icecast\u7684\u7a0b\u5e8f\u653e\u5728\/usr\/share\u76ee\u5f55\u4e0b<\/p>\n<pre class=\"lang:default decode:true \" >\/usr\/share\/doc\/icecast-2.3.2\r\n\/usr\/share\/doc\/icecast-2.3.2\/AUTHORS\r\n\/usr\/share\/doc\/icecast-2.3.2\/COPYING\r\n\/usr\/share\/doc\/icecast-2.3.2\/ChangeLog<\/pre>\n<p>\u5728icecast.fc\u4e2d\u6dfb\u52a0<\/p>\n<pre class=\"lang:default decode:true \" >\/usr\/share\/icecast(\/.*)?        gen_context(system_u:object_r:httpd_sys_content_t,s0)<\/pre>\n<p>\u5230\u8fd9\u91cc\u6574\u4e2a\u7b56\u7565\u4e5f\u5373\u5c06\u5b8c\u6210<br \/>\n\u4f7f\u7528icecast.sh\u7f16\u8bd1\u548c\u52a0\u8f7d\u7b56\u7565<\/p>\n<pre class=\"lang:default decode:true \" >sh icecast.sh\r\nBuilding and Loading Policy\r\n+ make -f \/usr\/share\/selinux\/devel\/Makefile\r\nCompiling targeted icecast module\r\n\/usr\/bin\/checkmodule:loading policy configuration from tmp\/icecast.tmp\r\n\/usr\/bin\/checkmodule:policy configuration loaded\r\n\/usr\/bin\/checkmodule:writing binary representation (version 10) to tmp\/icecast.mod\r\nCreating targeted icecast.pp policy package\r\nrm tmp\/icecast.mod tmp\/icecast.mod.fc\r\n+ \/usr\/sbin\/semodule -i icecast.pp<\/pre>\n<p>\u5982\u679c\u53d1\u73b0avc\u7684\u62d2\u7edd\u53ef\u4ee5\u662f\u4f7f\u7528audit2allow \u2013la\u5de5\u5177\u8fdb\u884c\u8c03\u8bd5<br \/>\n3 \u7b56\u7565\u751f\u6210\u5de5\u5177\u8bf4\u660e<br \/>\n<a href=\"http:\/\/www.selinuxplus.com\/wp-content\/uploads\/2013\/06\/seplogen.png\"><img loading=\"lazy\" src=\"http:\/\/www.selinuxplus.com\/wp-content\/uploads\/2013\/06\/seplogen-300x177.png\" alt=\"\" title=\"seplogen\" width=\"300\" height=\"177\" class=\"alignnone size-medium wp-image-266\" srcset=\"http:\/\/www.selinuxplus.com\/wp-content\/uploads\/2013\/06\/seplogen-300x177.png 300w, http:\/\/www.selinuxplus.com\/wp-content\/uploads\/2013\/06\/seplogen-150x88.png 150w, http:\/\/www.selinuxplus.com\/wp-content\/uploads\/2013\/06\/seplogen-400x236.png 400w, http:\/\/www.selinuxplus.com\/wp-content\/uploads\/2013\/06\/seplogen.png 971w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>4 Template\u6a21\u677f<br \/>\n\u7a0b\u5e8f\u7684\u6a21\u677f\u6765\u81ea\/usr\/share\/system-config-selinux\/templates\u76ee\u5f55\u4e0b<br \/>\n\u8fd9\u4e9b\u6587\u4ef6\u4fbf\u662f\u5bf9\u9ed8\u8ba4\u76ee\u5f55\u7684\u4e00\u4e2a\u6a21\u677f\u6587\u4ef6\u5bf9\u5e94\uff0c\u5e38\u89c1\u7684\u76ee\u5f55\u5982\u4e0a\u56fe\u6240\u793a\uff1a\/etc\uff0c\/var\/cache\uff0c\/var\/log,\/tmp\/,\/var,\/var\/run\/,\/var\/spool\u7b49<br \/>\n\u6587\u4ef6\u5206\u522b\u4e3a<\/p>\n<pre class=\"lang:default decode:true \" >[root@localhost templates]# ll *.py\r\n -rw-r--r--. 1 root root  1186 Aug 25  2010 boolean.py\r\n -rw-r--r--. 1 root root  3143 Aug 25  2010 etc_rw.py\r\n -rw-r--r--. 1 root root  7821 Aug 25  2010 executable.py\r\n -rw-r--r--. 1 root root   726 Aug 25  2010 __init__.py\r\n -rw-r--r--. 1 root root  1794 Aug 25  2010 network.py\r\n -rw-r--r--. 1 root root 49098 Aug 25  2010 polgen.py\r\n -rw-r--r--. 1 root root  3267 Aug 25  2010 rw.py\r\n -rw-r--r--. 1 root root  3829 Aug 25  2010 script.py\r\n -rw-r--r--. 1 root root  1313 Aug 25  2010 semodule.py\r\n -rw-r--r--. 1 root root  2797 Aug 25  2010 tmp.py\r\n -rw-r--r--. 1 root root  4164 Aug 25  2010 user.p\r\ny -rw-r--r--. 1 root root  3606 Aug 25  2010 var_cache.py\r\n -rw-r--r--. 1 root root  4263 Aug 25  2010 var_lib.py\r\n -rw-r--r--. 1 root root  3308 Aug 25  2010 var_log.py\r\n -rw-r--r--. 1 root root  2822 Aug 25  2010 var_run.py\r\n -rw-r--r--. 1 root root  3601 Aug 25  2010 var_spool.py<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4f60\u8fd8\u5728\u4e3aselinux\u7684\u7b56\u7565\u800c\u5fe7\u6101\u4e48\uff1f\u4e0b\u9762\u6765\u5206\u6790\u4e00&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[179,46],"_links":{"self":[{"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/posts\/264"}],"collection":[{"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=264"}],"version-history":[{"count":4,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/posts\/264\/revisions"}],"predecessor-version":[{"id":270,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/posts\/264\/revisions\/270"}],"wp:attachment":[{"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=264"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}