﻿{"id":144,"date":"2009-07-25T13:20:48","date_gmt":"2009-07-25T13:20:48","guid":{"rendered":""},"modified":"2011-11-18T16:58:13","modified_gmt":"2011-11-18T08:58:13","slug":"144","status":"publish","type":"post","link":"http:\/\/zerobox.org\/notes\/144.html","title":{"rendered":"\u89e3\u8bfbLinux\u6587\u4ef6\u6743\u9650\u7684\u8bbe\u7f6e\u65b9\u6cd5"},"content":{"rendered":"<p><span style=\"font-size: x-small;\">Windows\u7cfb\u7edf\u5176\u5b9e\u548cLinux\u7cfb\u7edf\u6709\u76f8\u4f3c\u7684\u5730\u65b9\uff0cWindows\u7cfb\u7edf\u6587\u4ef6\u3001\u76ee\u5f55\u7684\u5c5e\u6027\u6709\u53ea\u8bfb\u3001\u9690\u85cf\uff0c\u800cLinux\u4e5f\u4e00\u6837\u3002<\/span><\/p>\n<p>Linux\u4e2d\uff0c\u6bcf\u4e00\u4e2a\u6587\u4ef6\u90fd\u5177\u6709\u7279\u5b9a\u7684\u5c5e\u6027\u3002\u4e3b\u8981\u5305\u62ec\u6587\u4ef6\u7c7b\u578b\u548c\u6587\u4ef6\u6743\u9650\u4e24\u4e2a\u65b9\u9762\u3002\u53ef\u4ee5\u5206\u4e3a5\u79cd\u4e0d\u540c\u7684\u7c7b\u578b\uff1a\u666e\u901a\u6587\u4ef6\u3001\u76ee\u5f55\u6587\u4ef6\u3001\u94fe\u63a5\u6587\u4ef6\u3001\u8bbe\u5907\u6587\u4ef6\u548c\u7ba1\u9053\u6587\u4ef6\u3002<\/p>\n<p>\u6240\u8c13\u7684\u6587\u4ef6\u6743\u9650\uff0c\u662f\u6307\u5bf9\u6587\u4ef6\u7684\u8bbf\u95ee\u6743\u9650\uff0c\u5305\u62ec\u5bf9\u6587\u4ef6\u7684\u8bfb\u3001\u5199\u3001\u5220\u9664\u3001\u6267\u884c\u3002Linux \u662f\u4e00\u4e2a\u591a\u7528\u6237\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5b83\u5141\u8bb8\u591a\u4e2a\u7528\u6237\u540c\u65f6\u767b\u5f55\u548c\u5de5\u4f5c\u3002\u56e0\u6b64 Linux \u5c06\u4e00\u4e2a\u6587\u4ef6\u6216\u76ee\u5f55\u4e0e\u4e00\u4e2a\u7528\u6237\u6216\u7ec4\u8054\u7cfb\u8d77\u6765\u3002\u8bbf\u95ee\u63a7\u5236\u5217\u8868(ACL\uff1aAccess Control List)\u4e3a\u8ba1\u7b97\u673a\u63d0\u4f9b\u66f4\u597d\u7684\u8bbf\u95ee\u63a7\u5236\uff0c\u5b83\u7684\u4f5c\u7528\u662f\u9650\u5236\u5305\u62ecroot\u7528\u6237\u5728\u5185\u7684\u6240\u6709\u7528\u6237\u5bf9\u6587\u4ef6\u3001<span class=\"t_tag\" onclick=\"tagshow(event)\">\u8d44\u6e90<\/span>\u6216\u8005\u5957\u63a5\u5b57\u7684\u8bbf\u95ee\u3002\u4e0b\u9762\u5c31\u6765\u6559\u5927\u5bb6\u7b80\u5355\u7684\u8bbe\u7f6e\u65b9\u6cd5\u3002<\/p>\n<p>\u6b65\u9aa41 \u68c0\u67e5\u7cfb\u7edf\u6838\u5fc3<\/p>\n<p>\u9996\u5148\u68c0\u67e5\u4f60\u7684Linux\u7cfb\u7edf\u7684\u6838\u5fc3\u662f\u5426\u6709\u652f\u6301ACL\u7684\u529f\u80fd\u3002\u56e0\u4e3aLinux\u7cfb\u7edf\u5e76\u4e0d\u662f\u6bcf\u4e00\u4e2a\u7248\u672c\u7684\u6838\u5fc3\u90fd\u6709\u652f\u6301ACL\u7684\u529f\u80fd\uff0c\u800c\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u5c31\u662f\u68c0\u67e5\u7cfb\u7edf\u76ee\u524d\u7684\u6838\u5fc3\u80fd\u5426\u652f\u6301\uff1a<\/p>\n<p>[root@mail \/]# cat \/boot\/config-kernel-version | grep -i ext3<\/p>\n<p>CONFIG_EXT3_FS=m<\/p>\n<p>CONFIG_EXT3_IDEX=y<\/p>\n<p>CONFIG_EXT3_FS_XATTR_SHARING=y<\/p>\n<p>CONFIG_EXT3_FS_XATTR_USER=y<\/p>\n<p>CONFIG_EXT3_FS_XATTR_TRUSTED=y<\/p>\n<p>CONFIG_EXT3_FS_ACL=y<\/p>\n<p>\u6b64\u65f6\u5982\u679c\u80fd\u770b\u5230\u4e0a\u9762\u7684\u51e0\u9879\u5219\u8868\u793a\u5df2\u7ecf\u7f16\u8bd1\u5230\u6838\u5fc3\u4e2d,ext3\u6587\u4ef6\u7cfb\u7edf\u5df2\u652f\u6301ACL\u529f\u80fd\uff0c\u8fd9\u4e9b\u529f\u80fd\u5728\u7f16\u8bd1\u6838\u5fc3\u9009\u9879\u4e2d\u90fd\u53ef\u4ee5\u627e\u5230\u3002\u5982\u679c\u7f16\u8bd1\u65f6\u627e\u4e0d\u5230\uff0c\u53ef\u4ee5\u5230ACL\u7684\u5b98\u65b9\u7f51\u7ad9\u6765\u5b89\u88c5Kernel(acl.bestbits.at\/)\u3002<\/p>\n<p>\u6b65\u9aa42 \u6302\u8f7d\u5206\u533a<\/p>\n<p>\u4f60\u53ef\u4ee5\u7528\u4e0b\u5217\u7684\u65b9\u5f0f\u6302\u8f7d\u5206\u533a\u5e76\u542f\u7528ACL\uff1a<\/p>\n<p>#mount -t ext3 -o acl \/dev\/sda1 \/fs1<\/p>\n<p>\u4f60\u4e5f\u53ef\u4ee5\u76f4\u63a5\u5199\u5728\/etc\/fstab\u6587\u4ef6\u4e2d,\u8fd9\u6837\u5c31\u53ef\u4ee5\u5728\u5f00\u673a\u540e\u652f\u6301ACL\u529f\u80fd\uff1a<\/p>\n<p>#vi \/etc\/fstab<\/p>\n<p>\u6b65\u9aa43 \u8bbe\u7f6eACL\u6743\u9650<\/p>\n<p>ACL\u5e38\u5e38\u9488\u5bf9\u4e2a\u522b\u7528\u6237\u6765\u8fdb\u884c\u8bbe\u7f6e\uff0c\u4e0b\u9762\u662f\u591a\u4e2a\u4e0d\u540c\u7684\u4f8b\u5b50\uff1a<\/p>\n<p>\u4f8b\u5982\u9700\u8981\u521b\u5efatest1\u3001test2\u3001test3\u4e09\u4e2a\u7528\u6237\uff0c\u53ef\u4ee5\u5148\u7528root\u8eab\u4efd\u767b\u5f55\u7cfb\u7edf\uff0c\u7136\u540e\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u5206\u522b\u521b\u5efa\u4e09\u4e2a\u7528\u6237\u540d\u548c\u5bc6\u7801\uff1a<\/p>\n<p>[root@mail root]#adduser test1<br \/>\n[root@mail root]#adduser test2<br \/>\n[root@mail root]#adduser test3<br \/>\n[root@mail root]#passwd test1<br \/>\n[root@mail root]#passwd test2<br \/>\n[root@mail root]#passwd test3<\/p>\n<p>\u7136\u540emount\u4e00\u4e2aext3\u6587\u4ef6\u5230\u76ee\u5f55\/fs1\uff1a<br \/>\n[root@mail root]#mount -t ext3 -o acl \/dev\/sda1 \/fs1<\/p>\n<p>\u518d\u5c06test1 \u5efa\u7acb\u7684\u6587\u4ef6\u8bbe\u7f6e\u8bfb\u5199\u7684\u6743\u9650\u7ed9test2 \uff1a<br \/>\n[root@mail root]#chmod -R 777 \/fs1<\/p>\n<p>\u8ba9\u6240\u6709\u7684\u7528\u6237\u90fd\u80fd\u589e\u52a0\u6587\u4ef6\u5230\u76ee\u5f55\u7684\u6743\u9650\uff1a<\/p>\n<p>\u5148\u7528test1\u767b\u5f55\u7cfb\u7edf\uff0c\u6267\u884c\u547d\u4ee4\uff1a<br \/>\n[test1@mail test1]# cd \/fs1<br \/>\n[test1@mail fs1]# echo &#8220;Create by test1&#8221; &gt; test1.txt<br \/>\n[test1@mail fs1]# chmod go-r test1.txt<br \/>\n[test1@mail fs1]# ll test1.txt<br \/>\n-rw&#8212;&#8212;- 1 test1 test1 17 Jul 14 22:11 test1.txt<\/p>\n<p>\u800c\u5982\u4e0b\u64cd\u4f5c\u5219\u53ef\u4ee5\u8ba9\u9664\u4e86test1\u6709\u8bfb\u5199\u7684\u6743\u9650\u5916\u5176\u4ed6\u4eba\u6ca1\u6709\u8bfb\u5199test1.txt\u7684\u6743\u9650\uff08root\u9664\u5916\uff09\uff0c\u5148\u7528test2 \u767b\u5f55\u7cfb\u7edf\u540e\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<br \/>\n[test2@mail test2]# cd \/fs1<br \/>\n[test2@mail fs1]# cat test1.txt<br \/>\ncat : test1.txt Permission denied<\/p>\n<p>\u63a5\u7740\u7528test1\u767b\u5f55\u7cfb\u7edf\uff0c\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff1a<br \/>\n[test1@mail fs1]# setfacl -m u:test2:rw test1.txt<\/p>\n<p>\u8fd9\u6837\u5c31\u4fee\u6539\u6743\u9650\u5141\u8bb8test2 \u6709\u8fd9\u4e2a\u6587\u4ef6\u7684\u8bfb\u5199\u6743\u9650\u3002\u518d\u770b\u4e00\u4e0b\u5b83\u7684\u6587\u4ef6\u5c5e\u6027\u7684\u53d8\u5316\uff1a<br \/>\n[test1@mail fs1]# ll<br \/>\n-rw-rw-r&#8211;+ 1 test1 test1 10 Feb 16 13:52 test1.txt<\/p>\n<p>\u4f1a\u770b\u5230\u540e\u9762\u591a\u4e86\u4e00\u4e2a\u201c+\u201d\uff0c\u8868\u793a\u8fd9\u4e2a\u6587\u4ef6\u4f7f\u7528ACL\u7684\u5c5e\u6027\u8bbe\u7f6e\uff0c\u518d\u7528\u547d\u4ee4getfacl\u6765\u770bACL\u7684\u6587\u4ef6\u5c5e\u6027\u8bbe\u7f6e\uff1a<br \/>\n[test1@mail fs1]# getfacl test1.txt<br \/>\n# file: test1.txt<br \/>\n# owner: test1<br \/>\n# group: test1<br \/>\nuser::rw-<br \/>\nuser:test2:rw-<br \/>\ngroup::rw-<br \/>\nmask::rw-<br \/>\nother::r&#8211;<\/p>\n<p>\u53ef\u4ee5\u770b\u5230 test2 \u6709\u6743\u9650\u8bfb\u5199\u8fd9\u4e2a\u6587\u4ef6\u3002<\/p>\n<p>\u6211\u4eec\u518d\u7528test2\u767b\u5f55\u7cfb\u7edf\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u770b\u770b\u53d1\u751f\u4e86\u4ec0\u4e48\uff1f<br \/>\n[test2@mail test2]# cd \/fs1<br \/>\n[test2@mail fs1]# cat test1.txt<br \/>\nCreate by test1<\/p>\n<p>\u539f\u6765test2\u53ef\u4ee5\u8bfb\u53d6test1.txt\u6587\u4ef6\u4e86\u3002<br \/>\n[test2@mail fs1]# echo &#8220;Modify by test2&#8221; &gt;&gt; test1.txt<br \/>\n[test2@mail fs1]# cat test1.txt<br \/>\nCreate by test1<br \/>\nModify by test2<\/p>\n<p>\u73b0\u5728test2\u4e5f\u53ef\u4ee5\u4fee\u6539test1.txt\u6587\u4ef6\u4e86\u3002<\/p>\n<p>\u63a5\u7740\u7528test3 \u767b\u5f55\u7cfb\u7edf\uff1a<br \/>\n[test3@mail test3]# cd \/fs1<br \/>\n[test3@mail fs1]# cat test1.txt<br \/>\ncat : test1.txt Permission denied<\/p>\n<p>\u5475\u5475\uff0c\u5f53\u7136\uff0c\u9664\u4e86test1\u3001test2\u5916\u6ca1\u6709\u5176\u4ed6\u7528\u6237\u6709\u8bfb\u5199test1.txt\u7684\u6743\u9650\uff08root \u9664\u5916\uff09\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Windows\u7cfb\u7edf\u5176\u5b9e\u548cLinux\u7cfb\u7edf\u6709\u76f8\u4f3c\u7684\u5730\u65b9\uff0cWindows\u7cfb\u7edf\u6587\u4ef6\u3001\u76ee\u5f55 &hellip;<\/p>\n<p class=\"read-more\"><a href=\"http:\/\/zerobox.org\/notes\/144.html\">\u7ee7\u7eed\u9605\u8bfb &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[29],"class_list":["post-144","post","type-post","status-publish","format-standard","hentry","tag-linux-2"],"views":810,"_links":{"self":[{"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/posts\/144","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/comments?post=144"}],"version-history":[{"count":0,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/posts\/144\/revisions"}],"wp:attachment":[{"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/media?parent=144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/categories?post=144"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/tags?post=144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}