{"id":99543,"date":"2024-07-02T10:26:10","date_gmt":"2024-07-02T02:26:10","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=99543"},"modified":"2024-07-02T10:26:10","modified_gmt":"2024-07-02T02:26:10","slug":"linux-authority-ask","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-authority-ask.html","title":{"rendered":"Linux\u4e2d\u6743\u9650\u5217\u4e2d\u7684\u52a0\u53f7\u53ca\u70b9\u7684\u6df1\u5ea6\u89e3\u8bfb"},"content":{"rendered":"
\u4e00\u3001\u7efc\u8ff0<\/strong><\/div>\n

Linux\u4e2d\uff0cls -l\u547d\u4ee4\u53ef\u8c13\u662f\u6700\u5e38\u7528\u4e0d\u8fc7\u4e86\u3002\u547d\u4ee4\u663e\u793a\u7ed3\u679c\u4e2d\u7684\u7b2c\u4e00\u5217\u4e5f\u662f\u6211\u4eec\u6bd4\u8f83\u5173\u6ce8\u7684\u5730\u65b9\uff0c\u4e00\u822c\u8bf4\u6cd5\u662f\u8868\u793a\u6743\u9650\u7684\u5b57\u7b26\u536010\u4e2a\u4f4d\u7f6e\u3002\u53ef\u662f\uff0c\u6211\u4eec\u4e5f\u7ecf\u5e38\u770b\u5230\u5728\u8fd9\u4e00\u5217\u4e2d\u7b2c\u5341\u4e00\u4e2a\u4f4d\u7f6e\u4e5f\u6709\u5185\u5bb9\u663e\u793a\uff0c\u6700\u5e38\u89c1\u7684\u975e\u90a3\u4e2a\u70b9\uff08.\uff09\u83ab\u5c5e\u4e86\uff0c\u8fd8\u6709\u52a0\u53f7\uff08+\uff09\u4e5f\u4f1a\u51fa\u73b0\u5728\u8fd9\u4e2a\u4f4d\u7f6e\uff0c\u8fd9\u5230\u5e95\u662f\u600e\u4e48\u56de\u4e8b\u5462\uff1f\u8ba9\u6211\u4eec\u4eb2\u624b\u6765\u5b9e\u8df5\u4e00\u4e0b\u5427\uff1f<\/p>\n

\u4e8c\u3001\u5173\u4e8e\u6743\u9650\u5217\u5185\u7684\u70b9\uff08.\uff09<\/strong><\/div>\n

2.1 \u8ba9\u6211\u4eec\u6765\u770b\u4e00\u4e0b\u6839\u76ee\u5f55\u3002<\/strong><\/p>\n

\r\n[root@DCGH ~]# ls -lZ \/\r\nlrwxrwxrwx. root root system_u:object_r:bin_t:s0 bin -> usr\/bin\r\ndr-xr-xr-x. root root system_u:object_r:boot_t:s0 boot\r\ndrwxr-xr-x. root root system_u:object_r:device_t:s0 dev\r\ndrwxr-xr-x. root root system_u:object_r:etc_t:s0 etc\r\ndrwxr-xr-x. root root system_u:object_r:home_root_t:s0 home\r\nlrwxrwxrwx. root root system_u:object_r:lib_t:s0 lib -> usr\/lib\r\nlrwxrwxrwx. root root system_u:object_r:lib_t:s0 lib64 -> usr\/lib64\r\ndrwxr-xr-x. root root system_u:object_r:mnt_t:s0 media\r\ndrwxr-xr-x. root root system_u:object_r:mnt_t:s0 mnt\r\ndrwxr-xr-x. root root system_u:object_r:usr_t:s0 opt\r\ndr-xr-xr-x. root root system_u:object_r:proc_t:s0 proc\r\ndr-xr-x---. root root system_u:object_r:admin_home_t:s0 root\r\ndrwxr-xr-x. root root system_u:object_r:var_run_t:s0 run\r\nlrwxrwxrwx. root root system_u:object_r:bin_t:s0 sbin -> usr\/sbin\r\ndrwxr-xr-x. root root system_u:object_r:var_t:s0 srv\r\ndr-xr-xr-x. root root system_u:object_r:sysfs_t:s0 sys\r\ndrwxrwxrwt. root root system_u:object_r:tmp_t:s0 tmp\r\ndrwxr-xr-x. root root system_u:object_r:usr_t:s0 usr\r\ndrwxr-xr-x. root root system_u:object_r:var_t:s0 var\r\n<\/pre>\n

2.2 \u5728HOME\u76ee\u5f55\u5206\u522b\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\u548c\u76ee\u5f55\uff0c\u89c2\u5bdf\u6743\u9650\u4e86\u7b2c\u5341\u4e00\u4e2a\u4f4d\u7f6e\u7684\u8be6\u7ec6\u60c5\u51b5\u3002<\/strong><\/p>\n

[root@DCGH ~]# touch DCGH\r\n[root@DCGH ~]# mkdir DCGH-DIR\r\n[root@DCGH ~]# ls -l\r\n\u603b\u7528\u91cf 0\r\n-rw-r--r--. 1 root root 0 3\u6708 28 10:23 DCGH\r\ndrwxr-xr-x. 2 root root 6 3\u6708 28 10:24 DCGH-DIR\r\n<\/pre>\n

2.3 \u67e5\u770b\u672c\u673aSELinux\u72b6\u6001\uff0c\u5e76\u5217\u4e3e\u672c\u76ee\u5f55\u4e0b\u6587\u4ef6\u548c\u76ee\u5f55\u5173\u4e8eSELinux\u7684\u57fa\u672c\u60c5\u51b5\u3002<\/strong><\/p>\n

[root@DCGH ~]# getenforce\r\nEnforcing\r\n[root@DCGH ~]# ls -lZ\r\n-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 DCGH\r\ndrwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 DCGH-DIR\r\n<\/pre>\n

2.4 \u5173\u95edSELinux\uff0c\u518d\u521b\u5efa\u5b9e\u9a8c\u6587\u4ef6\u548c\u76ee\u5f55\uff0c\u518d\u6b21\u5217\u4e3e\u672c\u76ee\u5f55\u53ca\u6839\u4e0b\u6587\u4ef6\u548c\u76ee\u5f55\u5173\u4e8eSELinux\u7684\u57fa\u672c\u60c5\u51b5<\/strong>\u3002<\/p>\n

[root@DCGH ~]# sed -i \"s\/SELINUX=enforcing\/SELINUX=disabled\/g\" \/etc\/selinux\/config\r\n[root@DCGH ~]# reboot\r\n[root@DCGH ~]# getenforce\r\nDisabled\r\n[root@DCGH ~]# ls -lZ\r\n-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 DCGH\r\ndrwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 DCGH-DIR\r\n[root@DCGH ~]# touch DCGH-later\r\n[root@DCGH ~]# mkdir DCGH-later-dir\r\n[root@DCGH ~]# ls -lZ\r\n-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 DCGH\r\ndrwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 DCGH-DIR\r\n-rw-r--r-- root root ? DCGH-later\r\ndrwxr-xr-x root root ? DCGH-later-dir\r\n[root@DCGH ~]# ls -lZ \/\r\nlrwxrwxrwx. root root system_u:object_r:bin_t:s0 bin -> usr\/bin\r\ndr-xr-xr-x. root root system_u:object_r:boot_t:s0 boot\r\ndrwxr-xr-x root root ? dev\r\ndrwxr-xr-x. root root system_u:object_r:etc_t:s0 etc\r\ndrwxr-xr-x. root root system_u:object_r:home_root_t:s0 home\r\nlrwxrwxrwx. root root system_u:object_r:lib_t:s0 lib -> usr\/lib\r\nlrwxrwxrwx. root root system_u:object_r:lib_t:s0 lib64 -> usr\/lib64\r\ndrwxr-xr-x. root root system_u:object_r:mnt_t:s0 media\r\ndrwxr-xr-x. root root system_u:object_r:mnt_t:s0 mnt\r\ndrwxr-xr-x. root root system_u:object_r:usr_t:s0 opt\r\ndr-xr-xr-x root root ? proc\r\ndr-xr-x---. root root system_u:object_r:admin_home_t:s0 root\r\ndrwxr-xr-x root root ? run\r\nlrwxrwxrwx. root root system_u:object_r:bin_t:s0 sbin -> usr\/sbin\r\ndrwxr-xr-x. root root system_u:object_r:var_t:s0 srv\r\ndr-xr-xr-x root root ? sys\r\ndrwxrwxrwt. root root system_u:object_r:tmp_t:s0 tmp\r\ndrwxr-xr-x. root root system_u:object_r:usr_t:s0 usr\r\ndrwxr-xr-x. root root system_u:object_r:var_t:s0 var\r\n<\/pre>\n

\u901a\u8fc7\u4e0a\u9762\u7684\u4f8b\u5b50\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u51fa\u6765\uff0c\u8fd9\u4e2a\u70b9\uff08.\uff09\u4e0d\u662f\u6ca1\u6709\u7528\u7684\uff0c\u800c\u662f\u4f5c\u7528\u5de8\u5927\uff0c\u6211\u4eec\u5e73\u65f6\u6ca1\u600e\u4e48\u6ce8\u610f\u800c\u5df2\u3002\u5f00\u542fSELinux\u540e\u521b\u5efa\u7684\u6587\u4ef6\u548c\u76ee\u5f55\u90fd\u4f1a\u5728\u6743\u9650\u5217\u663e\u793a\u8fd9\u4e2a\u70b9\u7684\uff0c\u5173\u95edSELinux\u540e\u521b\u5efa\u7684\u6587\u4ef6\u548c\u76ee\u5f55\u5728\u6743\u9650\u5217\u662f\u4e0d\u4f1a\u663e\u793a\u8fd9\u4e2a\u70b9\u7684\uff0c\u4e4b\u524d\u521b\u5efa\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u4fdd\u6301\u4e0d\u53d8\u3002<\/p>\n

\u4e09\u3001\u5173\u4e8e\u6743\u9650\u5217\u7684\u52a0\u53f7\uff08+\uff09<\/strong><\/div>\n

3.1 \u4e86\u89e3\u8fc7Linux\u4e2dACL\u6743\u9650\u8bbe\u7f6e\u7684\u670b\u53cb\u5bf9\u4e8e\u8fd9\u4e2a\u52a0\u53f7\u80af\u5b9a\u4e0d\u964c\u751f\u3002\u4e0d\u8fc7\u8fd8\u662f\u8ba9\u6211\u4eec\u901a\u8fc7\u5b9e\u9a8c\u6765\u9a8c\u8bc1\u4e00\u4e0b\u3002<\/strong><\/p>\n

[root@DCGH ~]# setfacl -m u:dcgh:rwx *\r\n\r\n[root@DCGH ~]# ls -lZ\r\n\r\n-rw-rwxr--+ root root unconfined_u:object_r:admin_home_t:s0 DCGH\r\n\r\ndrwxrwxr-x+ root root unconfined_u:object_r:admin_home_t:s0 DCGH-DIR\r\n\r\ndrwxrwxr-x+ root root ? DCGH-DIR-later -rw-rwxr--+ root root ? DCGH-later\r\n\r\n[root@DCGH ~]# setfacl -b *\r\n\r\n[root@DCGH ~]# ls -lZ\r\n\r\n-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 DCGH\r\n\r\ndrwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 DCGH-DIR\r\n\r\ndrwxr-xr-x root root ? DCGH-DIR-later -rw-r--r-- root root ? DCGH-later\r\n<\/pre>\n

\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff0c\u52a0\u4e86ACL\u6743\u9650\u63a7\u5236\u4e4b\u540e\uff0c\u4e4b\u524d\u5177\u6709SELinux\u5c5e\u6027\u7684\u6587\u4ef6\u548c\u76ee\u5f55\u7684\u6743\u9650\u5217\u6700\u540e\u4e00\u4e2a\u4f4d\u7f6e\u5168\u90e8\u53d8\u6210\u4e86\u52a0\u53f7\uff08+\uff09\u3002\u79fb\u9664\u539f\u6765\u7684ACL\u6743\u9650\u4e4b\u540e\uff0c\u6062\u590d\u539f\u6837\u3002<\/p>\n

\u56db\u3001\u603b\u7ed3<\/strong><\/div>\n

4.1 Linux\u6743\u9650\u5217\u7684\u70b9\u4e0d\u662f\u65e0\u610f\u4e49\u5b57\u7b26\u3002\u5728\u5f00\u542fSELinux\u7684\u60c5\u51b5\u4e0b\u521b\u5efa\u7684\u76ee\u5f55\u548c\u6587\u4ef6\u6709\u5177\u6709\u8fd9\u4e2a\u70b9\uff0c\u6743\u9650\u5217\u6709\u8fd9\u4e2a\u70b9\u8bf4\u660e\u8be5\u76ee\u5f55\u6216\u6587\u4ef6\u4ee5\u53ca\u8bbe\u7f6e\u4e86SELinux\u76f8\u5173\u7684\u6743\u9650\u3002\u5728\u7981\u7528SELinux\u6743\u9650\u4e4b\u540e\uff0c\u5728\u4e4b\u524d\u5f00\u542fSELinux\u6743\u9650\u65f6\u521b\u5efa\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u4fdd\u6301\u539f\u6765\u7684\u6743\u9650\u4e0d\u4fbf\uff0c\u6743\u9650\u5217\u7684\u70b9\u4f9d\u7136\u663e\u793a\u3002\u65b0\u521b\u5efa\u7684\u76ee\u5f55\u6216\u6587\u4ef6\u5728\u6743\u9650\u5217\u65e0\u8fd9\u4e2a\u70b9\u663e\u793a\u3002<\/p>\n

4.2 \u6743\u9650\u5217\u4e2d\u6700\u540e\u4e00\u4e2a\u4f4d\u7f6e\u5982\u679c\u662f\u52a0\u53f7\uff0c\u8bf4\u660e\u8fd9\u4e2a\u76ee\u5f55\u6216\u6587\u4ef6\u5df2\u7ecf\u8bbe\u7f6e\u4e86ACL\u6743\u9650\u76f8\u5173\u7684\u5185\u5bb9\u3002\u5982\u679c\u52a0\u53f7\u5b58\u5728\uff0c\u5219\u5df2\u7ecf\u6709\u70b9\u7684\u76ee\u5f55\u6216\u6587\u4ef6\uff0c\u70b9\u7684\u663e\u793a\u4f1a\u88ab\u8986\u76d6\uff0c\u4f46\u539f\u6765\u7684SELinux\u5c5e\u6027\u4fdd\u6301\u4e0d\u53d8\u3002<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/blog.csdn.net\/solaraceboy\/article\/details\/79736242<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttps:\/\/lrxjmw.cn\/linux-authority-ask.html<\/a>\u7f16\u8f91\uff1a\u5f20\u96c4\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u4e00\u3001\u7efc\u8ff0 Linux\u4e2d\uff0cls -l\u547d\u4ee4\u53ef\u8c13\u662f\u6700\u5e38\u7528\u4e0d\u8fc7\u4e86\u3002\u547d\u4ee4\u663e\u793a\u7ed3\u679c\u4e2d\u7684\u7b2c\u4e00\u5217\u4e5f\u662f\u6211\u4eec\u6bd4\u8f83\u5173\u6ce8\u7684\u5730\u65b9\uff0c\u4e00\u822c\u8bf4 […]<\/p>\n","protected":false},"author":643,"featured_media":99546,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-99543","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\/99543","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\/643"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=99543"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/99543\/revisions"}],"predecessor-version":[{"id":99631,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/99543\/revisions\/99631"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/99546"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=99543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=99543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=99543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}