{"id":138967,"date":"2019-03-15T08:15:36","date_gmt":"2019-03-15T00:15:36","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=138967"},"modified":"2019-03-04T14:16:15","modified_gmt":"2019-03-04T06:16:15","slug":"firejail-linux","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/firejail-linux.html","title":{"rendered":"\u5982\u4f55\u5728Linux\u4e2d\u4f7f\u7528Firejail\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f"},"content":{"rendered":"
\u6709\u65f6\u60a8\u53ef\u80fd\u5e0c\u671b\u4f7f\u7528\u5728\u4e0d\u540c\u73af\u5883\u4e2d\u672a\u7ecf\u8fc7\u826f\u597d\u6d4b\u8bd5\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u4f46\u60a8\u5fc5\u987b\u4f7f\u7528\u5b83\u4eec\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5173\u6ce8\u7cfb\u7edf\u7684\u5b89\u5168\u6027\u662f\u6b63\u5e38\u7684\u3002\u5728Linux\u4e2d\u53ef\u4ee5\u505a\u7684\u4e00\u4ef6\u4e8b\u662f\u5728\u6c99\u7bb1\u4e2d\u4f7f\u7528\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n
\u201c\u6c99\u76d2\u201d\u662f\u5728\u6709\u9650\u73af\u5883\u4e2d\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u7684\u80fd\u529b\u3002\u8fd9\u6837\uff0c\u5e94\u7528\u7a0b\u5e8f\u5c31\u53ef\u4ee5\u63d0\u4f9b\u8fd0\u884c\u6240\u9700\u7684\u5927\u91cf\u8d44\u6e90\u3002\u7531\u4e8e\u540d\u4e3aFirejail\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u60a8\u53ef\u4ee5\u5b89\u5168\u5730\u5728Linux\u4e2d\u8fd0\u884c\u4e0d\u53d7\u4fe1\u4efb\u7684\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n
Firejail\u662f\u4e00\u4e2aSUID\uff08\u8bbe\u7f6e\u6240\u6709\u8005\u7528\u6237ID\uff09\u5e94\u7528\u7a0b\u5e8f\uff0c\u5b83\u901a\u8fc7\u4f7f\u7528Linux\u547d\u540d\u7a7a\u95f4\u548cseccomp-bpf\u9650\u5236\u4e0d\u53d7\u4fe1\u4efb\u7a0b\u5e8f\u7684\u8fd0\u884c\u73af\u5883\u6765\u51cf\u5c11\u5b89\u5168\u6f0f\u6d1e\u7684\u66b4\u9732\u3002<\/p>\n
\u5b83\u4f7f\u4e00\u4e2a\u8fdb\u7a0b\u53ca\u5176\u6240\u6709\u540e\u4ee3\u62e5\u6709\u81ea\u5df1\u7684\u5168\u5c40\u5171\u4eab\u5185\u6838\u8d44\u6e90\u7684\u79d8\u5bc6\u89c6\u56fe\uff0c\u4f8b\u5982\u7f51\u7edc\u5806\u6808\uff0c\u8fdb\u7a0b\u8868\uff0c\u6302\u8f7d\u8868\u3002<\/p>\n
Firejail\u4f7f\u7528\u7684\u4e00\u4e9b\u529f\u80fd\uff1a<\/p>\n
\u6709\u5173Firejail\u529f\u80fd\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605\u5b98\u65b9\u9875\u9762\u3002<\/p>\n
\u53ef\u4ee5\u4f7f\u7528git\u547d\u4ee4\u4ece\u9879\u76ee\u7684github\u9875\u9762\u4e0b\u8f7d\u6700\u65b0\u7684\u8f6f\u4ef6\u5305\u6765\u5b8c\u6210\u5b89\u88c5\uff0c\u5982\u56fe\u6240\u793a\u3002<\/p>\n
linuxidc@linuxidc:~\/www.linuxidc.com$ git clone https:\/\/github.com\/netblue30\/firejail.git\r\n\u6b63\u514b\u9686\u5230 'firejail'...\r\nremote: Enumerating objects: 23, done.\r\nremote: Counting objects: 100% (23\/23), done.\r\nremote: Compressing objects: 100% (18\/18), done.\r\nremote: Total 38395 (delta 11), reused 11 (delta 5), pack-reused 38372\r\n\u63a5\u6536\u5bf9\u8c61\u4e2d: 100% (38395\/38395), 9.82 MiB | 87.00 KiB\/s, \u5b8c\u6210.\r\n\u5904\u7406 delta \u4e2d: 100% (30820\/30820), \u5b8c\u6210.\r\nlinuxidc@linuxidc:~\/www.linuxidc.com$ cd firejail\r\nlinuxidc@linuxidc:~\/www.linuxidc.com\/firejail$ .\/configure && make && sudo make install-strip\r\nchecking for gcc... gcc\r\nchecking whether the C compiler works... yes\r\nchecking for C compiler default output file name... a.out\r\nchecking for suffix of executables...\r\nchecking whether we are cross compiling... no\r\nchecking for suffix of object files... o\r\n<\/pre>\n<\/p>\n
\u5982\u679c\u60a8\u7684\u7cfb\u7edf\u4e0a\u6ca1\u6709\u5b89\u88c5git\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u5b83\uff1a<\/p>\n
$ sudo apt install git [\u5728 Debian\/Ubuntu]\r\n# yum install git [\u5728 CentOS\/RHEL]\r\n# dnf install git [\u5728 Fedora 22+]\r\n<\/pre>\n\u5b89\u88c5firejail\u7684\u53e6\u4e00\u79cd\u65b9\u6cd5\u662f\u4e0b\u8f7d\u4e0eLinux\u53d1\u884c\u7248\u76f8\u5173\u8054\u7684\u8f6f\u4ef6\u5305\uff0c\u5e76\u4f7f\u7528\u5176\u8f6f\u4ef6\u5305\u7ba1\u7406\u5668\u8fdb\u884c\u5b89\u88c5\u3002 \u53ef\u4ee5\u4ece\u9879\u76ee\u7684SourceForge\u9875\u9762\u4e0b\u8f7d\u6587\u4ef6\u3002 \u4e0b\u8f7d\u6587\u4ef6\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n
$ sudo dpkg -i firejail_X.Y_1_amd64.deb [\u5728 Debian\/Ubuntu]\r\n$ sudo rpm -i firejail_X.Y-Z.x86_64.rpm [\u5728 CentOS\/RHEL\/Fedora]<\/pre>\n\u5982\u4f55\u5728Linux\u4e2d\u4f7f\u7528Firejail\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f<\/strong><\/div>\n\u60a8\u73b0\u5728\u53ef\u4ee5\u4f7f\u7528firejail\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u4e86\u3002 \u8fd9\u662f\u901a\u8fc7\u542f\u52a8\u7ec8\u7aef\u5e76\u5728\u60a8\u5e0c\u671b\u8fd0\u884c\u7684\u547d\u4ee4\u4e4b\u524d\u6dfb\u52a0firejail\u6765\u5b9e\u73b0\u7684\u3002<\/p>\n
\u4e0b\u9762\u662f\u4e00\u4e2a\u4f8b\u5b50:<\/p>\n
<\/p>\n
$ firejail firefox #\u542f\u52a8 Firefox\u7f51\u7edc\u6d4f\u89c8\u5668\r\n$ firejail vlc # \u542f\u52a8 VLC \u64ad\u653e\u5668<\/pre>\n\u521b\u5efa\u5b89\u5168\u914d\u7f6e\u6587\u4ef6<\/strong><\/div>\nFirejail\u5305\u542b\u8bb8\u591a\u9488\u5bf9\u4e0d\u540c\u5e94\u7528\u7a0b\u5e8f\u7684\u5b89\u5168\u914d\u7f6e\u6587\u4ef6\uff0c\u5b83\u4eec\u5b58\u50a8\u5728\uff1a<\/p>\n
\/etc\/firejail\r\n<\/pre>\n\u5982\u679c\u60a8\u4ece\u6e90\u4ee3\u7801\u6784\u5efa\u9879\u76ee\uff0c\u5219\u53ef\u4ee5\u5728\u4ee5\u4e0b\u4f4d\u7f6e\u627e\u5230\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n
# path-to-firejail\/etc\/\r\n<\/pre>\n\u5982\u679c\u60a8\u4f7f\u7528\u4e86rpm\/deb\u8f6f\u4ef6\u5305\uff0c\u5219\u53ef\u4ee5\u5728\u4ee5\u4e0b\u4f4d\u7f6e\u627e\u5230\u5b89\u5168\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n
\/etc\/firejail\/\r\n<\/pre>\n\u7528\u6237\u5e94\u5c06\u5176\u914d\u7f6e\u6587\u4ef6\u653e\u5728\u4ee5\u4e0b\u76ee\u5f55\u4e2d\uff1a<\/p>\n
~\/.config\/firejail\r\n<\/pre>\n\u5982\u679c\u8981\u6269\u5c55\u73b0\u6709\u5b89\u5168\u914d\u7f6e\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u5305\u542b\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\u7684include\uff0c\u7136\u540e\u6dfb\u52a0\u884c\u3002 \u8fd9\u5e94\u8be5\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n
$ cat ~\/.config\/firejail\/vlc.profile\r\n\r\ninclude \/etc\/firejail\/vlc.profile\r\nnet none\r\n<\/pre>\n\u5982\u679c\u60a8\u5e0c\u671b\u9650\u5236\u5e94\u7528\u7a0b\u5e8f\u8bbf\u95ee\u67d0\u4e2a\u76ee\u5f55\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u9ed1\u540d\u5355\u89c4\u5219\u6765\u5b9e\u73b0\u8fd9\u4e00\u76ee\u6807\u3002 \u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u5c06\u4ee5\u4e0b\u5185\u5bb9\u6dfb\u52a0\u5230\u5b89\u5168\u914d\u7f6e\u6587\u4ef6\u4e2d\uff1a<\/p>\n
blacklist ${HOME}\/Documents\r\n<\/pre>\n\u5b9e\u73b0\u76f8\u540c\u7ed3\u679c\u7684\u53e6\u4e00\u79cd\u65b9\u6cd5\u662f\u5b9e\u9645\u63cf\u8ff0\u60a8\u5e0c\u671b\u9650\u5236\u7684\u6587\u4ef6\u5939\u7684\u5b8c\u6574\u8def\u5f84\uff1a<\/p>\n
blacklist \/home\/user\/Documents\r\n<\/pre>\n\u60a8\u53ef\u4ee5\u901a\u8fc7\u8bb8\u591a\u4e0d\u540c\u7684\u65b9\u5f0f\u914d\u7f6e\u5b89\u5168\u914d\u7f6e\u6587\u4ef6\uff0c\u4f8b\u5982\u7981\u6b62\u8bbf\u95ee\uff0c\u5141\u8bb8\u53ea\u8bfb\u8bbf\u95ee\u7b49\u3002\u5982\u679c\u60a8\u6709\u5174\u8da3\u6784\u5efa\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\uff0c\u53ef\u4ee5\u67e5\u770b\u4ee5\u4e0bfirejail\u8bf4\u660e\u3002<\/p>\n
\u5bf9\u4e8e\u60f3\u8981\u4fdd\u62a4\u7cfb\u7edf\u7684\u5b89\u5168\u7528\u6237\u6765\u8bf4\uff0cFirejail\u662f\u4e00\u4e2a\u5f88\u68d2\u7684\u5de5\u5177\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u6709\u65f6\u60a8\u53ef\u80fd\u5e0c\u671b\u4f7f\u7528\u5728\u4e0d\u540c\u73af\u5883\u4e2d\u672a\u7ecf\u8fc7\u826f\u597d\u6d4b\u8bd5\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u4f46\u60a8\u5fc5\u987b\u4f7f\u7528\u5b83\u4eec\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5173\u6ce8\u7cfb\u7edf\u7684\u5b89\u5168\u6027\u662f\u6b63\u5e38 […]<\/p>\n","protected":false},"author":323,"featured_media":139068,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-138967","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\/138967","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\/323"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=138967"}],"version-history":[{"count":7,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/138967\/revisions"}],"predecessor-version":[{"id":139074,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/138967\/revisions\/139074"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/139068"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=138967"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=138967"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=138967"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}