{"id":114185,"date":"2026-10-08T15:09:02","date_gmt":"2026-10-08T07:09:02","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/114185.html"},"modified":"2026-10-08T15:09:02","modified_gmt":"2026-10-08T07:09:02","slug":"tlpi-%e7%ac%ac39%e7%ab%a0-%e8%af%bb%e4%b9%a6%e7%ac%94%e8%ae%b0%ef%bc%9acapabilities","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/114185.html","title":{"rendered":"TLPI \u7b2c39\u7ae0 \u8bfb\u4e66\u7b14\u8bb0\uff1aCapabilities"},"content":{"rendered":"<p>\u7b14\u8bb0\u548c\u7ec3\u4e60\u535a\u5ba2\u603b\u76ee\u5f55\u89c1&#xff1a;\u5f00\u59cb\u8bfbTLPI\u3002<\/p>\n<p>\u672c\u7ae0\u4ecb\u7ecd Linux \u6743\u80fd&#xff08;capabilities&#xff09;\u673a\u5236\u3002\u8be5\u673a\u5236\u5c06\u4f20\u7edf UNIX\u300c\u8981\u4e48\u5168\u90e8\u6743\u9650\u3001\u8981\u4e48\u6ca1\u6709\u6743\u9650\u300d\u7684\u7279\u6743\u6a21\u578b&#xff0c;\u62c6\u5206\u4e3a\u82e5\u5e72\u53ef\u72ec\u7acb\u542f\u7528\u6216\u7981\u7528\u7684\u5355\u9879\u6743\u80fd\u3002\u501f\u52a9\u6743\u80fd\u673a\u5236&#xff0c;\u7a0b\u5e8f\u53ef\u4ee5\u6267\u884c\u90e8\u5206\u7279\u6743\u64cd\u4f5c&#xff0c;\u540c\u65f6\u88ab\u7981\u6b62\u6267\u884c\u5176\u4f59\u7279\u6743\u64cd\u4f5c\u3002<\/p>\n<h3>39.1 Rationale for Capabilities<\/h3>\n<p>\u4f20\u7edf UNIX \u7279\u6743\u673a\u5236\u5c06\u8fdb\u7a0b\u5206\u4e3a\u4e24\u7c7b&#xff1a;\u4e00\u7c7b\u662f\u6709\u6548\u7528\u6237 ID \u4e3a 0 \u7684\u8fdb\u7a0b&#xff08;\u8d85\u7ea7\u7528\u6237&#xff09;&#xff0c;\u8fd9\u7c7b\u8fdb\u7a0b\u4f1a\u7ed5\u8fc7\u6240\u6709\u6743\u9650\u68c0\u67e5&#xff1b;\u5176\u4f59\u6240\u6709\u8fdb\u7a0b\u5219\u9700\u8981\u6839\u636e\u81ea\u8eab\u7528\u6237 ID \u4e0e\u7ec4 ID \u63a5\u53d7\u6743\u9650\u6821\u9a8c\u3002<\/p>\n<p>\u8be5\u673a\u5236\u7684\u6743\u9650\u7c92\u5ea6\u8fc7\u7c97&#xff0c;\u8fd9\u662f\u4e00\u4e2a\u7a81\u51fa\u95ee\u9898\u3002\u5982\u679c\u6211\u4eec\u5e0c\u671b\u5141\u8bb8\u67d0\u4e2a\u8fdb\u7a0b\u6267\u884c\u4ec5\u8d85\u7ea7\u7528\u6237\u624d\u80fd\u6267\u884c\u7684\u64cd\u4f5c&#xff08;\u4f8b\u5982\u4fee\u6539\u7cfb\u7edf\u65f6\u95f4&#xff09;&#xff0c;\u5c31\u5fc5\u987b\u4ee5\u6709\u6548\u7528\u6237 ID \u4e3a 0 \u7684\u8eab\u4efd\u8fd0\u884c\u8be5\u8fdb\u7a0b\u3002&#xff08;\u975e\u7279\u6743\u7528\u6237\u9700\u8981\u6267\u884c\u8fd9\u7c7b\u64cd\u4f5c\u65f6&#xff0c;\u4e00\u822c\u901a\u8fc7 set-user-ID-root \u7a0b\u5e8f\u5b9e\u73b0\u3002&#xff09;\u4f46\u8fd9\u6837\u505a\u4f1a\u8d4b\u4e88\u8be5\u8fdb\u7a0b\u5927\u91cf\u5176\u4ed6\u64cd\u4f5c\u6743\u9650 \u2014\u2014 \u4f8b\u5982\u8bbf\u95ee\u6587\u4ef6\u65f6\u7ed5\u8fc7\u5168\u90e8\u6743\u9650\u6821\u9a8c\u3002\u4e00\u65e6\u7a0b\u5e8f\u51fa\u73b0\u975e\u9884\u671f\u884c\u4e3a&#xff08;\u53ef\u80fd\u7531\u610f\u5916\u573a\u666f\u89e6\u53d1&#xff0c;\u6216\u662f\u906d\u5230\u6076\u610f\u7528\u6237\u84c4\u610f\u5229\u7528&#xff09;&#xff0c;\u5c31\u4f1a\u5f15\u53d1\u5404\u7c7b\u5b89\u5168\u6f0f\u6d1e\u3002\u7b2c 38 \u7ae0\u4ecb\u7ecd\u8fc7\u5904\u7406\u8be5\u95ee\u9898\u7684\u4f20\u7edf\u65b9\u6848&#xff1a;\u4e0b\u653e\u6709\u6548\u7279\u6743&#xff08;\u5373\u628a\u6709\u6548\u7528\u6237 ID \u4ece 0 \u4fee\u6539\u4e3a\u5176\u4ed6\u503c&#xff0c;\u540c\u65f6\u5c06\u4fdd\u5b58\u7684\u8bbe\u7f6e\u7528\u6237 ID \u4fdd\u6301\u4e3a 0&#xff09;&#xff0c;\u4ec5\u5728\u5fc5\u8981\u65f6\u4e34\u65f6\u91cd\u65b0\u83b7\u53d6\u7279\u6743\u3002<\/p>\n<p>Linux \u6743\u80fd\u673a\u5236\u4f18\u5316\u4e86\u8be5\u95ee\u9898\u7684\u5904\u7406\u65b9\u5f0f\u3002\u5185\u6838\u5728\u6267\u884c\u5b89\u5168\u68c0\u67e5\u65f6&#xff0c;\u4e0d\u518d\u4f7f\u7528\u5355\u4e00\u7279\u6743&#xff08;\u5373\u6709\u6548\u7528\u6237 ID \u4e3a 0&#xff09;&#xff0c;\u800c\u662f\u5c06\u8d85\u7ea7\u7528\u6237\u7279\u6743\u62c6\u5206\u4e3a\u591a\u4e2a\u72ec\u7acb\u5355\u5143&#xff0c;\u8fd9\u4e9b\u5355\u5143\u5c31\u79f0\u4e3a\u6743\u80fd&#xff08;capabilities&#xff09;\u3002\u6bcf\u9879\u7279\u6743\u64cd\u4f5c\u90fd\u5173\u8054\u4e00\u9879\u7279\u5b9a\u6743\u80fd&#xff1b;\u8fdb\u7a0b\u53ea\u6709\u6301\u6709\u5bf9\u5e94\u7684\u6743\u80fd&#xff0c;\u624d\u80fd\u6267\u884c\u8be5\u64cd\u4f5c&#xff08;\u4e0e\u8fdb\u7a0b\u7684\u6709\u6548\u7528\u6237 ID \u65e0\u5173&#xff09;\u3002\u6362\u53e5\u8bdd\u8bf4&#xff0c;\u672c\u4e66\u4e2d\u4f46\u51e1\u63d0\u5230 Linux \u4e0b\u7684\u7279\u6743\u8fdb\u7a0b&#xff0c;\u5176\u771f\u5b9e\u542b\u4e49\u662f&#xff1a;\u8be5\u8fdb\u7a0b\u62e5\u6709\u6267\u884c\u67d0\u9879\u7279\u5b9a\u64cd\u4f5c\u6240\u9700\u7684\u76f8\u5173\u6743\u80fd\u3002<\/p>\n<p>\u5927\u591a\u6570\u573a\u666f\u4e0b&#xff0c;Linux \u6743\u80fd\u673a\u5236\u5bf9\u4f7f\u7528\u8005\u662f\u900f\u660e\u7684\u3002\u539f\u56e0\u5728\u4e8e&#xff1a;\u5f53\u4e0d\u611f\u77e5\u6743\u80fd\u673a\u5236\u7684\u5e94\u7528\u7a0b\u5e8f\u5047\u5b9a\u81ea\u8eab\u6709\u6548\u7528\u6237 ID \u4e3a 0 \u65f6&#xff0c;\u5185\u6838\u4f1a\u5411\u8be5\u8fdb\u7a0b\u6388\u4e88\u5168\u90e8\u6743\u80fd\u3002<\/p>\n<p>&#x1f4a1; Linux \u5f15\u5165 capability \u662f\u4e3a\u4e86\u62c6\u5206 root \u6743\u9650&#xff0c;\u4f46\u662f\u4e3a\u4e86\u517c\u5bb9\u51e0\u5341\u5e74\u7684\u65e7 root \u7a0b\u5e8f&#xff0c;\u505a\u4e86\u4ee5\u4e0a\u517c\u5bb9\u89c4\u5219\u3002<\/p>\n<p>Linux \u6743\u80fd\u7684\u5b9e\u73b0\u57fa\u4e8e POSIX 1003.1e \u8349\u6848\u6807\u51c6&#xff08;http:\/\/wt.tuxomania.net\/publications\/posix.1e\/&#xff09;\u3002\u8fd9\u9879\u6807\u51c6\u5316\u5de5\u4f5c\u5728 20 \u4e16\u7eaa 90 \u5e74\u4ee3\u540e\u671f\u5c1a\u672a\u5b8c\u6210\u5c31\u5ba3\u544a\u6401\u7f6e&#xff0c;\u4f46\u5404\u7c7b\u6743\u80fd\u5b9e\u73b0\u4f9d\u7136\u4ee5\u8fd9\u4efd\u8349\u6848\u4e3a\u57fa\u7840\u3002&#xff08;\u8868 39-1 \u6240\u5217\u7684\u90e8\u5206\u6743\u80fd\u5728 POSIX.1e \u8349\u6848\u4e2d\u5b9a\u4e49&#xff0c;\u4f46\u5927\u91cf\u6743\u80fd\u5c5e\u4e8e Linux \u6269\u5c55\u3002&#xff09;<\/p>\n<p>\u5c11\u6570\u5176\u4ed6 UNIX \u5b9e\u73b0\u4e5f\u63d0\u4f9b\u4e86\u6743\u80fd\u673a\u5236&#xff0c;\u4f8b\u5982 Sun \u7684 Solaris 10 \u4ee5\u53ca\u66f4\u65e9\u7684\u53ef\u4fe1 Solaris \u7248\u672c\u3001SGI \u7684 Trusted Irix&#xff0c;\u8fd8\u6709 FreeBSD \u7684 TrustedBSD \u9879\u76ee&#xff08;\u53c2\u89c1 [Watson, 2000]&#xff09;\u3002\u5176\u4ed6\u4e00\u4e9b\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u4e5f\u5b58\u5728\u7c7b\u4f3c\u673a\u5236&#xff1b;\u4f8b\u5982Digital VMS \u7cfb\u7edf\u4e2d\u7684\u7279\u6743\u673a\u5236\u3002<\/p>\n<h3>39.2 The Linux Capabilities<\/h3>\n<p>\u8868 39-1 \u5217\u51fa\u4e86 Linux \u7684\u5404\u9879\u6743\u80fd&#xff0c;\u5e76\u7b80\u8981&#xff08;\u4e14\u975e\u5b8c\u6574&#xff09;\u8bf4\u660e\u4e86\u8fd9\u4e9b\u6743\u80fd\u5bf9\u5e94\u7684\u9002\u7528\u64cd\u4f5c\u3002<\/p>\n<p>Table 39-1: Operations permitted by each Linux capability<\/p>\n<h2>Linux Capabilities \u6743\u80fd\u5bf9\u7167\u8868&#xff08;\u4e2d\u82f1\u53cc\u8bed Markdown \u8868\u683c&#xff09;<\/h2>\n<table>\n<tr>\u6743\u80fd\u5141\u8bb8\u8fdb\u7a0b\u6267\u884c\u7684\u64cd\u4f5c<\/tr>\n<tbody>\n<tr>\n<td align=\"left\">CAP_AUDIT_CONTROL<\/td>\n<td align=\"left\">&#xff08;\u81ea Linux 2.6.11&#xff09;\u542f\u7528\u3001\u7981\u7528\u5185\u6838\u5ba1\u8ba1\u65e5\u5fd7&#xff1b;\u4fee\u6539\u5ba1\u8ba1\u8fc7\u6ee4\u89c4\u5219&#xff1b;\u83b7\u53d6\u5ba1\u8ba1\u72b6\u6001\u4e0e\u8fc7\u6ee4\u89c4\u5219<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_AUDIT_WRITE<\/td>\n<td align=\"left\">&#xff08;\u81ea Linux 2.6.11&#xff09;\u5411\u5185\u6838\u5ba1\u8ba1\u65e5\u5fd7\u5199\u5165\u8bb0\u5f55<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_CHOWN<\/td>\n<td align=\"left\">\u4fee\u6539\u6587\u4ef6\u7528\u6237ID&#xff08;\u5c5e\u4e3b&#xff09;&#xff1b;\u6216\u5c06\u6587\u4ef6\u7ec4ID\u4fee\u6539\u4e3a\u8be5\u8fdb\u7a0b\u5e76\u975e\u5176\u6210\u5458\u7684\u7528\u6237\u7ec4&#xff08;chown()&#xff09;<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_DAC_OVERRIDE<\/td>\n<td align=\"left\">\u7ed5\u8fc7\u6587\u4ef6\u8bfb\u3001\u5199\u3001\u6267\u884c\u6743\u9650\u68c0\u67e5&#xff08;DAC \u5373\u81ea\u4e3b\u8bbf\u95ee\u63a7\u5236 discretionary access control&#xff09;&#xff1b;\u8bfb\u53d6 \/proc\/PID \u4e0b cwd\u3001exe\u3001root \u7b26\u53f7\u94fe\u63a5\u5185\u5bb9<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_DAC_READ_SEARCH<\/td>\n<td align=\"left\">\u7ed5\u8fc7\u6587\u4ef6\u8bfb\u6743\u9650\u68c0\u67e5&#xff0c;\u4ee5\u53ca\u76ee\u5f55\u8bfb\u3001\u6267\u884c&#xff08;\u68c0\u7d22&#xff09;\u6743\u9650\u68c0\u67e5<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_FOWNER<\/td>\n<td align=\"left\">\u901a\u5e38\u53ef\u5ffd\u7565\u8fd9\u7c7b\u64cd\u4f5c\u7684\u6743\u9650\u6821\u9a8c&#xff1a;\u64cd\u4f5c\u4e00\u822c\u8981\u6c42\u8fdb\u7a0b\u6587\u4ef6\u7cfb\u7edfUID\u4e0e\u6587\u4ef6UID\u5339\u914d&#xff08;chmod()\u3001utime()&#xff09;&#xff1b;\u53ef\u5bf9\u4efb\u610f\u6587\u4ef6\u8bbe\u7f6einode\u6807\u5fd7&#xff1b;\u5bf9\u4efb\u610f\u6587\u4ef6\u8bbe\u7f6e\u3001\u4fee\u6539ACL&#xff1b;\u5220\u9664\u6587\u4ef6\u65f6\u5ffd\u7565\u76ee\u5f55\u7c98\u6ede\u4f4d\u4f5c\u7528&#xff08;unlink()\u3001rmdir()\u3001rename()&#xff09;&#xff1b;\u5728open()\u4e0efcntl(F_SETFL)\u4e2d&#xff0c;\u53ef\u5bf9\u4efb\u610f\u6587\u4ef6\u6307\u5b9aO_NOATIME\u6807\u5fd7<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_FSETID<\/td>\n<td align=\"left\">\u4fee\u6539\u6587\u4ef6\u65f6&#xff0c;\u5185\u6838\u4e0d\u4f1a\u6e05\u9664set-user-ID\u548cset-group-ID\u4f4d&#xff08;write()\u3001truncate()&#xff09;&#xff1b;\u5f53\u6587\u4ef6\u7ec4ID\u4e0e\u8fdb\u7a0b\u6587\u4ef6\u7cfb\u7edfGID\u6216\u9644\u52a0\u7ec4ID\u4e0d\u5339\u914d\u65f6&#xff0c;\u4ecd\u53ef\u542f\u7528\u8be5\u6587\u4ef6\u7684set-group-ID\u4f4d&#xff08;chmod()&#xff09;<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_IPC_LOCK<\/td>\n<td align=\"left\">\u89e3\u9664\u5185\u5b58\u9501\u5b9a\u9650\u5236&#xff08;mlock()\u3001mlockall()\u3001shmctl(SHM_LOCK)\u3001shmctl(SHM_UNLOCK)&#xff09;&#xff1b;\u5728shmget()\u4e2d\u4f7f\u7528SHM_HUGETLB\u6807\u5fd7&#xff0c;\u5728mmap()\u4e2d\u4f7f\u7528MAP_HUGETLB\u6807\u5fd7<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_IPC_OWNER<\/td>\n<td align=\"left\">\u7ed5\u8fc7System V IPC\u5bf9\u8c61\u64cd\u4f5c\u7684\u6743\u9650\u68c0\u67e5<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_KILL<\/td>\n<td align=\"left\">\u7ed5\u8fc7\u53d1\u9001\u4fe1\u53f7\u7684\u6743\u9650\u68c0\u67e5&#xff08;kill()\u3001sigqueue()&#xff09;<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_LEASE<\/td>\n<td align=\"left\">&#xff08;\u81ea Linux 2.4&#xff09;\u5728\u4efb\u610f\u6587\u4ef6\u4e0a\u5efa\u7acb\u6587\u4ef6\u79df\u7ea6&#xff08;fcntl(F_SETLEASE)&#xff09;<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_LINUX_IMMUTABLE<\/td>\n<td align=\"left\">\u8bbe\u7f6einode\u7684\u8ffd\u52a0&#xff08;append&#xff09;\u4e0e\u4e0d\u53ef\u53d8&#xff08;immutable&#xff09;\u6807\u5fd7<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_MAC_ADMIN<\/td>\n<td align=\"left\">&#xff08;\u81ea Linux 2.6.25&#xff09;\u914d\u7f6e\u6216\u4fee\u6539\u5f3a\u5236\u8bbf\u95ee\u63a7\u5236MAC\u72b6\u6001&#xff08;\u7531\u90e8\u5206Linux\u5b89\u5168\u6a21\u5757\u5b9e\u73b0&#xff09;<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_MAC_OVERRIDE<\/td>\n<td align=\"left\">&#xff08;\u81ea Linux 2.6.25&#xff09;\u8986\u76d6\u5f3a\u5236\u8bbf\u95ee\u63a7\u5236MAC\u9650\u5236&#xff08;\u7531\u90e8\u5206Linux\u5b89\u5168\u6a21\u5757\u5b9e\u73b0&#xff09;<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_MKNOD<\/td>\n<td align=\"left\">&#xff08;\u81ea Linux 2.4&#xff09;\u4f7f\u7528mknod()\u521b\u5efa\u8bbe\u5907\u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_NET_ADMIN<\/td>\n<td align=\"left\">\u6267\u884c\u5404\u7c7b\u7f51\u7edc\u76f8\u5173\u64cd\u4f5c&#xff08;\u4f8b\u5982&#xff1a;\u8bbe\u7f6e\u7279\u6743socket\u9009\u9879\u3001\u542f\u7528\u7ec4\u64ad\u3001\u914d\u7f6e\u7f51\u7edc\u63a5\u53e3\u3001\u4fee\u6539\u8def\u7531\u8868&#xff09;<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_NET_BIND_SERVICE<\/td>\n<td align=\"left\">\u7ed1\u5b9a\u5230\u7279\u6743\u7aef\u53e3<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_NET_BROADCAST<\/td>\n<td align=\"left\">&#xff08;\u672a\u4f7f\u7528&#xff09;\u6267\u884csocket\u5e7f\u64ad&#xff0c;\u76d1\u542c\u7ec4\u64ad<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_NET_RAW<\/td>\n<td align=\"left\">\u4f7f\u7528\u539f\u59cb\u5957\u63a5\u5b57\u4e0e\u6570\u636e\u5305\u5957\u63a5\u5b57<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_SETGID<\/td>\n<td align=\"left\">\u4efb\u610f\u4fee\u6539\u8fdb\u7a0b\u7ec4ID&#xff08;setgid()\u3001setegid()\u3001setregid()\u3001setresgid()\u3001setfsgid()\u3001setgroups()\u3001initgroups()&#xff09;&#xff1b;\u901a\u8fc7UNIX\u57df\u5957\u63a5\u5b57\u4f20\u9012\u51ed\u8bc1&#xff08;SCM_CREDENTIALS&#xff09;\u65f6\u4f2a\u9020\u7ec4ID<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_SETFCAP<\/td>\n<td align=\"left\">&#xff08;\u81ea Linux 2.6.24&#xff09;\u8bbe\u7f6e\u6587\u4ef6\u6743\u80fd<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_SETPCAP<\/td>\n<td align=\"left\">\u5982\u679c\u4e0d\u652f\u6301\u6587\u4ef6\u6743\u80fd&#xff0c;\u53ef\u4ee5\u5bf9\u4efb\u610f\u5176\u4ed6\u8fdb\u7a0b&#xff08;\u5305\u62ec\u81ea\u8eab&#xff09;\u589e\u5220\u8fdb\u7a0b\u5141\u8bb8\u96c6\u4e2d\u7684\u6743\u80fd&#xff1b;\u5982\u679c\u652f\u6301\u6587\u4ef6\u6743\u80fd&#xff0c;\u53ef\u5c06\u8fdb\u7a0b\u6743\u80fd\u8fb9\u754c\u96c6\u4e2d\u7684\u4efb\u610f\u6743\u80fd\u6dfb\u52a0\u5230\u53ef\u7ee7\u627f\u96c6\u3001\u4ece\u8fb9\u754c\u96c6\u4e2d\u79fb\u9664\u6743\u80fd&#xff0c;\u5e76\u4fee\u6539\u5b89\u5168\u4f4d\u6807\u5fd7&#xff08;securebits flags&#xff09;<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_SETUID<\/td>\n<td align=\"left\">\u4efb\u610f\u4fee\u6539\u8fdb\u7a0b\u7528\u6237ID&#xff08;setuid()\u3001seteuid()\u3001setreuid()\u3001setresuid()\u3001setfsuid()&#xff09;&#xff1b;\u901a\u8fc7UNIX\u57df\u5957\u63a5\u5b57\u4f20\u9012\u51ed\u8bc1&#xff08;SCM_CREDENTIALS&#xff09;\u65f6\u4f2a\u9020\u7528\u6237ID<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_SYS_ADMIN<\/td>\n<td align=\"left\">\u5728\u6253\u5f00\u6587\u4ef6\u7684\u7cfb\u7edf\u8c03\u7528&#xff08;\u5982open()\u3001shm_open()\u3001pipe()\u3001socket()\u3001accept()\u3001exec()\u3001acct()\u3001epoll_create()&#xff09;\u4e2d\u7a81\u7834 \/proc\/sys\/fs\/file-max \u9650\u5236&#xff1b;\u6267\u884c\u5404\u7c7b\u7cfb\u7edf\u7ba1\u7406\u64cd\u4f5c&#xff0c;\u5305\u62ecquotactl()&#xff08;\u78c1\u76d8\u914d\u989d\u7ba1\u7406&#xff09;\u3001mount()\u4e0eumount()\u3001swapon()\u4e0eswapoff()\u3001pivot_root()\u3001sethostname()\u548csetdomainname()&#xff1b;\u6267\u884c\u5404\u7c7bsyslog(2)\u64cd\u4f5c&#xff1b;\u8986\u76d6RLIMIT_NPROC\u8d44\u6e90\u9650\u5236&#xff08;fork()&#xff09;&#xff1b;\u8c03\u7528lookup_dcookie()&#xff1b;\u8bbe\u7f6etrusted\u4e0esecurity\u6269\u5c55\u5c5e\u6027&#xff1b;\u5bf9\u4efb\u610fSystem V IPC\u5bf9\u8c61\u6267\u884cIPC_SET\u3001IPC_RMID\u64cd\u4f5c&#xff1b;\u901a\u8fc7UNIX\u57df\u5957\u63a5\u5b57\u4f20\u9012\u51ed\u8bc1&#xff08;SCM_CREDENTIALS&#xff09;\u65f6\u4f2a\u9020\u8fdb\u7a0bID&#xff1b;\u4f7f\u7528ioprio_set()\u8bbe\u7f6eIOPRIO_CLASS_RT\u8c03\u5ea6\u7c7b\u522b&#xff1b;\u4f7f\u7528TIOCCONS ioctl&#xff1b;\u5728clone()\u4e0eunshare()\u4e2d\u4f7f\u7528CLONE_NEWNS\u6807\u5fd7&#xff1b;\u6267\u884cKEYCTL_CHOWN\u3001KEYCTL_SETPERM\u7b49keyctl()\u64cd\u4f5c&#xff1b;\u7ba1\u7406random(4)\u8bbe\u5907&#xff1b;\u4ee5\u53ca\u5404\u7c7b\u8bbe\u5907\u4e13\u5c5e\u64cd\u4f5c<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_SYS_BOOT<\/td>\n<td align=\"left\">\u4f7f\u7528reboot()\u91cd\u542f\u7cfb\u7edf&#xff1b;\u8c03\u7528kexec_load()<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_SYS_CHROOT<\/td>\n<td align=\"left\">\u4f7f\u7528chroot()\u8bbe\u7f6e\u8fdb\u7a0b\u6839\u76ee\u5f55<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_SYS_MODULE<\/td>\n<td align=\"left\">\u52a0\u8f7d\u3001\u5378\u8f7d\u5185\u6838\u6a21\u5757&#xff08;init_module()\u3001delete_module()\u3001create_module()&#xff09;<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_SYS_NICE<\/td>\n<td align=\"left\">\u63d0\u5347nice\u503c&#xff08;nice()\u3001setpriority()&#xff09;&#xff1b;\u4fee\u6539\u4efb\u610f\u8fdb\u7a0b\u7684nice\u503c&#xff08;setpriority()&#xff09;&#xff1b;\u4e3a\u8c03\u7528\u8fdb\u7a0b\u8bbe\u7f6eSCHED_RR\u3001SCHED_FIFO\u5b9e\u65f6\u8c03\u5ea6\u7b56\u7565&#xff1b;\u91cd\u7f6eSCHED_RESET_ON_FORK\u6807\u5fd7&#xff1b;\u4e3a\u4efb\u610f\u8fdb\u7a0b\u8bbe\u7f6e\u8c03\u5ea6\u7b56\u7565\u4e0e\u4f18\u5148\u7ea7&#xff08;sched_setscheduler()\u3001sched_setparam()&#xff09;&#xff1b;\u4e3a\u4efb\u610f\u8fdb\u7a0b\u8bbe\u7f6eI\/O\u8c03\u5ea6\u7c7b\u522b\u548c\u4f18\u5148\u7ea7&#xff08;ioprio_set()&#xff09;&#xff1b;\u8bbe\u7f6e\u4efb\u610f\u8fdb\u7a0b\u7684CPU\u4eb2\u548c\u6027&#xff08;sched_setaffinity()&#xff09;&#xff1b;\u4f7f\u7528migrate_pages()\u8fc1\u79fb\u4efb\u610f\u8fdb\u7a0b&#xff0c;\u5e76\u5141\u8bb8\u8fdb\u7a0b\u8fc1\u79fb\u5230\u4efb\u610fNUMA\u8282\u70b9&#xff1b;\u5bf9\u4efb\u610f\u8fdb\u7a0b\u4f7f\u7528move_pages()&#xff1b;\u5728mbind()\u4e0emove_pages()\u4e2d\u4f7f\u7528MPOL_MF_MOVE_ALL\u6807\u5fd7<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_SYS_PACCT<\/td>\n<td align=\"left\">\u4f7f\u7528acct()\u542f\u7528\u6216\u7981\u7528\u8fdb\u7a0b\u8bb0\u8d26<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_SYS_PTRACE<\/td>\n<td align=\"left\">\u4f7f\u7528ptrace()\u8ddf\u8e2a\u4efb\u610f\u8fdb\u7a0b&#xff1b;\u8bfb\u53d6\u4efb\u610f\u8fdb\u7a0b\u7684 \/proc\/PID\/environ&#xff1b;\u5bf9\u4efb\u610f\u8fdb\u7a0b\u8c03\u7528get_robust_list()<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_SYS_RAWIO<\/td>\n<td align=\"left\">\u901a\u8fc7iopl()\u3001ioperm()\u5bf9I\/O\u7aef\u53e3\u6267\u884c\u64cd\u4f5c&#xff1b;\u8bbf\u95ee\/proc\/kcore&#xff1b;\u6253\u5f00\/dev\/mem\u548c\/dev\/kmem<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_SYS_RESOURCE<\/td>\n<td align=\"left\">\u4f7f\u7528\u6587\u4ef6\u7cfb\u7edf\u9884\u7559\u7a7a\u95f4&#xff1b;\u8c03\u7528ioctl\u63a7\u5236ext3\u65e5\u5fd7&#xff1b;\u7a81\u7834\u78c1\u76d8\u914d\u989d\u9650\u5236&#xff1b;\u63d0\u5347\u786c\u8d44\u6e90\u9650\u5236&#xff08;setrlimit()&#xff09;&#xff1b;\u8986\u76d6RLIMIT_NPROC\u8d44\u6e90\u9650\u5236&#xff08;fork()&#xff09;&#xff1b;\u5c06System V\u6d88\u606f\u961f\u5217msg_qbytes\u4e0a\u9650\u63d0\u5347\u81f3 \/proc\/sys\/kernel\/msgmnb \u4e4b\u4e0a&#xff1b;\u7ed5\u8fc7 \/proc\/sys\/fs\/mqueue \u4e0b\u6587\u4ef6\u5b9a\u4e49\u7684\u5404\u7c7bPOSIX\u6d88\u606f\u961f\u5217\u9650\u5236<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_SYS_TIME<\/td>\n<td align=\"left\">\u4fee\u6539\u7cfb\u7edf\u65f6\u949f&#xff08;settimeofday()\u3001stime()\u3001adjtime()\u3001adjtimex()&#xff09;&#xff1b;\u8bbe\u7f6e\u786c\u4ef6\u65f6\u949f<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">CAP_SYS_TTY_CONFIG<\/td>\n<td align=\"left\">\u4f7f\u7528vhangup()\u5bf9\u7ec8\u7aef\u6216\u4f2a\u7ec8\u7aef\u6267\u884c\u865a\u62df\u6302\u65ad\u64cd\u4f5c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5982\u679c\u4f60\u60f3\u8981\u539f\u7248\u82f1\u6587\u8868\u683c&#xff08;\u540c\u6837\u628a\u7248\u672c\u4fe1\u606f\u79fb\u5230\u7b2c\u4e8c\u5217&#xff09;&#xff0c;\u6211\u4e5f\u4e00\u5e76\u751f\u6210\u3002<\/p>\n<h3>39.3 Process and File Capabilities<\/h3>\n<p>\u6bcf\u4e2a\u8fdb\u7a0b\u5173\u8054\u4e09\u7ec4\u6743\u80fd\u96c6&#xff0c;\u5206\u522b\u79f0\u4e3a\u5141\u8bb8\u96c6&#xff08;permitted&#xff09;\u3001\u6709\u6548\u96c6&#xff08;effective&#xff09;\u4e0e\u53ef\u7ee7\u627f\u96c6&#xff08;inheritable&#xff09;&#xff0c;\u6bcf\u7ec4\u6743\u80fd\u96c6\u53ef\u5305\u542b\u8868 39-1 \u4e2d\u4e00\u9879\u6216\u591a\u9879\u6743\u80fd\u3002<\/p>\n<p>\u6bcf\u4e2a\u6587\u4ef6\u540c\u6837\u53ef\u4ee5\u9644\u5e26\u4e09\u7ec4\u540c\u540d\u7684\u6743\u80fd\u96c6\u3002&#xff08;\u540e\u6587\u4f1a\u8bf4\u660e\u7f18\u7531&#xff1a;\u6587\u4ef6\u6709\u6548\u6743\u80fd\u96c6\u5b9e\u9645\u4e0a\u4ec5\u662f\u4e00\u4e2a\u5355\u72ec\u6bd4\u7279\u4f4d&#xff0c;\u53ea\u6709\u542f\u7528\u6216\u7981\u7528\u4e24\u79cd\u72b6\u6001\u3002&#xff09;\u6211\u4eec\u5c06\u5728\u540e\u7eed\u5c0f\u8282\u8be6\u7ec6\u4ecb\u7ecd\u6bcf\u4e00\u7c7b\u6743\u80fd\u96c6\u3002<\/p>\n<h4>39.3.1 Process Capabilities<\/h4>\n<p>\u5185\u6838\u4e3a\u6bcf\u4e2a\u8fdb\u7a0b\u7ef4\u62a4\u4e09\u7ec4\u6743\u80fd\u96c6&#xff08;\u4ee5\u4f4d\u63a9\u7801\u5b9e\u73b0&#xff09;&#xff0c;\u5176\u4e2d\u53ef\u542f\u7528\u8868 39-1 \u4e2d\u4e00\u9879\u6216\u591a\u9879\u6743\u80fd\u3002\u8fd9\u4e09\u7ec4\u96c6\u5408\u8bf4\u660e\u5982\u4e0b&#xff1a;<\/p>\n<ul>\n<li>\u5141\u8bb8\u96c6&#xff08;Permitted&#xff09;&#xff1a;\u8fdb\u7a0b\u53ef\u4ee5\u4f7f\u7528\u7684\u6743\u80fd\u3002\u5141\u8bb8\u96c6\u662f\u4e00\u4e2a\u4e0a\u9650\u8d85\u96c6&#xff0c;\u51b3\u5b9a\u4e86\u53ef\u4ee5\u6dfb\u52a0\u5230\u6709\u6548\u96c6\u4e0e\u53ef\u7ee7\u627f\u96c6\u4e2d\u7684\u6743\u80fd\u8303\u56f4\u3002\u5982\u679c\u8fdb\u7a0b\u4ece\u81ea\u8eab\u5141\u8bb8\u96c6\u4e2d\u79fb\u9664\u67d0\u9879\u6743\u80fd&#xff0c;\u90a3\u4e48\u8be5\u8fdb\u7a0b\u5c06\u6c38\u8fdc\u65e0\u6cd5\u91cd\u65b0\u83b7\u53d6\u8fd9\u9879\u6743\u80fd&#xff08;\u9664\u975e\u901a\u8fc7 exec \u6267\u884c\u53e6\u4e00\u4e2a\u80fd\u91cd\u65b0\u8d4b\u4e88\u8be5\u6743\u80fd\u7684\u7a0b\u5e8f&#xff09;\u3002<\/li>\n<li>\u6709\u6548\u96c6&#xff08;Effective&#xff09;&#xff1a;\u5185\u6838\u9488\u5bf9\u8be5\u8fdb\u7a0b\u6267\u884c\u6743\u9650\u68c0\u67e5\u65f6\u6240\u4f7f\u7528\u7684\u6743\u80fd\u3002\u53ea\u8981\u67d0\u9879\u6743\u80fd\u4ecd\u4fdd\u7559\u5728\u5141\u8bb8\u96c6\u4e2d&#xff0c;\u8fdb\u7a0b\u5c31\u53ef\u4ee5\u5c06\u5b83\u4ece\u6709\u6548\u96c6\u4e2d\u79fb\u9664&#xff0c;\u4e34\u65f6\u7981\u7528\u8be5\u6743\u80fd&#xff0c;\u540e\u7eed\u8fd8\u80fd\u518d\u628a\u8fd9\u9879\u6743\u80fd\u6062\u590d\u5230\u6709\u6548\u96c6\u4e2d\u3002<\/li>\n<li>\u53ef\u7ee7\u627f\u96c6&#xff08;Inheritable&#xff09;&#xff1a;\u5f53\u8be5\u8fdb\u7a0b\u8c03\u7528 exec \u52a0\u8f7d\u65b0\u7a0b\u5e8f\u65f6&#xff0c;\u53ef\u4ee5\u4f20\u9012\u7ed9\u65b0\u8fdb\u7a0b\u5141\u8bb8\u96c6\u7684\u6743\u80fd\u3002<\/li>\n<\/ul>\n<p>\u6211\u4eec\u53ef\u4ee5\u5728 Linux \u7279\u6709\u7684 \/proc\/PID\/status \u6587\u4ef6\u7684 CapInh\u3001CapPrm\u3001CapEff \u8fd9\u4e09\u4e2a\u5b57\u6bb5\u4e2d&#xff0c;\u67e5\u770b\u4efb\u610f\u8fdb\u7a0b\u4e09\u7ec4\u6743\u80fd\u96c6\u7684\u5341\u516d\u8fdb\u5236\u8868\u793a\u3002<\/p>\n<p>getpcap \u5de5\u5177&#xff08;\u5c5e\u4e8e 39.7 \u8282\u4ecb\u7ecd\u7684 libcap \u8f6f\u4ef6\u5305&#xff09;\u80fd\u591f\u4ee5\u66f4\u6613\u8bfb\u7684\u683c\u5f0f\u5c55\u793a\u8fdb\u7a0b\u7684\u6743\u80fd\u3002<\/p>\n<p>\u901a\u8fc7 fork() \u521b\u5efa\u7684\u5b50\u8fdb\u7a0b&#xff0c;\u4f1a\u7ee7\u627f\u7236\u8fdb\u7a0b\u6743\u80fd\u96c6\u7684\u526f\u672c\u3002\u6211\u4eec\u5c06\u5728 39.5 \u8282\u4ecb\u7ecd\u6267\u884c exec() \u65f6\u6743\u80fd\u96c6\u7684\u5904\u7406\u89c4\u5219\u3002<\/p>\n<p>\u5b9e\u9645\u4e0a&#xff0c;\u6743\u80fd\u662f\u6309\u7ebf\u7a0b\u7684\u5c5e\u6027&#xff0c;\u8fdb\u7a0b\u5185\u7684\u6bcf\u4e00\u4e2a\u7ebf\u7a0b\u90fd\u53ef\u4ee5\u72ec\u7acb\u8c03\u6574\u81ea\u8eab\u6743\u80fd\u3002\u591a\u7ebf\u7a0b\u8fdb\u7a0b\u4e2d\u67d0\u4e2a\u7279\u5b9a\u7ebf\u7a0b\u7684\u6743\u80fd&#xff0c;\u8bb0\u5f55\u5728 \/proc\/PID\/task\/TID\/status \u6587\u4ef6&#xff1b;\u800c \/proc\/PID\/status \u6587\u4ef6\u5c55\u793a\u7684\u662f\u4e3b\u7ebf\u7a0b\u7684\u6743\u80fd\u3002<\/p>\n<p>\u5728\u5185\u6838 2.6.25 \u7248\u672c\u4e4b\u524d&#xff0c;Linux \u4f7f\u7528 32 \u4f4d\u6765\u8868\u793a\u6743\u80fd\u96c6\u30022.6.25 \u5185\u6838\u65b0\u589e\u66f4\u591a\u6743\u80fd&#xff0c;\u56e0\u6b64\u6743\u80fd\u96c6\u5347\u7ea7\u4e3a 64 \u4f4d\u3002<\/p>\n<h4>39.3.2 File Capabilities<\/h4>\n<p>\u5982\u679c\u6587\u4ef6\u7ed1\u5b9a\u4e86\u6743\u80fd\u96c6&#xff0c;\u90a3\u4e48\u5f53\u8fdb\u7a0b\u901a\u8fc7exec\u6267\u884c\u8be5\u6587\u4ef6\u65f6&#xff0c;\u5c31\u4f1a\u4f9d\u636e\u8fd9\u4e9b\u6743\u80fd\u96c6\u786e\u5b9a\u8d4b\u4e88\u8be5\u8fdb\u7a0b\u7684\u6743\u80fd\u3002\u6587\u4ef6\u6743\u80fd\u96c6\u5171\u5206\u4e3a\u4e09\u7ec4&#xff1a;<\/p>\n<ul>\n<li>\u5141\u8bb8\u96c6&#xff08;Permitted&#xff09;&#xff1a;\u5728exec()\u6267\u884c\u671f\u95f4&#xff0c;\u53ef\u4ee5\u6dfb\u52a0\u5230\u8fdb\u7a0b\u5141\u8bb8\u96c6\u7684\u4e00\u7ec4\u6743\u80fd&#xff0c;\u4e0d\u53d7\u8fdb\u7a0b\u539f\u6709\u6743\u80fd\u5f71\u54cd\u3002<\/li>\n<li>\u6709\u6548\u96c6&#xff08;Effective&#xff09;&#xff1a;\u5b83\u4ec5\u4e3a\u5355\u4e2a\u6bd4\u7279\u6807\u5fd7\u4f4d\u3002\u82e5\u8be5\u4f4d\u542f\u7528&#xff0c;\u90a3\u4e48exec()\u6267\u884c\u65f6&#xff0c;\u8fdb\u7a0b\u65b0\u5141\u8bb8\u96c6\u4e2d\u751f\u6548\u7684\u6743\u80fd&#xff0c;\u4e5f\u4f1a\u5728\u8fdb\u7a0b\u65b0\u6709\u6548\u96c6\u4e2d\u542f\u7528&#xff1b;\u82e5\u6587\u4ef6\u6709\u6548\u4f4d\u672a\u542f\u7528&#xff0c;\u5219exec()\u4e4b\u540e&#xff0c;\u8fdb\u7a0b\u65b0\u6709\u6548\u96c6\u521d\u59cb\u4e3a\u7a7a\u3002<\/li>\n<li>\u53ef\u7ee7\u627f\u96c6&#xff08;Inheritable&#xff09;&#xff1a;\u8be5\u96c6\u5408\u4f1a\u4e0e\u8fdb\u7a0b\u7684\u53ef\u7ee7\u627f\u96c6\u505a\u63a9\u7801\u8fd0\u7b97&#xff0c;\u4ee5\u6b64\u786e\u5b9aexec()\u6267\u884c\u540e\u9700\u8981\u5728\u8fdb\u7a0b\u5141\u8bb8\u96c6\u4e2d\u542f\u7528\u7684\u6743\u80fd\u3002<\/li>\n<\/ul>\n<p>39.5 \u8282\u5c06\u8be6\u7ec6\u4ecb\u7ecdexec()\u8fc7\u7a0b\u4e2d\u6587\u4ef6\u6743\u80fd\u7684\u4f7f\u7528\u89c4\u5219\u3002<\/p>\n<p>\u6587\u4ef6\u5141\u8bb8\u6743\u80fd\u96c6\u4e0e\u53ef\u7ee7\u627f\u6743\u80fd\u96c6\u8fc7\u53bb\u88ab\u79f0\u4e3a\u5f3a\u5236\u96c6&#xff08;forced&#xff09;\u548c\u8bb8\u53ef\u96c6&#xff08;allowed&#xff09;\u3002\u8fd9\u4e9b\u672f\u8bed\u73b0\u5df2\u5e9f\u5f03&#xff0c;\u4f46\u4ecd\u6709\u52a9\u4e8e\u7406\u89e3\u6982\u5ff5\u3002\u6587\u4ef6\u5141\u8bb8\u6743\u80fd&#xff0c;\u662f\u5728exec()\u671f\u95f4\u5f3a\u5236\u5199\u5165\u8fdb\u7a0b\u5141\u8bb8\u96c6\u7684\u6743\u80fd&#xff0c;\u4e0d\u53d7\u8fdb\u7a0b\u539f\u6709\u6743\u80fd\u5f71\u54cd\u3002\u6587\u4ef6\u53ef\u7ee7\u627f\u6743\u80fd&#xff0c;\u5219\u662f\u6587\u4ef6\u5141\u8bb8\u7eb3\u5165\u8fdb\u7a0b\u5141\u8bb8\u96c6\u7684\u6743\u80fd&#xff0c;\u524d\u63d0\u662f\u8fd9\u4e9b\u6743\u80fd\u540c\u65f6\u5728\u8fdb\u7a0b\u7684\u53ef\u7ee7\u627f\u6743\u80fd\u96c6\u4e2d\u5904\u4e8e\u542f\u7528\u72b6\u6001\u3002<\/p>\n<p>\u4e0e\u6587\u4ef6\u7ed1\u5b9a\u7684\u6743\u80fd\u5b58\u653e\u5728\u540d\u4e3asecurity.capability\u7684\u5b89\u5168\u6269\u5c55\u5c5e\u6027\u4e2d&#xff08;\u53c2\u89c1 16.1 \u8282&#xff09;\u3002\u4fee\u6539\u8be5\u6269\u5c55\u5c5e\u6027\u9700\u8981\u62e5\u6709CAP_SETFCAP\u6743\u80fd\u3002<\/p>\n<h4>39.3.3 Purpose of the Process Permitted and Effective Capability Sets<\/h4>\n<p>\u8fdb\u7a0b\u5141\u8bb8\u6743\u80fd\u96c6\u89c4\u5b9a\u4e86\u8fdb\u7a0b\u80fd\u591f\u4f7f\u7528\u7684\u6743\u80fd\u3002\u8fdb\u7a0b\u6709\u6548\u6743\u80fd\u96c6\u4ee3\u8868\u8fdb\u7a0b\u5f53\u524d\u751f\u6548\u7684\u6743\u80fd \u2014\u2014 \u4e5f\u5c31\u662f\u5185\u6838\u7528\u6765\u6821\u9a8c\u8fdb\u7a0b\u662f\u5426\u5177\u5907\u6267\u884c\u7279\u5b9a\u64cd\u4f5c\u6240\u9700\u7279\u6743\u7684\u6743\u80fd\u96c6\u5408\u3002<\/p>\n<p>\u5141\u8bb8\u6743\u80fd\u96c6\u5bf9\u6709\u6548\u96c6\u5212\u5b9a\u4e86\u4e0a\u9650\u3002\u8fdb\u7a0b\u4ec5\u5f53\u67d0\u9879\u6743\u80fd\u5b58\u5728\u4e8e\u5141\u8bb8\u96c6\u4e2d\u65f6&#xff0c;\u624d\u53ef\u4ee5\u5728\u6709\u6548\u96c6\u4e2d\u542f\u7528\u8be5\u6743\u80fd\u3002&#xff08;\u672f\u8bed add to\u3001set \u6709\u65f6\u548c raise \u540c\u4e49&#xff1b;\u5bf9\u5e94\u7684\u53cd\u5411\u64cd\u4f5c\u79f0\u4e3a drop&#xff0c;\u4e5f\u53ef\u7528 remove \u6216 clear \u8868\u8fbe\u3002&#xff09;<\/p>\n<p>\u6709\u6548\u6743\u80fd\u96c6\u4e0e\u5141\u8bb8\u6743\u80fd\u96c6\u4e4b\u95f4\u7684\u5173\u7cfb&#xff0c;\u7c7b\u4f3c\u4e8e setuid-root \u7a0b\u5e8f\u4e2d\u6709\u6548\u7528\u6237 ID\u548c\u4fdd\u5b58\u7684\u8bbe\u7f6e\u7528\u6237 ID\u4e4b\u95f4\u7684\u5173\u7cfb\u3002\u4ece\u6709\u6548\u96c6\u4e2d\u79fb\u9664\u67d0\u9879\u6743\u80fd&#xff0c;\u5c31\u597d\u6bd4\u4e34\u65f6\u5c06\u6709\u6548\u7528\u6237 ID \u4ece 0 \u4e0b\u653e&#xff0c;\u540c\u65f6\u4fdd\u5b58\u7684\u8bbe\u7f6e\u7528\u6237 ID \u4ecd\u4fdd\u7559\u4e3a 0\u3002\u540c\u65f6\u4ece\u6709\u6548\u96c6\u548c\u5141\u8bb8\u96c6\u4e2d\u79fb\u9664\u67d0\u9879\u6743\u80fd&#xff0c;\u5219\u7c7b\u4f3c\u4e8e\u5c06\u6709\u6548\u7528\u6237 ID \u4e0e\u4fdd\u5b58\u7684\u8bbe\u7f6e\u7528\u6237 ID \u90fd\u6539\u4e3a\u975e 0 \u503c&#xff0c;\u6c38\u4e45\u653e\u5f03\u8d85\u7ea7\u7528\u6237\u7279\u6743\u3002<\/p>\n<h4>39.3.4 Purpose of the File Permitted and Effective Capability Sets<\/h4>\n<p>\u6587\u4ef6\u5141\u8bb8\u6743\u80fd\u96c6\u63d0\u4f9b\u4e86\u4e00\u79cd\u673a\u5236&#xff0c;\u53ef\u8ba9\u53ef\u6267\u884c\u6587\u4ef6\u5411\u8fdb\u7a0b\u8d4b\u4e88\u6743\u80fd\u3002\u5b83\u6307\u5b9a\u4e00\u7ec4\u6743\u80fd&#xff0c;\u5728\u8c03\u7528exec()\u65f6\u5206\u914d\u7ed9\u8fdb\u7a0b\u7684\u5141\u8bb8\u6743\u80fd\u96c6\u3002<\/p>\n<p>\u6587\u4ef6\u6709\u6548\u6743\u80fd\u96c6\u662f\u4e00\u4e2a\u4ec5\u53ef\u542f\u7528\u6216\u7981\u7528\u7684\u6807\u5fd7\u4f4d\u3002\u60f3\u8981\u7406\u89e3\u4e3a\u4ec0\u4e48\u8be5\u96c6\u5408\u53ea\u6709\u5355\u4e2a\u6bd4\u7279\u4f4d&#xff0c;\u6211\u4eec\u9700\u8981\u5206\u6790\u6267\u884c\u7a0b\u5e8f\u65f6\u4f1a\u51fa\u73b0\u7684\u4e24\u79cd\u573a\u666f&#xff1a;<\/p>\n<ul>\n<li>\u7a0b\u5e8f\u4e0d\u611f\u77e5\u6743\u80fd&#xff08;capability-dumb&#xff09;&#xff1a;\u5373\u7a0b\u5e8f\u4e0d\u4e86\u89e3\u6743\u80fd\u673a\u5236&#xff08;\u5c5e\u4e8e\u4f20\u7edf set-user-ID-root \u7a0b\u5e8f&#xff09;\u3002\u8fd9\u7c7b\u7a0b\u5e8f\u4e0d\u77e5\u9053\u9700\u8981\u5728\u6709\u6548\u96c6\u4e2d\u542f\u7528\u6743\u80fd\u624d\u80fd\u6267\u884c\u7279\u6743\u64cd\u4f5c\u3002\u5bf9\u4e8e\u8fd9\u7c7b\u7a0b\u5e8f&#xff0c;\u6267\u884cexec()\u65f6&#xff0c;\u5e94\u5f53\u628a\u8fdb\u7a0b\u65b0\u5141\u8bb8\u96c6\u4e2d\u7684\u5168\u90e8\u6743\u80fd\u81ea\u52a8\u8d4b\u4e88\u6709\u6548\u96c6\u3002\u8be5\u6548\u679c\u901a\u8fc7\u542f\u7528\u6587\u4ef6\u6709\u6548\u4f4d\u5b9e\u73b0\u3002<\/li>\n<li>\u7a0b\u5e8f\u611f\u77e5\u6743\u80fd&#xff08;capability-aware&#xff09;&#xff1a;\u7a0b\u5e8f\u5728\u8bbe\u8ba1\u65f6\u5c31\u8003\u8651\u4e86\u6743\u80fd\u6846\u67b6&#xff0c;\u4f1a\u8c03\u7528\u76f8\u5e94\u7cfb\u7edf\u8c03\u7528&#xff08;\u540e\u6587\u4ecb\u7ecd&#xff09;\u6765\u542f\u7528\u3001\u5173\u95ed\u6709\u6548\u96c6\u4e2d\u7684\u6743\u80fd\u3002\u57fa\u4e8e\u6700\u5c0f\u6743\u9650\u539f\u5219&#xff0c;\u8fd9\u7c7b\u7a0b\u5e8f\u5728exec()\u4e4b\u540e&#xff0c;\u8fdb\u7a0b\u6709\u6548\u6743\u80fd\u96c6\u5185\u6240\u6709\u6743\u80fd\u521d\u59cb\u90fd\u5e94\u5904\u4e8e\u7981\u7528\u72b6\u6001\u3002\u8be5\u6548\u679c\u901a\u8fc7\u5173\u95ed\u6587\u4ef6\u6709\u6548\u4f4d\u5b9e\u73b0\u3002<\/li>\n<\/ul>\n<h4>39.3.5 Purpose of the Process and File Inheritable Sets<\/h4>\n<p>\u4e4d\u4e00\u770b&#xff0c;\u8fdb\u7a0b\u4e0e\u6587\u4ef6\u5404\u81ea\u4f7f\u7528\u5141\u8bb8\u96c6\u548c\u6709\u6548\u96c6&#xff0c;\u4f3c\u4e4e\u5c31\u8db3\u4ee5\u6784\u6210\u4e00\u5957\u5b8c\u6574\u7684\u6743\u80fd\u4f53\u7cfb\u3002\u4f46\u5728\u90e8\u5206\u573a\u666f\u4e0b&#xff0c;\u4ec5\u4f9d\u9760\u8fd9\u4e24\u7ec4\u96c6\u5408\u662f\u4e0d\u591f\u7684\u3002\u4e3e\u4e2a\u4f8b\u5b50&#xff1a;\u5982\u679c\u8fdb\u7a0b\u8c03\u7528exec()\u65f6&#xff0c;\u5e0c\u671b\u5728\u6267\u884c exec \u4e4b\u540e\u4fdd\u7559\u5f53\u524d\u62e5\u6709\u7684\u90e8\u5206\u6743\u80fd&#xff0c;\u8be5\u5982\u4f55\u5904\u7406&#xff1f;\u76f4\u89c2\u4e0a\u6743\u80fd\u673a\u5236\u4f3c\u4e4e\u53ef\u4ee5\u76f4\u63a5\u5728 exec \u8fc7\u7a0b\u4e2d\u4fdd\u7559\u8fdb\u7a0b\u7684\u5141\u8bb8\u6743\u80fd&#xff0c;\u4ee5\u6b64\u5b9e\u73b0\u8be5\u9700\u6c42\u3002\u4f46\u8fd9\u79cd\u65b9\u6848\u65e0\u6cd5\u5904\u7406\u4e0b\u9762\u4e24\u7c7b\u573a\u666f&#xff1a;<\/p>\n<ul>\n<li>\u6267\u884c exec \u64cd\u4f5c\u672c\u8eab\u53ef\u80fd\u9700\u8981\u67d0\u4e9b\u7279\u6743&#xff08;\u4f8b\u5982CAP_DAC_OVERRIDE&#xff09;&#xff0c;\u800c\u6211\u4eec\u5e76\u4e0d\u5e0c\u671b\u8fd9\u4e9b\u7279\u6743\u5728 exec \u4e4b\u540e\u7ee7\u7eed\u4fdd\u7559\u3002<\/li>\n<li>\u5047\u8bbe\u6211\u4eec\u5df2\u7ecf\u4e3b\u52a8\u4e22\u5f03\u4e86\u4e00\u90e8\u5206\u4e0d\u60f3\u5728 exec \u540e\u4fdd\u7559\u7684\u5141\u8bb8\u6743\u80fd&#xff0c;\u4f46\u968f\u540e exec \u8c03\u7528\u5931\u8d25\u3002\u6b64\u65f6\u7a0b\u5e8f\u53ef\u80fd\u53c8\u9700\u8981\u90a3\u4e9b\u5df2\u7ecf\u4e0d\u53ef\u6062\u590d\u5730\u4e22\u5f03\u7684\u5141\u8bb8\u6743\u80fd\u3002<\/li>\n<\/ul>\n<p>\u51fa\u4e8e\u4e0a\u8ff0\u539f\u56e0&#xff0c;\u8fdb\u7a0b\u7684\u5141\u8bb8\u6743\u80fd\u96c6\u4e0d\u4f1a\u5728 exec \u8c03\u7528\u540e\u81ea\u52a8\u4fdd\u7559\u3002\u4e3a\u6b64\u5f15\u5165\u4e86\u53e6\u4e00\u7ec4\u6743\u80fd\u96c6&#xff1a;\u53ef\u7ee7\u627f\u96c6&#xff08;inheritable set&#xff09;\u3002\u53ef\u7ee7\u627f\u96c6\u63d0\u4f9b\u4e00\u79cd\u673a\u5236&#xff0c;\u8ba9\u8fdb\u7a0b\u80fd\u591f\u8de8 exec \u4fdd\u7559\u90e8\u5206\u6743\u80fd\u3002<\/p>\n<p>\u8fdb\u7a0b\u53ef\u7ee7\u627f\u6743\u80fd\u96c6\u6307\u5b9a\u4e86\u4e00\u7ec4\u6743\u80fd&#xff0c;\u8fd9\u4e9b\u6743\u80fd\u53ef\u4ee5\u5728 exec \u6267\u884c\u671f\u95f4\u5206\u914d\u7ed9\u8fdb\u7a0b\u7684\u5141\u8bb8\u6743\u80fd\u96c6\u3002\u5bf9\u5e94\u7684\u6587\u4ef6\u53ef\u7ee7\u627f\u96c6\u4f1a\u4e0e\u8fdb\u7a0b\u53ef\u7ee7\u627f\u96c6\u505a\u63a9\u7801\u6309\u4f4d\u4e0e&#xff08;AND&#xff09;\u8fd0\u7b97&#xff0c;\u4ee5\u6b64\u786e\u5b9a exec \u8fc7\u7a0b\u4e2d\u5b9e\u9645\u6dfb\u52a0\u5230\u8fdb\u7a0b\u5141\u8bb8\u6743\u80fd\u96c6\u7684\u6743\u80fd\u3002<\/p>\n<p>\u4e0d\u76f4\u63a5\u8de8 exec \u4fdd\u7559\u8fdb\u7a0b\u5141\u8bb8\u6743\u80fd\u96c6&#xff0c;\u8fd8\u6709\u4e00\u5c42\u8bbe\u8ba1\u7406\u5ff5\u4e0a\u7684\u539f\u56e0\u3002\u6743\u80fd\u673a\u5236\u7684\u6838\u5fc3\u601d\u60f3\u662f&#xff1a;\u8d4b\u4e88\u8fdb\u7a0b\u7684\u6240\u6709\u7279\u6743&#xff0c;\u90fd\u7531\u8fdb\u7a0b\u6240\u6267\u884c\u7684\u6587\u4ef6\u6765\u6388\u4e88\u548c\u7ba1\u63a7\u3002\u867d\u7136\u8fdb\u7a0b\u53ef\u7ee7\u627f\u96c6\u6307\u5b9a\u4e86\u53ef\u4ee5\u8de8 exec \u4f20\u9012\u7684\u6743\u80fd&#xff0c;\u4f46\u8fd9\u4e9b\u6743\u80fd\u8fd8\u8981\u7ecf\u8fc7\u6587\u4ef6\u53ef\u7ee7\u627f\u96c6\u7684\u63a9\u7801\u7b5b\u9009\u3002<\/p>\n<h4>39.3.6 Assigning and Viewing File Capabilities from the Shell<\/h4>\n<p>setcap(8) \u548c getcap(8) \u547d\u4ee4\u5305\u542b\u5728 39.7 \u8282\u4ecb\u7ecd\u7684 libcap \u8f6f\u4ef6\u5305\u4e2d&#xff0c;\u53ef\u7528\u4e8e\u64cd\u4f5c\u6587\u4ef6\u6743\u80fd\u96c6\u3002\u6211\u4eec\u4ee5\u6807\u51c6date(1)\u7a0b\u5e8f\u4e3a\u4f8b&#xff0c;\u7b80\u5355\u6f14\u793a\u8fd9\u4e24\u6761\u547d\u4ee4\u7684\u7528\u6cd5\u3002&#xff08;\u6309\u7167 39.3.4 \u8282\u4e2d\u7684\u5b9a\u4e49&#xff0c;\u8be5\u7a0b\u5e8f\u5c5e\u4e8e\u4e0d\u611f\u77e5\u6743\u80fd\u7684\u5e94\u7528\u3002&#xff09;\u5728\u7279\u6743\u72b6\u6001\u4e0b\u8fd0\u884c\u65f6&#xff0c;date(1)\u53ef\u4fee\u6539\u7cfb\u7edf\u65f6\u95f4\u3002date \u7a0b\u5e8f\u5e76\u672a\u8bbe\u7f6e set-user-ID-root \u4f4d&#xff0c;\u56e0\u6b64\u901a\u5e38\u60c5\u51b5\u4e0b&#xff0c;\u552f\u4e00\u4ee5\u7279\u6743\u8fd0\u884c\u5b83\u7684\u65b9\u5f0f\u662f\u5207\u6362\u4e3a\u8d85\u7ea7\u7528\u6237\u3002<\/p>\n<p>\u6211\u4eec\u5148\u67e5\u770b\u5f53\u524d\u7cfb\u7edf\u65f6\u95f4&#xff0c;\u518d\u5c1d\u8bd5\u4ee5\u975e\u7279\u6743\u7528\u6237\u4fee\u6539\u7cfb\u7edf\u65f6\u95f4&#xff1a;<\/p>\n<p>$ <span class=\"token function\">date<\/span><br \/>\nMon Sep <span class=\"token number\">28<\/span> 03:08:38 AM UTC <span class=\"token number\">2026<\/span><br \/>\n$ <span class=\"token function\">date<\/span> <span class=\"token parameter variable\">-s<\/span> <span class=\"token string\">&#039;2018-02-01 21:39&#039;<\/span><br \/>\ndate: cannot <span class=\"token builtin class-name\">set<\/span> date: Operation not permitted<br \/>\nThu Feb  <span class=\"token number\">1<\/span> 09:39:00 PM UTC <span class=\"token number\">2018<\/span><\/p>\n<p>\u4ece\u4e0a\u9762\u7684\u8f93\u51fa\u53ef\u4ee5\u770b\u5230&#xff1a;date \u547d\u4ee4\u4fee\u6539\u7cfb\u7edf\u65f6\u95f4\u7684\u64cd\u4f5c\u5931\u8d25\u4e86&#xff0c;\u4f46\u4ecd\u7136\u6309\u7167\u6807\u51c6\u683c\u5f0f\u8f93\u51fa\u4e86\u4f20\u5165\u7684\u53c2\u6570\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\u5207\u6362\u4e3a\u8d85\u7ea7\u7528\u6237&#xff0c;\u6b64\u65f6\u5c31\u53ef\u4ee5\u6210\u529f\u4fee\u6539\u7cfb\u7edf\u65f6\u95f4&#xff1a;<\/p>\n<p>$ <span class=\"token function\">sudo<\/span> <span class=\"token function\">date<\/span> <span class=\"token parameter variable\">-s<\/span> <span class=\"token string\">&#039;2026-09-28 03:11:30&#039;<\/span><br \/>\nMon Sep <span class=\"token number\">28<\/span> 03:11:30 AM UTC <span class=\"token number\">2026<\/span><br \/>\n$ <span class=\"token function\">date<\/span><br \/>\nMon Sep <span class=\"token number\">28<\/span> 03:11:32 AM UTC <span class=\"token number\">2026<\/span><\/p>\n<p>\u73b0\u5728\u590d\u5236\u4e00\u4efd date \u7a0b\u5e8f&#xff0c;\u5e76\u4e3a\u5176\u8d4b\u4e88\u6240\u9700\u7684\u6743\u80fd&#xff1a;<\/p>\n<p>$ <span class=\"token builtin class-name\">pwd<\/span><br \/>\n\/home\/vagrant\/test<br \/>\n$ <span class=\"token function\">whereis<\/span> <span class=\"token parameter variable\">-b<\/span> <span class=\"token function\">date<\/span><br \/>\ndate: \/usr\/bin\/date<br \/>\n$ <span class=\"token function\">cp<\/span> \/usr\/bin\/date <span class=\"token builtin class-name\">.<\/span><br \/>\n$ <span class=\"token function\">sudo<\/span> setcap <span class=\"token string\">&#034;cap_sys_time&#061;pe&#034;<\/span> <span class=\"token function\">date<\/span><br \/>\n$ getcap <span class=\"token function\">date<\/span><br \/>\n<span class=\"token function\">date<\/span> <span class=\"token assign-left variable\">cap_sys_time<\/span><span class=\"token operator\">&#061;<\/span>ep<\/p>\n<p>\u4e0a\u9762\u8fd9\u6761 setcap \u547d\u4ee4&#xff0c;\u5c06 CAP_SYS_TIME \u6743\u80fd\u8d4b\u4e88\u8be5\u53ef\u6267\u884c\u6587\u4ef6\u7684\u5141\u8bb8\u96c6&#xff08;p&#xff09;\u4e0e\u6709\u6548\u96c6&#xff08;e&#xff09;\u3002\u968f\u540e\u6211\u4eec\u4f7f\u7528 getcap \u547d\u4ee4\u9a8c\u8bc1\u8d4b\u4e88\u8be5\u6587\u4ef6\u7684\u6743\u80fd\u3002&#xff08;setcap \u548c getcap \u7528\u4e8e\u8868\u793a\u6743\u80fd\u96c6\u7684\u8bed\u6cd5&#xff0c;\u5728 libcap \u8f6f\u4ef6\u5305\u4e2d\u7684 cap_from_text (3) \u624b\u518c\u9875\u91cc\u6709\u8bf4\u660e\u3002&#xff09;<\/p>\n<p>\u6b64 date \u7a0b\u5e8f\u526f\u672c\u4e0a\u6302\u8f7d\u7684\u6587\u4ef6\u6743\u80fd&#xff0c;\u4f7f\u5f97\u975e\u7279\u6743\u7528\u6237\u4e5f\u80fd\u501f\u52a9\u8be5\u7a0b\u5e8f\u4fee\u6539\u7cfb\u7edf\u65f6\u95f4&#xff1a;<\/p>\n<p>$ .\/date <span class=\"token parameter variable\">-s<\/span> <span class=\"token string\">&#039;2026-09-28 03:16:30&#039;<\/span><br \/>\nMon Sep <span class=\"token number\">28<\/span> 03:16:30 AM UTC <span class=\"token number\">2026<\/span><br \/>\n$ <span class=\"token function\">date<\/span><br \/>\nMon Sep <span class=\"token number\">28<\/span> 03:16:32 AM UTC <span class=\"token number\">2026<\/span><\/p>\n<h3>39.4 The Modern Capabilities Implementation<\/h3>\n<p>\u4e00\u5957\u5b8c\u6574\u7684\u6743\u80fd\u5b9e\u73b0&#xff0c;\u9700\u8981\u5177\u5907\u4ee5\u4e0b\u8981\u7d20&#xff1a;<\/p>\n<ul>\n<li>\u5bf9\u4e8e\u6bcf\u4e00\u9879\u7279\u6743\u64cd\u4f5c&#xff0c;\u5185\u6838\u5e94\u5f53\u68c0\u67e5\u8fdb\u7a0b\u662f\u5426\u62e5\u6709\u5bf9\u5e94\u7684\u6743\u80fd&#xff0c;\u800c\u4e0d\u662f\u6821\u9a8c\u6709\u6548\u7528\u6237 ID&#xff08;\u6216\u6587\u4ef6\u7cfb\u7edf\u7528\u6237 ID&#xff09;\u662f\u5426\u4e3a 0\u3002<\/li>\n<li>\u5185\u6838\u5fc5\u987b\u63d0\u4f9b\u7cfb\u7edf\u8c03\u7528&#xff0c;\u652f\u6301\u83b7\u53d6\u548c\u4fee\u6539\u8fdb\u7a0b\u7684\u6743\u80fd\u3002<\/li>\n<li>\u5185\u6838\u5fc5\u987b\u652f\u6301\u5c06\u6743\u80fd\u9644\u7740\u5728\u53ef\u6267\u884c\u6587\u4ef6\u4e0a&#xff0c;\u4f7f\u5f97\u6267\u884c\u8be5\u6587\u4ef6\u65f6&#xff0c;\u8fdb\u7a0b\u80fd\u591f\u83b7\u5f97\u5bf9\u5e94\u7684\u6743\u80fd\u3002\u8fd9\u7c7b\u4f3c\u4e8e set-user-ID \u4f4d&#xff0c;\u4f46\u53ef\u4ee5\u5bf9\u53ef\u6267\u884c\u6587\u4ef6\u72ec\u7acb\u6307\u5b9a\u5404\u9879\u6743\u80fd\u3002\u9664\u6b64\u4e4b\u5916&#xff0c;\u7cfb\u7edf\u8fd8\u9700\u8981\u63d0\u4f9b\u4e00\u7ec4\u7f16\u7a0b\u63a5\u53e3\u4e0e\u547d\u4ee4&#xff0c;\u7528\u4e8e\u8bbe\u7f6e\u548c\u67e5\u770b\u9644\u7740\u5728\u53ef\u6267\u884c\u6587\u4ef6\u4e0a\u7684\u6743\u80fd\u3002<\/li>\n<\/ul>\n<p>2.6.23 \u53ca\u66f4\u65e9\u7248\u672c\u7684 Linux \u5185\u6838&#xff0c;\u4ec5\u6ee1\u8db3\u4e0a\u8ff0\u524d\u4e24\u9879\u8981\u6c42\u3002\u81ea 2.6.24 \u5185\u6838\u8d77&#xff0c;Linux \u652f\u6301\u5411\u6587\u4ef6\u9644\u52a0\u6743\u80fd\u3002\u5185\u6838 2.6.25 \u4e0e 2.6.26 \u7248\u672c\u9646\u7eed\u589e\u52a0\u5404\u7c7b\u7279\u6027&#xff0c;\u4ece\u800c\u5b8c\u6210\u6574\u5957\u6743\u80fd\u673a\u5236\u7684\u5b9e\u73b0\u3002<\/p>\n<p>\u5728\u6743\u80fd\u76f8\u5173\u7684\u5927\u90e8\u5206\u8ba8\u8bba\u4e2d&#xff0c;\u6211\u4eec\u5c06\u805a\u7126\u73b0\u4ee3\u5b9e\u73b0\u65b9\u6848\u300239.10 \u8282\u4f1a\u4ecb\u7ecd\u6587\u4ef6\u6743\u80fd\u5f15\u5165\u4e4b\u524d\u7684\u5b9e\u73b0\u5dee\u5f02\u3002\u6b64\u5916&#xff0c;\u5728\u73b0\u4ee3\u5185\u6838\u4e2d\u6587\u4ef6\u6743\u80fd\u5c5e\u4e8e\u53ef\u9009\u5185\u6838\u7ec4\u4ef6&#xff1b;\u4f46\u5728\u4e3b\u4f53\u5185\u5bb9\u7684\u8ba8\u8bba\u91cc&#xff0c;\u6211\u4eec\u5047\u5b9a\u8be5\u7ec4\u4ef6\u5df2\u5f00\u542f\u3002\u540e\u6587\u4f1a\u4ecb\u7ecd\u6587\u4ef6\u6743\u80fd\u672a\u542f\u7528\u65f6\u4ea7\u751f\u7684\u884c\u4e3a\u5dee\u5f02\u3002&#xff08;\u5f88\u591a\u65b9\u9762&#xff0c;\u8be5\u884c\u4e3a\u548c 2.6.24 \u4e4b\u524d\u3001\u5c1a\u672a\u5b9e\u73b0\u6587\u4ef6\u6743\u80fd\u7684 Linux \u5185\u6838\u76f8\u8fd1\u3002&#xff09;<\/p>\n<p>\u63a5\u4e0b\u6765\u7684\u7ae0\u8282&#xff0c;\u6211\u4eec\u4f1a\u6df1\u5165\u8bb2\u89e3 Linux \u6743\u80fd\u673a\u5236\u7684\u5b9e\u73b0\u7ec6\u8282\u3002<\/p>\n<h3>39.5 Transformation of Process Capabilities During exec()<\/h3>\n<p>\u5728\u6267\u884cexec()\u671f\u95f4&#xff0c;\u5185\u6838\u4f1a\u6839\u636e\u8fdb\u7a0b\u5f53\u524d\u7684\u6743\u80fd&#xff0c;\u4ee5\u53ca\u5f85\u6267\u884c\u6587\u4ef6\u7684\u6743\u80fd\u96c6&#xff0c;\u4e3a\u8be5\u8fdb\u7a0b\u8bbe\u7f6e\u65b0\u7684\u6743\u80fd\u3002\u5185\u6838\u901a\u8fc7\u4e0b\u9762\u8fd9\u5957\u89c4\u5219\u8ba1\u7b97\u8fdb\u7a0b\u7684\u65b0\u6743\u80fd&#xff1a;<\/p>\n<p>P&#039;(permitted) &#061; (P(inheritable) &amp; F(inheritable)) | (F(permitted) &amp; cap_bset)<br \/>\nP&#039;(effective) &#061; F(effective) ? P&#039;(permitted) : 0<br \/>\nP&#039;(inheritable) &#061; P(inheritable)<\/p>\n<p>\u5728\u4e0a\u8ff0\u89c4\u5219\u4e2d&#xff1a;P \u4ee3\u8868exec \u6267\u884c\u4e4b\u524d\u7684\u6743\u80fd\u96c6&#xff1b;P&#039; \u4ee3\u8868exec \u6267\u884c\u4e4b\u540e\u7684\u6743\u80fd\u96c6&#xff1b;F \u4ee3\u8868\u6587\u4ef6\u6743\u80fd\u96c6\u3002\u6807\u8bc6\u7b26cap_bset\u4ee3\u8868\u6743\u80fd\u8fb9\u754c\u96c6&#xff08;capability bounding set&#xff09;\u3002\u8bf7\u6ce8\u610f&#xff1a;exec()\u4e0d\u4f1a\u4fee\u6539\u8fdb\u7a0b\u7684\u53ef\u7ee7\u627f\u6743\u80fd\u96c6\u3002<\/p>\n<h4>39.5.1 Capability Bounding Set<\/h4>\n<p>\u6743\u80fd\u8fb9\u754c\u96c6&#xff08;capability bounding set&#xff09;\u662f\u4e00\u79cd\u5b89\u5168\u673a\u5236&#xff0c;\u7528\u4e8e\u9650\u5236\u8fdb\u7a0b\u5728exec()\u8fc7\u7a0b\u4e2d\u80fd\u591f\u83b7\u53d6\u5230\u7684\u6743\u80fd\u3002\u8be5\u96c6\u5408\u7684\u4f5c\u7528\u89c4\u5219\u5982\u4e0b&#xff1a;<\/p>\n<ul>\n<li>\u5728exec()\u6267\u884c\u671f\u95f4&#xff0c;\u6743\u80fd\u8fb9\u754c\u96c6\u4f1a\u4e0e\u6587\u4ef6\u5141\u8bb8\u6743\u80fd\u505a\u6309\u4f4d\u4e0e\u8fd0\u7b97&#xff0c;\u4ee5\u6b64\u786e\u5b9a\u8d4b\u4e88\u65b0\u7a0b\u5e8f\u7684\u5141\u8bb8\u6743\u80fd\u3002\u6362\u53e5\u8bdd\u8bf4&#xff0c;\u5982\u679c\u67d0\u9879\u6743\u80fd\u4e0d\u5728\u8fb9\u754c\u96c6\u4e2d&#xff0c;\u90a3\u4e48\u5373\u4fbf\u53ef\u6267\u884c\u6587\u4ef6\u7684\u5141\u8bb8\u6743\u80fd\u96c6\u5305\u542b\u8be5\u9879\u6743\u80fd&#xff0c;\u4e5f\u65e0\u6cd5\u628a\u5b83\u6388\u4e88\u8fdb\u7a0b\u3002<\/li>\n<li>\u6743\u80fd\u8fb9\u754c\u96c6\u662f\u8fdb\u7a0b\u53ef\u7ee7\u627f\u6743\u80fd\u96c6\u53ef\u6dfb\u52a0\u6743\u80fd\u7684\u4e0a\u9650\u8d85\u96c6\u3002\u4e5f\u5c31\u662f\u8bf4&#xff0c;\u5982\u679c\u67d0\u9879\u6743\u80fd\u4e0d\u5728\u8fb9\u754c\u96c6\u4e2d&#xff0c;\u8fdb\u7a0b\u5c31\u65e0\u6cd5\u5c06\u81ea\u8eab\u5141\u8bb8\u96c6\u4e2d\u7684\u8be5\u9879\u6743\u80fd\u6dfb\u52a0\u5230\u53ef\u7ee7\u627f\u96c6&#xff1b;\u8fdb\u800c&#xff0c;\u5373\u4fbf\u5f85\u6267\u884c\u6587\u4ef6\u7684\u53ef\u7ee7\u627f\u96c6\u5305\u542b\u8be5\u6743\u80fd&#xff0c;\u4e5f\u65e0\u6cd5\u4f9d\u9760\u524d\u9762\u63d0\u5230\u7684\u6743\u80fd\u8f6c\u6362\u89c4\u5219&#xff0c;\u5728 exec \u4e4b\u540e\u628a\u8fd9\u9879\u6743\u80fd\u4fdd\u7559\u5728\u8fdb\u7a0b\u5141\u8bb8\u96c6\u4e2d\u3002<\/li>\n<\/ul>\n<p>\u6743\u80fd\u8fb9\u754c\u96c6\u662f\u6309\u8fdb\u7a0b\u7684\u5c5e\u6027&#xff0c;\u901a\u8fc7fork()\u521b\u5efa\u7684\u5b50\u8fdb\u7a0b\u4f1a\u7ee7\u627f\u8be5\u96c6\u5408&#xff0c;\u5e76\u4e14\u5728exec()\u6267\u884c\u540e\u4ecd\u7136\u4fdd\u7559\u3002\u5728\u652f\u6301\u6587\u4ef6\u6743\u80fd\u7684\u5185\u6838\u4e0a&#xff0c;\u6240\u6709\u8fdb\u7a0b\u7684\u59cb\u7956init\u8fdb\u7a0b\u542f\u52a8\u65f6&#xff0c;\u5176\u6743\u80fd\u8fb9\u754c\u96c6\u5305\u542b\u5168\u90e8\u6743\u80fd\u3002<\/p>\n<p>\u8fdb\u7a0b\u5982\u679c\u62e5\u6709CAP_SETPCAP\u6743\u80fd&#xff0c;\u5c31\u53ef\u4ee5\u901a\u8fc7prctl()\u7684PR_CAPBSET_DROP\u64cd\u4f5c&#xff0c;\u4e0d\u53ef\u64a4\u9500\u5730\u4ece\u81ea\u8eab\u8fb9\u754c\u96c6\u4e2d\u79fb\u9664\u6743\u80fd\u3002&#xff08;\u4ece\u8fb9\u754c\u96c6\u4e2d\u79fb\u9664\u67d0\u9879\u6743\u80fd&#xff0c;\u4e0d\u4f1a\u5f71\u54cd\u8be5\u8fdb\u7a0b\u7684\u5141\u8bb8\u3001\u6709\u6548\u4e0e\u53ef\u7ee7\u627f\u6743\u80fd\u96c6\u3002&#xff09;\u8fdb\u7a0b\u53ef\u4f7f\u7528prctl()\u7684PR_CAPBSET_READ\u64cd\u4f5c&#xff0c;\u5224\u65ad\u67d0\u6743\u80fd\u662f\u5426\u5b58\u5728\u4e8e\u81ea\u8eab\u8fb9\u754c\u96c6\u4e2d\u3002<\/p>\n<p>\u66f4\u51c6\u786e\u5730\u8bf4&#xff0c;\u6743\u80fd\u8fb9\u754c\u96c6\u5c5e\u4e8e\u6309\u7ebf\u7a0b\u7684\u5c5e\u6027\u3002\u81ea Linux 2.6.26 \u8d77&#xff0c;\u8be5\u5c5e\u6027\u5728 Linux \u7279\u6709\u7684\/proc\/PID\/task\/TID\/status\u6587\u4ef6\u4e2d\u4ee5CapBnd\u5b57\u6bb5\u5c55\u793a&#xff1b;\u800c\/proc\/PID\/status\u6587\u4ef6\u5c55\u793a\u7684\u662f\u8fdb\u7a0b\u4e3b\u7ebf\u7a0b\u7684\u8fb9\u754c\u96c6\u3002<\/p>\n<h4>39.5.2 Preserving root Semantics<\/h4>\n<p>\u4e3a\u4fdd\u7559 root \u7528\u6237\u7684\u4f20\u7edf\u8bed\u4e49&#xff08;\u5373 root \u62e5\u6709\u5168\u90e8\u7279\u6743&#xff09;&#xff0c;\u5f53 root \u6267\u884c\u6587\u4ef6\u65f6&#xff0c;\u4f1a\u5ffd\u7565\u8be5\u6587\u4ef6\u4e0a\u7ed1\u5b9a\u7684\u6240\u6709\u6743\u80fd\u96c6\u3002\u53d6\u800c\u4ee3\u4e4b&#xff0c;\u5728 39.5 \u8282\u6240\u8ff0\u7b97\u6cd5\u4e2d&#xff0c;exec()\u6267\u884c\u671f\u95f4\u6587\u4ef6\u6743\u80fd\u96c6\u6309\u865a\u62df\u5b9a\u4e49\u5904\u7406&#xff0c;\u89c4\u5219\u5982\u4e0b&#xff1a;<\/p>\n<ul>\n<li>\u5982\u679c\u6267\u884c\u7684\u662f set-user-ID-root \u7a0b\u5e8f&#xff0c;\u6216\u8005\u8c03\u7528exec()\u7684\u8fdb\u7a0b\u7684\u771f\u5b9e\u7528\u6237 ID\u3001\u6709\u6548\u7528\u6237 ID \u4e3a 0&#xff0c;\u5219\u6587\u4ef6\u53ef\u7ee7\u627f\u96c6\u4e0e\u5141\u8bb8\u96c6\u88ab\u865a\u62df\u5b9a\u4e49\u4e3a\u5168\u90e8\u7f6e 1&#xff08;\u5305\u542b\u6240\u6709\u6743\u80fd&#xff09;\u3002<\/li>\n<li>\u5982\u679c\u6267\u884c\u7684\u662f set-user-ID-root \u7a0b\u5e8f&#xff0c;\u6216\u8005\u8c03\u7528exec()\u7684\u8fdb\u7a0b\u6709\u6548\u7528\u6237 ID \u4e3a 0&#xff0c;\u5219\u6587\u4ef6\u6709\u6548\u4f4d\u88ab\u865a\u62df\u5b9a\u4e49\u4e3a\u5df2\u5f00\u542f\u3002<\/li>\n<\/ul>\n<p>\u5047\u8bbe\u5f53\u524d\u6267\u884c\u7684\u662f set-user-ID-root \u7a0b\u5e8f&#xff0c;\u57fa\u4e8e\u6587\u4ef6\u6743\u80fd\u96c6\u7684\u8fd9\u5957\u865a\u62df\u5b9a\u4e49&#xff0c;39.5 \u8282\u4e2d\u8fdb\u7a0b\u65b0\u5141\u8bb8\u6743\u80fd\u96c6\u4e0e\u6709\u6548\u6743\u80fd\u96c6\u7684\u8ba1\u7b97\u53ef\u7b80\u5316\u4e3a&#xff1a;<\/p>\n<p>P&#039;(permitted) &#061; P (inheritable) | cap_bset<br \/>\nP&#039;(effective) &#061; P&#039;(permitted)<\/p>\n<h3>39.6 Effect on Process Capabilities of Changing User IDs<\/h3>\n<p>\u4e3a\u4fdd\u6301\u7528\u6237 ID \u5728 0 \u4e0e\u975e 0 \u4e4b\u95f4\u5207\u6362\u65f6\u4e0e\u4f20\u7edf\u884c\u4e3a\u517c\u5bb9&#xff0c;\u5185\u6838\u5728\u4fee\u6539\u8fdb\u7a0b\u7528\u6237 ID&#xff08;\u901a\u8fc7setuid()\u7b49\u7cfb\u7edf\u8c03\u7528&#xff09;\u65f6\u6267\u884c\u5982\u4e0b\u903b\u8f91&#xff1a;<\/p>\n<li>\u82e5\u771f\u5b9e\u7528\u6237 ID\u3001\u6709\u6548\u7528\u6237 ID \u6216\u4fdd\u5b58\u7684\u8bbe\u7f6e\u7528\u6237 ID\u4e4b\u524d\u4e3a 0&#xff0c;\u5e76\u4e14\u7ecf\u8fc7\u672c\u6b21\u7528\u6237 ID \u4fee\u6539\u540e&#xff0c;\u8fd9\u4e09\u8005\u5168\u90e8\u53d8\u4e3a\u975e 0 \u503c&#xff0c;\u5219\u6e05\u7a7a\u5141\u8bb8\u6743\u80fd\u96c6\u4e0e\u6709\u6548\u6743\u80fd\u96c6&#xff08;\u5373\u6c38\u4e45\u4e22\u5f03\u6240\u6709\u6743\u80fd&#xff09;\u3002<\/li>\n<li>\u82e5\u6709\u6548\u7528\u6237 ID \u4ece 0 \u4fee\u6539\u4e3a\u975e 0 \u503c&#xff0c;\u5219\u6e05\u7a7a\u6709\u6548\u6743\u80fd\u96c6&#xff08;\u5373\u5173\u95ed\u6709\u6548\u6743\u80fd&#xff0c;\u4f46\u5141\u8bb8\u96c6\u4e2d\u7684\u6743\u80fd\u4ecd\u53ef\u91cd\u65b0\u542f\u7528&#xff09;\u3002<\/li>\n<li>\u82e5\u6709\u6548\u7528\u6237 ID \u4ece\u975e 0 \u503c\u4fee\u6539\u4e3a 0&#xff0c;\u5219\u5c06\u5141\u8bb8\u6743\u80fd\u96c6\u539f\u6837\u590d\u5236\u5230\u6709\u6548\u6743\u80fd\u96c6&#xff08;\u5373\u6240\u6709\u5141\u8bb8\u6743\u80fd\u5168\u90e8\u53d8\u4e3a\u751f\u6548\u72b6\u6001&#xff09;\u3002<\/li>\n<li>\u5982\u679c\u6587\u4ef6\u7cfb\u7edf\u7528\u6237 ID \u4ece 0 \u4fee\u6539\u4e3a\u975e 0 \u503c&#xff0c;\u5219\u4f1a\u4ece\u6709\u6548\u6743\u80fd\u96c6\u4e2d\u6e05\u9664\u4ee5\u4e0b\u548c\u6587\u4ef6\u64cd\u4f5c\u76f8\u5173\u7684\u6743\u80fd&#xff1a;CAP_CHOWN\u3001CAP_DAC_OVERRIDE\u3001CAP_DAC_READ_SEARCH\u3001CAP_FOWNER\u3001CAP_FSETID\u3001CAP_LINUX_IMMUTABLE&#xff08;Linux 2.6.30 \u8d77&#xff09;\u3001CAP_MAC_OVERRIDE\u4ee5\u53caCAP_MKNOD&#xff08;Linux 2.6.30 \u8d77&#xff09;\u3002 \u4e0e\u4e4b\u76f8\u53cd&#xff0c;\u5982\u679c\u6587\u4ef6\u7cfb\u7edf\u7528\u6237 ID \u4ece\u975e 0 \u503c\u4fee\u6539\u4e3a 0&#xff0c;\u90a3\u4e48\u5141\u8bb8\u96c6\u4e2d\u5df2\u542f\u7528\u7684\u4e0a\u8ff0\u6743\u80fd&#xff0c;\u4f1a\u5728\u6709\u6548\u96c6\u4e2d\u4e00\u5e76\u542f\u7528\u3002\u8fdb\u884c\u8fd9\u4e9b\u64cd\u4f5c&#xff0c;\u662f\u4e3a\u4e86\u7ef4\u6301 Linux \u7279\u6709\u7684\u6587\u4ef6\u7cfb\u7edf\u7528\u6237 ID \u5728\u6743\u9650\u53d8\u66f4\u65f6\u7684\u4f20\u7edf\u8bed\u4e49\u3002<\/li>\n<h3>39.7 Changing Process Capabilities Programmatically<\/h3>\n<p>\u8fdb\u7a0b\u53ef\u901a\u8fc7capset()\u7cfb\u7edf\u8c03\u7528&#xff0c;\u6216\u8005\u66f4\u63a8\u8350\u4f7f\u7528\u4e0b\u6587\u4ecb\u7ecd\u7684 libcap API&#xff0c;\u6765\u542f\u7528\u6216\u79fb\u9664\u81ea\u8eab\u6743\u80fd\u96c6\u4e2d\u7684\u6743\u80fd\u3002\u4fee\u6539\u8fdb\u7a0b\u6743\u80fd\u9700\u8981\u9075\u5b88\u5982\u4e0b\u89c4\u5219&#xff1a;<\/p>\n<li>\u82e5\u8fdb\u7a0b\u7684\u6709\u6548\u6743\u80fd\u96c6\u4e2d\u4e0d\u5177\u5907CAP_SETPCAP\u6743\u80fd&#xff0c;\u5219\u65b0\u7684\u53ef\u7ee7\u627f\u96c6\u5fc5\u987b\u662f\u539f\u6709\u53ef\u7ee7\u627f\u96c6\u4e0e\u5141\u8bb8\u96c6\u7684\u5e76\u96c6\u7684\u5b50\u96c6\u3002<\/li>\n<li>\u65b0\u7684\u53ef\u7ee7\u627f\u96c6\u5fc5\u987b\u662f\u539f\u6709\u53ef\u7ee7\u627f\u96c6\u4e0e\u6743\u80fd\u8fb9\u754c\u96c6\u7684\u5e76\u96c6\u7684\u5b50\u96c6\u3002<\/li>\n<li>\u65b0\u7684\u5141\u8bb8\u96c6\u5fc5\u987b\u662f\u539f\u6709\u5141\u8bb8\u96c6\u7684\u5b50\u96c6\u3002\u6362\u8a00\u4e4b&#xff0c;\u8fdb\u7a0b\u4e0d\u80fd\u81ea\u884c\u8d4b\u4e88\u81ea\u8eab\u539f\u672c\u4e0d\u5b58\u5728\u7684\u5141\u8bb8\u6743\u80fd\u3002\u6362\u53e5\u8bdd\u8bf4&#xff0c;\u4e00\u65e6\u67d0\u9879\u6743\u80fd\u4ece\u5141\u8bb8\u96c6\u4e2d\u79fb\u9664&#xff0c;\u5c31\u65e0\u6cd5\u518d\u6b21\u83b7\u53d6\u3002<\/li>\n<li>\u65b0\u7684\u6709\u6548\u96c6\u4ec5\u80fd\u5305\u542b\u540c\u65f6\u5b58\u5728\u4e8e\u65b0\u5141\u8bb8\u96c6\u4e2d\u7684\u6743\u80fd\u3002<\/li>\n<p>The libcap API \u5230\u8fd9\u91cc\u4e3a\u6b62&#xff0c;\u6211\u4eec\u523b\u610f\u6ca1\u6709\u7ed9\u51facapset()\u7cfb\u7edf\u8c03\u7528&#xff0c;\u4ee5\u53ca\u7528\u4e8e\u83b7\u53d6\u8fdb\u7a0b\u6743\u80fd\u7684\u914d\u5957\u8c03\u7528capget()\u7684\u51fd\u6570\u539f\u578b\u3002\u539f\u56e0\u662f\u5e94\u5f53\u5c3d\u91cf\u907f\u514d\u76f4\u63a5\u4f7f\u7528\u8fd9\u4e24\u4e2a\u539f\u59cb\u7cfb\u7edf\u8c03\u7528&#xff0c;\u800c\u6539\u7528 libcap \u5e93\u63d0\u4f9b\u7684\u51fd\u6570\u3002\u8fd9\u4e9b\u5e93\u51fd\u6570\u63d0\u4f9b\u4e86\u4e00\u5957\u63a5\u53e3&#xff0c;\u517c\u5bb9\u5df2\u64a4\u56de\u7684 POSIX 1003.1e \u8349\u6848\u6807\u51c6&#xff0c;\u5e76\u9644\u5e26\u90e8\u5206 Linux \u6269\u5c55\u3002<\/p>\n<p>\u53d7\u7bc7\u5e45\u9650\u5236&#xff0c;\u6211\u4eec\u4e0d\u8be6\u7ec6\u63cf\u8ff0 libcap API\u3002\u4f5c\u4e3a\u6982\u89c8&#xff0c;\u4f7f\u7528\u8fd9\u5957\u5e93\u51fd\u6570\u7684\u7a0b\u5e8f\u4e00\u822c\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4&#xff1a;<\/p>\n<li>\u8c03\u7528cap_get_proc()&#xff0c;\u4ece\u5185\u6838\u8bfb\u53d6\u8fdb\u7a0b\u5f53\u524d\u6743\u80fd\u96c6\u7684\u526f\u672c&#xff0c;\u5b58\u5165\u8be5\u51fd\u6570\u5728\u7528\u6237\u7a7a\u95f4\u5206\u914d\u7684\u7ed3\u6784\u4f53\u3002&#xff08;\u4e5f\u53ef\u4ee5\u8c03\u7528cap_init()\u521b\u5efa\u5168\u65b0\u7684\u7a7a\u6743\u80fd\u96c6\u7ed3\u6784\u4f53\u3002&#xff09;\u5728 libcap API \u4e2d&#xff0c;cap_t\u662f\u6307\u5411\u8fd9\u7c7b\u7ed3\u6784\u4f53\u7684\u6307\u9488\u7c7b\u578b\u3002<\/li>\n<li>\u8c03\u7528cap_set_flag()&#xff0c;\u66f4\u65b0\u7528\u6237\u7a7a\u95f4\u7ed3\u6784\u4f53&#xff0c;\u5bf9\u524d\u4e00\u6b65\u62ff\u5230\u7684\u5141\u8bb8\u3001\u6709\u6548\u3001\u53ef\u7ee7\u627f\u6743\u80fd\u96c6\u6267\u884c\u542f\u7528&#xff08;CAP_SET&#xff09;\u4e0e\u6e05\u9664&#xff08;CAP_CLEAR&#xff09;\u64cd\u4f5c\u3002<\/li>\n<li>\u8c03\u7528cap_set_proc()\u51fd\u6570&#xff0c;\u5c06\u7528\u6237\u7a7a\u95f4\u7ed3\u6784\u4f53\u4f20\u56de\u5185\u6838&#xff0c;\u4ee5\u6b64\u4fee\u6539\u8fdb\u7a0b\u7684\u6743\u80fd\u3002<\/li>\n<li>\u8c03\u7528cap_free()\u51fd\u6570&#xff0c;\u91ca\u653e\u7b2c\u4e00\u6b65\u4e2d\u7531 libcap API \u5206\u914d\u7684\u7ed3\u6784\u4f53\u3002<\/li>\n<p>\u64b0\u5199\u672c\u4e66\u65f6&#xff0c;\u65b0\u7248\u6539\u8fdb\u578b\u6743\u80fd\u5e93 API libcap-ng\u4ecd\u5728\u5f00\u53d1\u4e2d&#xff0c;\u8be6\u60c5\u53ef\u53c2\u89c1 https:\/\/github.com\/stevegrubb\/libcap-ng\u3002<\/p>\n<p>&#x1f4a1; 2.6.24\u4e4b\u540e\u7684linux\u90fd\u652f\u6301libcap-ng&#xff1a;<\/p>\n<p>$ ldconfig <span class=\"token parameter variable\">-p<\/span> <span class=\"token operator\">|<\/span> <span class=\"token function\">grep<\/span> libcap-ng<br \/>\n        libcap-ng.so.0 <span class=\"token punctuation\">(<\/span>libc6,x86-64<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;<\/span><span class=\"token operator\">&gt;<\/span> \/lib64\/libcap-ng.so.0<\/p>\n<p>Example program \u672c\u4e66 164 \u9875\u7684\u6e05\u5355 8-2\u4e2d&#xff0c;\u6211\u4eec\u7ed9\u51fa\u8fc7\u4e00\u4e2a\u7a0b\u5e8f&#xff0c;\u8be5\u7a0b\u5e8f\u4f9d\u636e\u6807\u51c6\u5bc6\u7801\u6570\u636e\u5e93\u6821\u9a8c\u7528\u6237\u540d\u4e0e\u5bc6\u7801\u3002\u5f53\u65f6\u6211\u4eec\u63d0\u5230&#xff0c;\u8bfb\u53d6\u5f71\u5b50\u5bc6\u7801\u6587\u4ef6\u9700\u8981\u7279\u6743&#xff1b;\u8be5\u6587\u4ef6\u53d7\u4fdd\u62a4&#xff0c;\u4ec5\u5141\u8bb8 root \u7528\u6237\u6216 shadow \u7528\u6237\u7ec4\u7684\u6210\u5458\u8bfb\u53d6\u3002\u4f20\u7edf\u65b9\u6848\u8981\u7ed9\u8fd9\u4e2a\u7a0b\u5e8f\u8d4b\u4e88\u6240\u9700\u6743\u9650&#xff0c;\u8981\u4e48\u4ee5 root \u8d26\u53f7\u8fd0\u884c&#xff0c;\u8981\u4e48\u5c06\u5176\u8bbe\u7f6e\u4e3a set-user-ID-root \u7a0b\u5e8f\u3002\u4e0b\u9762\u6211\u4eec\u7ed9\u51fa\u8be5\u7a0b\u5e8f\u7684\u4fee\u6539\u7248\u672c&#xff0c;\u4f7f\u7528\u6743\u80fd\u673a\u5236\u4e0e libcap API \u5b9e\u73b0\u3002<\/p>\n<p>\u666e\u901a\u7528\u6237\u60f3\u8981\u8bfb\u53d6\u5f71\u5b50\u5bc6\u7801\u6587\u4ef6&#xff0c;\u9700\u8981\u7ed5\u8fc7\u6807\u51c6\u6587\u4ef6\u6743\u9650\u68c0\u67e5\u3002\u67e5\u9605\u8868 39-1 \u6240\u5217\u6743\u80fd&#xff0c;\u53ef\u4ee5\u627e\u5230\u9002\u7528\u6743\u80fd&#xff1a;CAP_DAC_READ_SEARCH\u3002\u8fd9\u4efd\u4fee\u6539\u540e\u7684\u5bc6\u7801\u8ba4\u8bc1\u7a0b\u5e8f\u89c1\u6e05\u5355 39-1\u3002\u8be5\u7a0b\u5e8f\u5229\u7528 libcap API&#xff0c;\u5728\u8bbf\u95ee\u5f71\u5b50\u5bc6\u7801\u6587\u4ef6\u4e4b\u524d&#xff0c;\u5728\u6709\u6548\u6743\u80fd\u96c6\u4e2d\u542f\u7528CAP_DAC_READ_SEARCH&#xff1b;\u8bbf\u95ee\u5b8c\u6210\u540e\u7acb\u523b\u79fb\u9664\u8fd9\u9879\u6743\u80fd\u3002\u8981\u8ba9\u975e\u7279\u6743\u7528\u6237\u53ef\u4ee5\u8fd0\u884c\u6b64\u7a0b\u5e8f&#xff0c;\u5fc5\u987b\u5728\u6587\u4ef6\u7684\u5141\u8bb8\u6743\u80fd\u96c6\u4e2d\u914d\u7f6e\u8be5\u9879\u6743\u80fd&#xff0c;\u5982\u4e0b\u4f8b shell \u4f1a\u8bdd\u6240\u793a&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u6b64\u65f6check_password_caps\u4e3a\u7eff\u8272&#xff0c;\u8868\u793a\u5176\u4e3a\u53ef\u6267\u884c\u6587\u4ef6<\/span><br \/>\n$ <span class=\"token function\">ls<\/span> <span class=\"token parameter variable\">-l<\/span> check_password_caps<br \/>\n-rwxr-xr-x. <span class=\"token number\">1<\/span> vagrant vagrant <span class=\"token number\">33792<\/span> Mar <span class=\"token number\">31<\/span> 07:26 check_password_caps<br \/>\n$ <span class=\"token function\">sudo<\/span> setcap <span class=\"token string\">&#034;cap_dac_read_search&#061;p&#034;<\/span> check_password_caps<br \/>\n<span class=\"token comment\"># \u6b64\u65f6check_password_caps\u4e3a\u7ea2\u5e95\u9ed1\u5b57&#xff0c;\u8868\u793a\u5176\u542f\u7528\u4e86\u6587\u4ef6\u6743\u80fd<\/span><br \/>\n$ <span class=\"token function\">ls<\/span> <span class=\"token parameter variable\">-l<\/span> check_password_caps<br \/>\n-rwxr-xr-x. <span class=\"token number\">1<\/span> vagrant vagrant <span class=\"token number\">33792<\/span> Mar <span class=\"token number\">31<\/span> 07:26 check_password_caps<br \/>\n$ getcap check_password_caps<br \/>\ncheck_password_caps <span class=\"token assign-left variable\">cap_dac_read_search<\/span><span class=\"token operator\">&#061;<\/span>p<br \/>\n$ .\/check_password_caps<br \/>\nUsername: vagrant<br \/>\nPassword:<br \/>\nSuccessfully authenticated: <span class=\"token assign-left variable\"><span class=\"token environment constant\">UID<\/span><\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">1000<\/span><\/p>\n<p>Listing 39-1: A capability-aware program that authenticates a user<\/p>\n<p><span class=\"token comment\">\/\/ cap\/check_password_caps.c<\/span><br \/>\n\u7565\u3002<\/p>\n<h3>39.8 Creating Capabilities-Only Environments<\/h3>\n<p>\u5728\u524d\u8ff0\u7ae0\u8282\u4e2d&#xff0c;\u6211\u4eec\u4ecb\u7ecd\u4e86**\u7528\u6237 ID \u4e3a 0&#xff08;root&#xff09;\u7684\u8fdb\u7a0b\u5728\u6743\u80fd&#xff08;capabilities&#xff09;**\u65b9\u9762\u53d7\u5230\u7279\u6b8a\u5904\u7406\u7684\u591a\u79cd\u60c5\u5f62&#xff1a;<\/p>\n<ul>\n<li>\u82e5\u4e00\u4e2a\u8fdb\u7a0b\u5b58\u5728\u81f3\u5c11\u4e00\u4e2a\u7b49\u4e8e 0 \u7684\u7528\u6237 ID&#xff0c;\u5f53\u5b83\u5c06\u81ea\u8eab\u6240\u6709\u7528\u6237 ID \u5168\u90e8\u8bbe\u7f6e\u4e3a\u975e 0 \u503c\u65f6&#xff0c;\u8be5\u8fdb\u7a0b\u7684**\u8bb8\u53ef\u6743\u80fd\u96c6&#xff08;permitted capability set&#xff09;\u4e0e\u6709\u6548\u6743\u80fd\u96c6&#xff08;effective capability set&#xff09;**\u4f1a\u88ab\u6e05\u7a7a\u3002&#xff08;\u53c2\u89c1 39.6 \u8282&#xff09;<\/li>\n<li>\u82e5\u8fdb\u7a0b\u7684**\u6709\u6548\u7528\u6237 ID&#xff08;effective user ID&#xff09;\u4e3a 0&#xff0c;\u5f53\u8be5 ID \u4fee\u6539\u4e3a\u975e 0 \u503c\u65f6&#xff0c;\u8fdb\u7a0b\u4f1a\u4e22\u5931\u5176\u6709\u6548\u6743\u80fd\u3002\u53cd\u4e4b&#xff0c;\u82e5\u5c06\u6709\u6548\u7528\u6237 ID \u6539\u56de 0&#xff0c;\u5219\u4f1a\u628a\u8bb8\u53ef\u6743\u80fd\u96c6\u590d\u5236\u5230\u6709\u6548\u6743\u80fd\u96c6\u3002\u5f53\u8fdb\u7a0b\u7684\u6587\u4ef6\u7cfb\u7edf\u7528\u6237 ID&#xff08;file-system user ID&#xff09;**\u5728 0 \u4e0e\u975e 0 \u503c\u4e4b\u95f4\u5207\u6362\u65f6&#xff0c;\u9488\u5bf9\u4e00\u90e8\u5206\u6743\u80fd\u4e5f\u4f1a\u6267\u884c\u7c7b\u4f3c\u903b\u8f91\u3002&#xff08;\u53c2\u89c1 39.6 \u8282&#xff09;<\/li>\n<li>\u5982\u679c\u771f\u5b9e\u7528\u6237 ID\u6216\u6709\u6548\u7528\u6237 ID\u4e3a root \u7684\u8fdb\u7a0b\u6267\u884c\u65b0\u7a0b\u5e8f&#xff0c;\u6216\u662f\u4efb\u610f\u8fdb\u7a0b\u6267\u884c\u8bbe\u7f6e\u7528\u6237 ID \u4e3a root&#xff08;set-user-ID-root&#xff09;\u7684\u7a0b\u5e8f&#xff0c;\u5219\u6587\u4ef6\u53ef\u7ee7\u627f\u6743\u80fd\u96c6\u4e0e\u6587\u4ef6\u8bb8\u53ef\u6743\u80fd\u96c6\u5728\u6982\u5ff5\u4e0a\u88ab\u5b9a\u4e49\u4e3a\u5168 1\u3002\u82e5\u8fdb\u7a0b\u7684\u6709\u6548\u7528\u6237 ID \u4e3a 0&#xff0c;\u6216\u662f\u6b63\u5728\u6267\u884c set-user-ID-root \u7a0b\u5e8f&#xff0c;\u5219\u6587\u4ef6\u6709\u6548\u4f4d\u5728\u6982\u5ff5\u4e0a\u88ab\u5b9a\u4e49\u4e3a 1\u3002&#xff08;\u53c2\u89c1 39.5.2 \u8282&#xff09;\u5728\u5e38\u89c4\u573a\u666f\u4e0b&#xff08;\u5373\u771f\u5b9e\u7528\u6237 ID \u4e0e\u6709\u6548\u7528\u6237 ID \u5747\u4e3a root&#xff0c;\u6216\u662f\u6b63\u5728\u6267\u884c set-user-ID-root \u7a0b\u5e8f&#xff09;&#xff0c;\u8fd9\u610f\u5473\u7740\u8be5\u8fdb\u7a0b\u7684\u8bb8\u53ef\u6743\u80fd\u96c6\u4e0e\u6709\u6548\u6743\u80fd\u96c6\u5c06\u83b7\u5f97\u5168\u90e8\u6743\u80fd\u3002<\/li>\n<\/ul>\n<p>\u5728\u4e00\u5957\u5b8c\u5168\u57fa\u4e8e\u6743\u80fd\u7684\u7cfb\u7edf\u4e2d&#xff0c;\u5185\u6838\u65e0\u9700\u9488\u5bf9 root \u6267\u884c\u4e0a\u8ff0\u4efb\u4f55\u7279\u6b8a\u5904\u7406\u3002\u7cfb\u7edf\u4e2d\u5c06\u4e0d\u518d\u5b58\u5728 set-user-ID-root \u7a0b\u5e8f&#xff0c;\u800c\u662f\u901a\u8fc7\u6587\u4ef6\u6743\u80fd&#xff0c;\u4ec5\u6388\u4e88\u7a0b\u5e8f\u8fd0\u884c\u6240\u9700\u7684\u6700\u5c0f\u6743\u80fd\u3002<\/p>\n<p>\u7531\u4e8e\u73b0\u6709\u5e94\u7528\u7a0b\u5e8f\u5728\u8bbe\u8ba1\u65f6\u5e76\u672a\u8003\u8651\u4f7f\u7528\u6587\u4ef6\u6743\u80fd\u8fd9\u5957\u5e95\u5c42\u673a\u5236&#xff0c;\u5185\u6838\u5fc5\u987b\u4fdd\u7559\u5bf9\u7528\u6237 ID \u4e3a 0 \u7684\u8fdb\u7a0b\u7684\u4f20\u7edf\u5904\u7406\u903b\u8f91\u3002\u5c3d\u7ba1\u5982\u6b64&#xff0c;\u6211\u4eec\u6709\u65f6\u4ecd\u5e0c\u671b\u5e94\u7528\u8fd0\u884c\u5728\u7eaf\u57fa\u4e8e\u6743\u80fd\u7684\u73af\u5883\u4e2d&#xff1a;\u5728\u8be5\u73af\u5883\u4e0b&#xff0c;root \u4e0d\u518d\u4eab\u6709\u4e0a\u6587\u6240\u8ff0\u7684\u4efb\u4f55\u7279\u6b8a\u7279\u6743\u3002\u81ea\u5185\u6838 2.6.26 \u7248\u672c\u8d77&#xff0c;\u82e5\u5185\u6838\u5f00\u542f\u6587\u4ef6\u6743\u80fd\u652f\u6301&#xff0c;Linux \u63d0\u4f9b\u4e86\u5b89\u5168\u4f4d&#xff08;securebits&#xff09;\u673a\u5236\u3002\u8be5\u673a\u5236\u7ba1\u7406\u4e00\u7ec4\u6309\u8fdb\u7a0b\u8bbe\u7f6e\u7684\u6807\u5fd7\u4f4d&#xff0c;\u7528\u6765\u542f\u7528\u6216\u7981\u7528\u9488\u5bf9 root \u7684\u4e09\u9879\u7279\u6b8a\u5904\u7406\u89c4\u5219\u3002&#xff08;\u4e25\u683c\u6765\u8bf4&#xff0c;securebits \u6807\u5fd7\u5b9e\u9645\u4e0a\u662f\u6309\u7ebf\u7a0b\u7684\u5c5e\u6027\u3002&#xff09;<\/p>\n<p>securebits \u673a\u5236\u7ba1\u63a7\u7684\u6807\u5fd7\u4f4d\u5982\u8868 39-2 \u6240\u793a\u3002\u8fd9\u4e9b\u6807\u5fd7\u6210\u5bf9\u5b58\u5728&#xff1a;\u57fa\u7840\u6807\u5fd7\u4ee5\u53ca\u5bf9\u5e94\u7684\u9501\u5b9a\u6807\u5fd7\u3002\u6bcf\u4e2a\u57fa\u7840\u6807\u5fd7\u63a7\u5236\u4e0a\u8ff0 root \u7279\u6b8a\u5904\u7406\u89c4\u5219\u4e2d\u7684\u4e00\u9879\u3002\u8bbe\u7f6e\u5bf9\u5e94\u7684\u9501\u5b9a\u6807\u5fd7\u5c5e\u4e8e\u4e00\u6b21\u6027\u64cd\u4f5c&#xff0c;\u5b83\u4f1a\u963b\u6b62\u540e\u7eed\u4fee\u6539\u5173\u8054\u7684\u57fa\u7840\u6807\u5fd7 \u2014\u2014 \u9501\u5b9a\u6807\u5fd7\u4e00\u65e6\u7f6e\u4f4d&#xff0c;\u4fbf\u65e0\u6cd5\u6e05\u9664\u3002<\/p>\n<p>Table 39-2: The securebits flags<\/p>\n<table>\n<tr>\u6807\u5fd7\u4f4d\u7f6e\u4f4d\u540e\u7684\u542b\u4e49<\/tr>\n<tbody>\n<tr>\n<td align=\"left\">SECBIT_KEEP_CAPS<\/td>\n<td align=\"left\">\u5f53\u8fdb\u7a0b\u5b58\u5728\u4e00\u4e2a\u6216\u591a\u4e2a\u503c\u4e3a0\u7684\u7528\u6237ID&#xff0c;\u968f\u540e\u5c06\u5176\u6240\u6709\u7528\u6237ID\u8bbe\u7f6e\u4e3a\u975e0\u503c\u65f6&#xff0c;\u4e0d\u6e05\u7a7a\u8bb8\u53ef\u6743\u80fd\u96c6\u3002\u8be5\u6807\u5fd7\u4ec5\u5728\u672a\u540c\u65f6\u8bbe\u7f6e SECBIT_NO_SETUID_FIXUP \u65f6\u751f\u6548\u3002\u5728\u8c03\u7528 exec() \u65f6\u6b64\u6807\u5fd7\u4f1a\u88ab\u6e05\u9664\u3002<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">SECBIT_NO_SETUID_FIXUP<\/td>\n<td align=\"left\">\u5728\u6709\u6548\u7528\u6237ID\u6216\u6587\u4ef6\u7cfb\u7edf\u7528\u6237ID\u4e8e0\u4e0e\u975e0\u503c\u4e4b\u95f4\u5207\u6362\u65f6&#xff0c;\u4e0d\u4fee\u6539\u6743\u80fd\u3002<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">SECBIT_NOROOT<\/td>\n<td align=\"left\">\u82e5\u771f\u5b9e\u7528\u6237ID\u6216\u6709\u6548\u7528\u6237ID\u4e3a0\u7684\u8fdb\u7a0b\u6267\u884c exec()&#xff0c;\u6216\u662f\u6267\u884c set-user-ID-root \u7a0b\u5e8f&#xff0c;\u4e0d\u81ea\u52a8\u8d4b\u4e88\u6743\u80fd&#xff08;\u9664\u975e\u8be5\u53ef\u6267\u884c\u6587\u4ef6\u672c\u8eab\u5e26\u6709\u6587\u4ef6\u6743\u80fd&#xff09;\u3002<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">SECBIT_KEEP_CAPS_LOCKED<\/td>\n<td align=\"left\">\u9501\u5b9a SECBIT_KEEP_CAPS \u6807\u5fd7\u3002<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">SECBIT_NO_SETUID_FIXUP_LOCKED<\/td>\n<td align=\"left\">\u9501\u5b9a SECBIT_NO_SETUID_FIXUP \u6807\u5fd7\u3002<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">SECBIT_NOROOT_LOCKED<\/td>\n<td align=\"left\">\u9501\u5b9a SECBIT_NOROOT \u6807\u5fd7\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7531fork()\u521b\u5efa\u7684\u5b50\u8fdb\u7a0b\u4f1a\u7ee7\u627f securebits \u6807\u5fd7\u7684\u8bbe\u7f6e\u3002\u6267\u884cexec()\u671f\u95f4&#xff0c;\u7edd\u5927\u591a\u6570\u6807\u5fd7\u914d\u7f6e\u90fd\u4f1a\u4fdd\u7559&#xff0c;\u4f46SECBIT_KEEP_CAPS\u4f8b\u5916&#xff1a;\u4e3a\u4e86\u517c\u5bb9\u4e0b\u6587\u6240\u8ff0PR_SET_KEEPCAPS\u7684\u5386\u53f2\u673a\u5236&#xff0c;\u8be5\u6807\u5fd7\u4f1a\u88ab\u6e05\u9664\u3002<\/p>\n<p>\u8fdb\u7a0b\u53ef\u901a\u8fc7prctl()\u7684PR_GET_SECUREBITS\u64cd\u4f5c\u8bfb\u53d6 securebits \u6807\u5fd7\u3002 \u82e5\u8fdb\u7a0b\u62e5\u6709CAP_SETPCAP\u6743\u80fd&#xff0c;\u5219\u53ef\u4ee5\u901a\u8fc7prctl()\u7684PR_SET_SECUREBITS\u64cd\u4f5c\u4fee\u6539 securebits \u6807\u5fd7\u3002 \u7eaf\u57fa\u4e8e\u6743\u80fd\u7684\u5e94\u7528\u7a0b\u5e8f&#xff0c;\u53ef\u901a\u8fc7\u5982\u4e0b\u8c03\u7528&#xff0c;\u4e0d\u53ef\u9006\u5730\u5173\u95ed\u8c03\u7528\u8fdb\u7a0b\u53ca\u5176\u6240\u6709\u540e\u4ee3\u8fdb\u7a0b\u4e2d root \u7684\u7279\u6b8a\u5904\u7406\u903b\u8f91&#xff1a;<\/p>\n<p><span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">prctl<\/span><span class=\"token punctuation\">(<\/span>PR_SET_SECUREBITS<span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token comment\">\/* SECBIT_KEEP_CAPS off *\/<\/span><br \/>\nSECBIT_NO_SETUID_FIXUP <span class=\"token operator\">|<\/span> SECBIT_NO_SETUID_FIXUP_LOCKED <span class=\"token operator\">|<\/span><br \/>\nSECBIT_NOROOT <span class=\"token operator\">|<\/span> SECBIT_NOROOT_LOCKED<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token function\">errExit<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;prctl&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u6267\u884c\u8be5\u8c03\u7528\u4e4b\u540e&#xff0c;\u6b64\u8fdb\u7a0b\u53ca\u5176\u540e\u4ee3\u8fdb\u7a0b\u83b7\u53d6\u6743\u80fd\u7684\u552f\u4e00\u9014\u5f84&#xff0c;\u5c31\u662f\u8fd0\u884c\u5e26\u6709\u6587\u4ef6\u6743\u80fd\u7684\u53ef\u6267\u884c\u7a0b\u5e8f\u3002<\/p>\n<p>SECBIT_KEEP_CAPS and the prctl() PR_SET_KEEPCAPS operation SECBIT_KEEP_CAPS \u6807\u5fd7\u7684\u4f5c\u7528&#xff1a;\u5f53\u8fdb\u7a0b\u5b58\u5728\u4e00\u4e2a\u6216\u591a\u4e2a\u503c\u4e3a 0 \u7684\u7528\u6237 ID&#xff0c;\u968f\u540e\u5c06\u5168\u90e8\u7528\u6237 ID \u4fee\u6539\u4e3a\u975e 0 \u503c\u65f6&#xff0c;\u963b\u6b62\u5185\u6838\u6e05\u7a7a\u8fdb\u7a0b\u7684\u6743\u80fd\u3002<\/p>\n<p>\u7c97\u7565\u6765\u8bf4&#xff0c;SECBIT_KEEP_CAPS \u53ea\u63d0\u4f9b\u4e86 SECBIT_NO_SETUID_FIXUP \u4e00\u534a\u7684\u529f\u80fd\u3002&#xff08;\u5982\u8868 39-2 \u6240\u8ff0&#xff0c;\u4ec5\u5f53\u672a\u8bbe\u7f6e SECBIT_NO_SETUID_FIXUP \u65f6&#xff0c;SECBIT_KEEP_CAPS \u624d\u4f1a\u751f\u6548\u3002&#xff09;\u5f15\u5165\u8be5\u6807\u5fd7&#xff0c;\u662f\u4e3a\u4e86\u5728 securebits \u4e2d\u63d0\u4f9b\u4e00\u4e2a\u548c\u65e7\u7248 prctl () \u7684 PR_SET_KEEPCAPS \u64cd\u4f5c\u529f\u80fd\u5bf9\u7b49\u7684\u6807\u5fd7&#xff0c;\u4e8c\u8005\u63a7\u5236\u540c\u4e00\u5c5e\u6027\u3002 &#xff08;\u4e24\u79cd\u673a\u5236\u6709\u4e00\u5904\u5dee\u522b&#xff1a;\u8fdb\u7a0b\u8c03\u7528 prctl () \u7684 PR_SET_KEEPCAPS \u64cd\u4f5c\u65f6&#xff0c;\u4e0d\u9700\u8981\u62e5\u6709 CAP_SETPCAP \u6743\u80fd\u3002&#xff09;<\/p>\n<p>\u524d\u6587\u63d0\u5230\u8fc7&#xff1a;exec () \u6267\u884c\u65f6&#xff0c;\u9664 SECBIT_KEEP_CAPS \u4ee5\u5916&#xff0c;\u5176\u4f59\u6240\u6709 securebits \u6807\u5fd7\u90fd\u4f1a\u4fdd\u7559\u3002SECBIT_KEEP_CAPS \u7684\u5904\u7406\u903b\u8f91\u548c\u5176\u4ed6 securebits \u6807\u5fd7\u76f8\u53cd&#xff0c;\u76ee\u7684\u662f\u548c prctl () \u7684 PR_SET_KEEPCAPS \u6240\u8bbe\u7f6e\u5c5e\u6027\u7684\u884c\u4e3a\u4fdd\u6301\u4e00\u81f4\u3002<\/p>\n<p>prctl () \u7684 PR_SET_KEEPCAPS \u64cd\u4f5c&#xff0c;\u662f\u4e3a\u90a3\u4e9b\u8fd0\u884c\u5728\u4e0d\u652f\u6301\u6587\u4ef6\u6743\u80fd\u7684\u65e7\u5185\u6838\u4e0a\u7684 set-user-ID-root \u7a0b\u5e8f\u8bbe\u8ba1\u7684\u3002\u8fd9\u7c7b\u7a0b\u5e8f\u4f9d\u65e7\u53ef\u4ee5\u6309\u9700\u901a\u8fc7\u4ee3\u7801\u4e3b\u52a8\u4e22\u5f03\u3001\u91cd\u65b0\u542f\u7528\u6743\u80fd&#xff0c;\u4ee5\u6b64\u63d0\u5347\u5b89\u5168\u6027&#xff08;\u53c2\u89c1 39.10 \u8282&#xff09;\u3002<\/p>\n<p>\u7136\u800c&#xff0c;\u5373\u4fbf\u8fd9\u7c7b set-user-ID-root \u7a0b\u5e8f\u4e22\u5f03\u4e86\u9664\u81ea\u8eab\u6240\u9700\u4e4b\u5916\u7684\u5168\u90e8\u6743\u80fd&#xff0c;\u5b83\u4ecd\u7136\u4fdd\u6709\u4e24\u9879\u91cd\u8981\u7279\u6743&#xff1a;\u80fd\u591f\u8bbf\u95ee root \u5c5e\u4e3b\u7684\u6587\u4ef6&#xff0c;\u5e76\u4e14\u53ef\u4ee5\u901a\u8fc7\u6267\u884c\u65b0\u7a0b\u5e8f\u91cd\u65b0\u83b7\u53d6\u6743\u80fd&#xff08;\u89c1 39.5.2 \u8282&#xff09;\u3002\u60f3\u8981\u6c38\u4e45\u53bb\u9664\u8fd9\u4e9b\u7279\u6743&#xff0c;\u552f\u4e00\u529e\u6cd5\u662f\u628a\u8fdb\u7a0b\u7684\u6240\u6709\u7528\u6237 ID \u90fd\u8bbe\u7f6e\u4e3a\u975e 0 \u503c\u3002\u4f46\u901a\u5e38\u60c5\u51b5\u4e0b&#xff0c;\u6267\u884c\u8be5\u64cd\u4f5c\u4f1a\u6e05\u7a7a\u8bb8\u53ef\u6743\u80fd\u96c6\u4e0e\u6709\u6548\u6743\u80fd\u96c6&#xff08;\u53c2\u89c1 39.6 \u8282\u4e2d\u4ecb\u7ecd\u7528\u6237 ID \u53d8\u66f4\u5bf9\u6743\u80fd\u5f71\u54cd\u7684\u56db\u70b9\u5185\u5bb9&#xff09;&#xff0c;\u8fd9\u5c31\u8fdd\u80cc\u4e86\u521d\u8877&#xff1a;\u5373\u6c38\u4e45\u8131\u79bb UID 0 \u8eab\u4efd&#xff0c;\u540c\u65f6\u4fdd\u7559\u90e8\u5206\u6743\u80fd\u3002\u4e3a\u652f\u6301\u8be5\u573a\u666f&#xff0c;\u53ef\u4ee5\u4f7f\u7528 prctl () \u7684 PR_SET_KEEPCAPS \u64cd\u4f5c\u8bbe\u7f6e\u8fdb\u7a0b\u5c5e\u6027&#xff0c;\u4f7f\u5f97\u5728\u5168\u90e8\u7528\u6237 ID \u4fee\u6539\u4e3a\u975e 0 \u503c\u65f6&#xff0c;\u8bb8\u53ef\u6743\u80fd\u96c6\u4e0d\u4f1a\u88ab\u6e05\u7a7a\u3002&#xff08;\u4f46\u5728\u6b64\u573a\u666f\u4e0b&#xff0c;\u65e0\u8bba \u201c\u4fdd\u7559\u6743\u80fd\u201d \u5c5e\u6027\u5982\u4f55\u8bbe\u7f6e&#xff0c;\u8fdb\u7a0b\u7684\u6709\u6548\u6743\u80fd\u96c6\u603b\u4f1a\u88ab\u6e05\u7a7a\u3002&#xff09;<\/p>\n<h3>39.9 Discovering the Capabilities Required by a Program<\/h3>\n<p>\u5047\u8bbe\u6709\u8fd9\u6837\u4e00\u4e2a\u7a0b\u5e8f&#xff1a;\u5b83\u5e76\u4e0d\u611f\u77e5\u6743\u80fd\u673a\u5236&#xff0c;\u4e14\u4ec5\u63d0\u4f9b\u4e8c\u8fdb\u5236\u53ef\u6267\u884c\u6587\u4ef6&#xff1b;\u6216\u662f\u7a0b\u5e8f\u6e90\u7801\u4f53\u91cf\u8fc7\u5927&#xff0c;\u96be\u4ee5\u901a\u8fc7\u9605\u8bfb\u6e90\u7801\u5224\u65ad\u8fd0\u884c\u5b83\u9700\u8981\u54ea\u4e9b\u6743\u80fd\u3002\u5982\u679c\u8be5\u7a0b\u5e8f\u9700\u8981\u7279\u6743&#xff0c;\u4f46\u53c8\u4e0d\u9002\u5408\u505a\u6210 set-user-ID-root \u7a0b\u5e8f&#xff0c;\u90a3\u4e48\u6211\u4eec\u8be5\u5982\u4f55\u901a\u8fc7 setcap(8) \u786e\u5b9a\u8981\u8d4b\u4e88\u8fd9\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8bb8\u53ef\u6743\u80fd&#xff1f;\u6709\u4e24\u79cd\u89e3\u51b3\u601d\u8def&#xff1a;<\/p>\n<ul>\n<li>\u4f7f\u7528 strace(1)&#xff08;\u9644\u5f55 A&#xff09;\u89c2\u5bdf\u54ea\u4e9b\u7cfb\u7edf\u8c03\u7528\u8fd4\u56de EPERM \u9519\u8bef&#xff0c;\u8be5\u9519\u8bef\u4ee3\u8868\u7f3a\u5c11\u5fc5\u9700\u7684\u6743\u80fd\u3002\u968f\u540e\u67e5\u9605\u7cfb\u7edf\u8c03\u7528\u624b\u518c\u9875\u6216\u5185\u6838\u6e90\u7801&#xff0c;\u5c31\u80fd\u63a8\u65ad\u51fa\u6240\u9700\u6743\u80fd\u3002\u8fd9\u79cd\u65b9\u6cd5\u5e76\u4e0d\u5b8c\u7f8e&#xff1a;EPERM \u9519\u8bef\u5076\u5c14\u4e5f\u4f1a\u7531\u5176\u4ed6\u539f\u56e0\u89e6\u53d1&#xff0c;\u5176\u4e2d\u90e8\u5206\u539f\u56e0\u548c\u7a0b\u5e8f\u7684\u6743\u80fd\u9700\u6c42\u6beb\u65e0\u5173\u7cfb\u3002\u6b64\u5916&#xff0c;\u7a0b\u5e8f\u53ef\u80fd\u4f1a\u6b63\u5e38\u8c03\u7528\u9700\u8981\u7279\u6743\u7684\u7cfb\u7edf\u8c03\u7528&#xff0c;\u5728\u53d1\u73b0\u81ea\u8eab\u6ca1\u6709\u5bf9\u5e94\u64cd\u4f5c\u6743\u9650\u540e\u518d\u6539\u53d8\u6267\u884c\u903b\u8f91\u3002\u5728\u786e\u5b9a\u53ef\u6267\u884c\u6587\u4ef6\u771f\u5b9e\u6240\u9700\u6743\u80fd\u65f6&#xff0c;\u6709\u65f6\u5f88\u96be\u533a\u5206\u8fd9\u7c7b\u8bef\u62a5\u3002<\/li>\n<li>\u5728\u5185\u6838\u6267\u884c\u6743\u80fd\u6821\u9a8c\u65f6&#xff0c;\u53ef\u501f\u52a9\u5185\u6838\u63a2\u9488\u751f\u6210\u76d1\u63a7\u8f93\u51fa\u3002\u6587\u4ef6\u6743\u80fd\u7684\u5f00\u53d1\u8005\u4e4b\u4e00\u64b0\u5199\u7684\u6587\u732e [Hallyn, 2007] \u7ed9\u51fa\u4e86\u5b9e\u73b0\u793a\u4f8b\u3002\u6587\u4e2d\u7684\u63a2\u9488\u4f1a\u8bb0\u5f55\u6bcf\u4e00\u6b21\u6743\u80fd\u6821\u9a8c\u8bf7\u6c42&#xff1a;\u88ab\u8c03\u7528\u7684\u5185\u6838\u51fd\u6570\u3001\u88ab\u6821\u9a8c\u7684\u6743\u80fd&#xff0c;\u4ee5\u53ca\u53d1\u8d77\u8bf7\u6c42\u7684\u7a0b\u5e8f\u540d\u79f0\u3002\u867d\u7136\u8fd9\u79cd\u65b9\u6cd5\u76f8\u6bd4 strace (1) \u5de5\u4f5c\u91cf\u66f4\u5927&#xff0c;\u4f46\u53ef\u4ee5\u66f4\u7cbe\u51c6\u5730\u5224\u65ad\u7a0b\u5e8f\u6240\u9700\u7684\u6743\u80fd\u3002<\/li>\n<\/ul>\n<h3>39.10 Older Kernels and Systems Without File Capabilities<\/h3>\n<p>\u672c\u8282\u5c06\u4ecb\u7ecd\u65e7\u7248\u5185\u6838\u4e2d\u6743\u80fd\u673a\u5236\u5b9e\u73b0\u4e0a\u7684\u5404\u7c7b\u5dee\u5f02&#xff0c;\u540c\u65f6\u8bf4\u660e\u5728\u4e0d\u652f\u6301\u6587\u4ef6\u6743\u80fd\u7684\u5185\u6838\u4e0a\u5b58\u5728\u7684\u533a\u522b\u3002Linux \u5728\u4e24\u79cd\u573a\u666f\u4e0b\u4e0d\u652f\u6301\u6587\u4ef6\u6743\u80fd&#xff1a;<\/p>\n<ul>\n<li>Linux 2.6.24 \u7248\u672c\u4e4b\u524d&#xff0c;\u5c1a\u672a\u5b9e\u73b0\u6587\u4ef6\u6743\u80fd\u3002<\/li>\n<li>\u81ea Linux 2.6.24 \u7248\u672c\u8d77&#xff0c;\u82e5\u7f16\u8bd1\u5185\u6838\u65f6\u672a\u5f00\u542f CONFIG_SECURITY_FILE_CAPABILITIES \u914d\u7f6e\u9879&#xff0c;\u5219\u53ef\u4ee5\u7981\u7528\u6587\u4ef6\u6743\u80fd\u3002<\/li>\n<\/ul>\n<p>\u5c3d\u7ba1 Linux \u4ece 2.2 \u7248\u5185\u6838\u5c31\u5f15\u5165\u4e86\u6743\u80fd\u673a\u5236&#xff0c;\u5e76\u652f\u6301\u5c06\u6743\u80fd\u5173\u8054\u5230\u8fdb\u7a0b&#xff0c;\u4f46\u6587\u4ef6\u6743\u80fd\u7684\u5b9e\u73b0\u5374\u662f\u6570\u5e74\u4e4b\u540e\u624d\u5b8c\u6210\u3002\u6587\u4ef6\u6743\u80fd\u8fdf\u8fdf\u6ca1\u6709\u843d\u5730&#xff0c;\u5176\u539f\u56e0\u5728\u4e8e\u7b56\u7565\u5c42\u9762\u8003\u91cf&#xff0c;\u800c\u975e\u6280\u672f\u96be\u9898\u3002&#xff08;\u5b9e\u73b0\u6587\u4ef6\u6743\u80fd\u6240\u4f9d\u8d56\u7684\u6269\u5c55\u5c5e\u6027&#xff0c;\u89c1\u7b2c 16 \u7ae0&#xff0c;\u81ea 2.6 \u5185\u6838\u8d77\u5c31\u5df2\u7ecf\u53ef\u7528\u3002&#xff09;\u5185\u6838\u5f00\u53d1\u8005\u7fa4\u4f53\u7684\u4e3b\u6d41\u770b\u6cd5\u662f&#xff1a;\u8981\u6c42\u7cfb\u7edf\u7ba1\u7406\u5458\u4e3a\u6bcf\u4e00\u4e2a\u7279\u6743\u7a0b\u5e8f\u8bbe\u7f6e\u5e76\u7ef4\u62a4\u591a\u5957\u4e0d\u540c\u7684\u6743\u80fd\u96c6\u5408&#xff0c;\u800c\u90e8\u5206\u6743\u80fd\u7684\u5f71\u54cd\u5fae\u5999\u4e14\u5f71\u54cd\u6df1\u8fdc&#xff0c;\u8fd9\u4f1a\u5e26\u6765\u96be\u4ee5\u7ba1\u63a7\u7684\u590d\u6742\u8fd0\u7ef4\u5de5\u4f5c\u3002\u4e0e\u4e4b\u76f8\u5bf9&#xff0c;\u7cfb\u7edf\u7ba1\u7406\u5458\u65e9\u5df2\u719f\u6089\u4f20\u7edf UNIX \u6743\u9650\u6a21\u578b&#xff0c;\u77e5\u9053\u8981\u5ba1\u614e\u5bf9\u5f85 set-user-ID \u7a0b\u5e8f&#xff0c;\u5e76\u4e14\u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u7684 find \u547d\u4ee4&#xff0c;\u627e\u51fa\u7cfb\u7edf\u4e2d\u6240\u6709 set-user-ID \u4e0e set-group-ID \u7a0b\u5e8f\u3002\u5c3d\u7ba1\u5982\u6b64&#xff0c;\u6587\u4ef6\u6743\u80fd\u7684\u5f00\u53d1\u8005\u8bba\u8bc1\u8be5\u673a\u5236\u5728\u8fd0\u7ef4\u4e0a\u5177\u5907\u53ef\u884c\u6027&#xff0c;\u6700\u7ec8\u63d0\u51fa\u4e86\u8db3\u591f\u6709\u8bf4\u670d\u529b\u7684\u89c2\u70b9&#xff0c;\u4f7f\u5f97\u6587\u4ef6\u6743\u80fd\u88ab\u5e76\u5165\u5185\u6838\u3002<\/p>\n<p>The CAP_SETPCAP capability \u5728\u4e0d\u652f\u6301\u6587\u4ef6\u6743\u80fd\u7684\u5185\u6838\u4e0a&#xff08;\u5373 2.6.24 \u4e4b\u524d\u7684\u6240\u6709\u5185\u6838&#xff0c;\u4ee5\u53ca 2.6.24 \u4e4b\u540e\u4f46\u7981\u7528\u6587\u4ef6\u6743\u80fd\u7684\u5185\u6838&#xff09;&#xff0c;CAP_SETPCAP\u6743\u80fd\u7684\u8bed\u4e49\u6709\u6240\u4e0d\u540c\u3002\u5728\u9075\u5faa\u4e0e 39.7 \u8282\u6240\u8ff0\u7c7b\u4f3c\u89c4\u5219\u7684\u524d\u63d0\u4e0b&#xff0c;\u82e5\u8fdb\u7a0b\u7684\u6709\u6548\u6743\u80fd\u96c6\u4e2d\u6709CAP_SETPCAP&#xff0c;\u7406\u8bba\u4e0a\u5b83\u53ef\u4ee5\u4fee\u6539\u5176\u4ed6\u8fdb\u7a0b\u7684\u6743\u80fd\u3002\u4fee\u6539\u5bf9\u8c61\u53ef\u4ee5\u662f\u5355\u4e2a\u5176\u4ed6\u8fdb\u7a0b\u3001\u6307\u5b9a\u8fdb\u7a0b\u7ec4\u5185\u7684\u5168\u90e8\u8fdb\u7a0b&#xff0c;\u6216\u662f\u7cfb\u7edf\u4e0a\u9664 init \u8fdb\u7a0b\u4e0e\u8c03\u7528\u8fdb\u7a0b\u81ea\u8eab\u4e4b\u5916\u7684\u6240\u6709\u8fdb\u7a0b\u3002\u6700\u540e\u4e00\u79cd\u573a\u666f\u6392\u9664 init \u8fdb\u7a0b&#xff0c;\u56e0\u4e3a\u5b83\u662f\u7cfb\u7edf\u8fd0\u884c\u7684\u57fa\u7840&#xff1b;\u540c\u65f6\u6392\u9664\u8c03\u7528\u8fdb\u7a0b&#xff0c;\u662f\u8003\u8651\u8c03\u7528\u8005\u53ef\u80fd\u8bd5\u56fe\u6e05\u9664\u7cfb\u7edf\u5185\u6240\u6709\u5176\u4ed6\u8fdb\u7a0b\u7684\u6743\u80fd&#xff0c;\u800c\u6211\u4eec\u4e0d\u5e0c\u671b\u8c03\u7528\u8fdb\u7a0b\u81ea\u8eab\u7684\u6743\u80fd\u4e5f\u88ab\u4e00\u5e76\u6e05\u9664\u3002<\/p>\n<p>\u4e0d\u8fc7&#xff0c;\u4fee\u6539\u5176\u4ed6\u8fdb\u7a0b\u6743\u80fd\u4ec5\u505c\u7559\u5728\u7406\u8bba\u53ef\u884c\u3002\u5728\u65e7\u5185\u6838&#xff0c;\u4ee5\u53ca\u7981\u7528\u6587\u4ef6\u6743\u80fd\u7684\u73b0\u4ee3\u5185\u6838\u4e2d&#xff0c;\u6743\u80fd\u8fb9\u754c\u96c6&#xff08;\u4e0b\u4e00\u8282\u8ba8\u8bba&#xff09;\u603b\u4f1a\u5c4f\u853d\u6389CAP_SETPCAP\u6743\u80fd\u3002<\/p>\n<p>The capability bounding set \u81ea Linux 2.6.25 \u8d77&#xff0c;\u6743\u80fd\u8fb9\u754c\u96c6\u662f\u6309\u8fdb\u7a0b\u7684\u5c5e\u6027\u3002\u4f46\u5728\u66f4\u65e9\u7684\u5185\u6838\u4e2d&#xff0c;\u6743\u80fd\u8fb9\u754c\u96c6\u5c5e\u4e8e\u5168\u5c40\u7cfb\u7edf\u5c5e\u6027&#xff0c;\u4f1a\u4f5c\u7528\u4e8e\u7cfb\u7edf\u4e0a\u6240\u6709\u8fdb\u7a0b\u3002\u5168\u5c40\u6743\u80fd\u8fb9\u754c\u96c6\u5728\u521d\u59cb\u5316\u65f6\u5c31\u4f1a\u5c4f\u853d CAP_SETPCAP&#xff08;\u4e0a\u6587\u6240\u8ff0&#xff09;\u3002<\/p>\n<p>\u5728 2.6.25 \u4e4b\u540e\u7684\u5185\u6838\u4e0a&#xff0c;\u4ec5\u5f53\u5185\u6838\u5f00\u542f\u6587\u4ef6\u6743\u80fd\u652f\u6301\u65f6&#xff0c;\u624d\u5141\u8bb8\u4ece\u8fdb\u7a0b\u72ec\u7acb\u7684\u8fb9\u754c\u96c6\u4e2d\u79fb\u9664\u6743\u80fd\u3002\u6b64\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u6240\u6709\u8fdb\u7a0b\u7684\u7956\u5148 init \u8fdb\u7a0b\u542f\u52a8\u65f6&#xff0c;\u5176\u8fb9\u754c\u96c6\u5305\u542b\u5168\u90e8\u6743\u80fd&#xff1b;\u7cfb\u7edf\u540e\u7eed\u521b\u5efa\u7684\u5176\u4ed6\u8fdb\u7a0b\u4f1a\u7ee7\u627f\u8be5\u8fb9\u754c\u96c6\u7684\u526f\u672c\u3002\u82e5\u6587\u4ef6\u6743\u80fd\u88ab\u7981\u7528&#xff0c;\u7531\u4e8e\u524d\u9762\u63d0\u5230\u7684 CAP_SETPCAP \u8bed\u4e49\u5dee\u5f02&#xff0c;init \u542f\u52a8\u65f6\u7684\u8fb9\u754c\u96c6\u5305\u542b\u9664 CAP_SETPCAP \u4ee5\u5916\u7684\u5168\u90e8\u6743\u80fd\u3002<\/p>\n<p>Linux 2.6.25 \u4e2d\u6743\u80fd\u8fb9\u754c\u96c6\u7684\u8bed\u4e49\u8fd8\u6709\u53e6\u4e00\u5904\u6539\u52a8\u3002\u5982\u524d\u6587&#xff08;39.5.1 \u8282&#xff09;\u6240\u8ff0&#xff1a;\u5728 Linux 2.6.25 \u53ca\u66f4\u9ad8\u7248\u672c\u4e2d&#xff0c;\u8fdb\u7a0b\u7ea7\u6743\u80fd\u8fb9\u754c\u96c6\u4f5c\u4e3a\u4e00\u4e2a\u4e0a\u9650\u8d85\u96c6&#xff0c;\u9650\u5236\u53ef\u6dfb\u52a0\u5230\u8fdb\u7a0b\u53ef\u7ee7\u627f\u6743\u80fd\u96c6\u4e2d\u7684\u6743\u80fd\u3002\u800c\u5728 Linux 2.6.24 \u53ca\u66f4\u65e9\u7248\u672c\u91cc&#xff0c;\u7cfb\u7edf\u5168\u5c40\u6743\u80fd\u8fb9\u754c\u96c6\u5e76\u4e0d\u5177\u5907\u8fd9\u79cd\u63a9\u7801\u9650\u5236\u4f5c\u7528\u3002&#xff08;\u8be5\u673a\u5236\u5728\u8fd9\u7c7b\u5185\u6838\u4e2d\u5e76\u65e0\u5fc5\u8981&#xff0c;\u56e0\u4e3a\u5b83\u4eec\u4e0d\u652f\u6301\u6587\u4ef6\u6743\u80fd\u3002&#xff09;<\/p>\n<p>\u53ef\u901a\u8fc7 Linux \u7279\u6709\u7684\/proc\/sys\/kernel\/cap-bound\u6587\u4ef6\u8bbf\u95ee\u7cfb\u7edf\u5168\u5c40\u6743\u80fd\u8fb9\u754c\u96c6\u3002\u8fdb\u7a0b\u9700\u8981\u62e5\u6709CAP_SYS_MODULE\u6743\u80fd&#xff0c;\u624d\u80fd\u591f\u4fee\u6539cap-bound\u7684\u5185\u5bb9\u3002\u4f46\u53ea\u6709 init \u8fdb\u7a0b\u53ef\u4ee5\u5f00\u542f\u8be5\u63a9\u7801\u4e2d\u7684\u6807\u5fd7\u4f4d&#xff1b;\u5176\u4ed6\u7279\u6743\u8fdb\u7a0b\u53ea\u80fd\u5173\u95ed\u6807\u5fd7\u4f4d\u3002\u8fd9\u4e9b\u9650\u5236\u5e26\u6765\u7684\u7ed3\u679c\u662f&#xff1a;\u5728\u4e0d\u652f\u6301\u6587\u4ef6\u6743\u80fd\u7684\u7cfb\u7edf\u4e0a&#xff0c;\u6211\u4eec\u6c38\u8fdc\u65e0\u6cd5\u4e3a\u67d0\u4e2a\u8fdb\u7a0b\u8d4b\u4e88CAP_SETPCAP\u6743\u80fd\u3002\u8fd9\u6837\u8bbe\u8ba1\u662f\u5408\u7406\u7684&#xff0c;\u56e0\u4e3a\u8be5\u6743\u80fd\u53ef\u88ab\u7528\u6765\u7834\u574f\u6574\u5957\u5185\u6838\u6743\u9650\u6821\u9a8c\u673a\u5236\u3002&#xff08;\u5982\u679c\u5728\u6781\u5c11\u6570\u573a\u666f\u4e0b\u9700\u8981\u4fee\u6539\u8be5\u9650\u5236&#xff0c;\u5219\u5fc5\u987b\u52a0\u8f7d\u5185\u6838\u6a21\u5757\u4fee\u6539\u96c6\u5408\u7684\u503c\u3001\u4fee\u6539 init \u7a0b\u5e8f\u6e90\u7801&#xff0c;\u6216\u662f\u4fee\u6539\u5185\u6838\u6e90\u7801\u4e2d\u6743\u80fd\u8fb9\u754c\u96c6\u7684\u521d\u59cb\u5316\u4ee3\u7801\u5e76\u91cd\u65b0\u7f16\u8bd1\u5185\u6838\u3002&#xff09;<\/p>\n<p>\u5bb9\u6613\u4ee4\u4eba\u6df7\u6dc6\u7684\u662f&#xff1a;\u5c3d\u7ba1\u5168\u5c40 cap-bound \u7684\u503c\u662f\u4f4d\u63a9\u7801&#xff0c;\u4f46\u8be5\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9\u662f\u4ee5\u6709\u7b26\u53f7\u5341\u8fdb\u5236\u6570\u5c55\u793a\u7684\u3002\u4f8b\u5982&#xff0c;\u8be5\u6587\u4ef6\u521d\u59cb\u503c\u4e3a -257\u3002\u8fd9\u662f\u5bf9\u4e00\u4e2a\u4f4d\u63a9\u7801\u505a\u4e8c\u8fdb\u5236\u8865\u7801\u89e3\u8bfb\u5f97\u5230\u7684\u7ed3\u679c&#xff1a;\u9664 (1 &lt;&lt; 8) \u5bf9\u5e94\u7684\u4f4d\u4ee5\u5916&#xff0c;\u5176\u4f59\u6240\u6709\u4f4d\u5168\u90e8\u7f6e 1&#xff08;\u5373\u4e8c\u8fdb\u5236&#xff1a;11111111 11111111 11111110 11111111&#xff09;&#xff1b;\u800c CAP_SETPCAP \u7684\u7f16\u53f7\u4e3a 8\u3002<\/p>\n<p>Using capabilities within a program on a system without file capabilities \u5373\u4fbf\u5728\u4e0d\u652f\u6301\u6587\u4ef6\u6743\u80fd\u7684\u7cfb\u7edf\u4e0a&#xff0c;\u6211\u4eec\u4f9d\u7136\u53ef\u4ee5\u4f7f\u7528\u6743\u80fd\u673a\u5236\u63d0\u5347\u7a0b\u5e8f\u7684\u5b89\u5168\u6027&#xff0c;\u64cd\u4f5c\u6b65\u9aa4\u5982\u4e0b&#xff1a;<\/p>\n<li>\u5728\u6709\u6548\u7528\u6237 ID \u4e3a 0 \u7684\u8fdb\u7a0b\u4e2d\u8fd0\u884c\u7a0b\u5e8f&#xff08;\u901a\u5e38\u662f set-user-ID-root \u7a0b\u5e8f&#xff09;\u3002\u8fd9\u7c7b\u8fdb\u7a0b\u4f1a\u5728\u5176\u8bb8\u53ef\u6743\u80fd\u96c6\u4e0e\u6709\u6548\u6743\u80fd\u96c6\u4e2d\u83b7\u5f97\u5168\u90e8\u6743\u80fd&#xff08;\u524d\u6587\u63d0\u53ca\u7684 CAP_SETPCAP \u9664\u5916&#xff09;\u3002<\/li>\n<li>\u5728\u7a0b\u5e8f\u542f\u52a8\u9636\u6bb5&#xff0c;\u8c03\u7528 libcap API&#xff0c;\u6e05\u7a7a\u6709\u6548\u6743\u80fd\u96c6\u4e2d\u7684\u6240\u6709\u6743\u80fd&#xff1b;\u5e76\u4ece\u8bb8\u53ef\u6743\u80fd\u96c6\u4e2d\u5254\u9664\u9664\u540e\u7eed\u8fd0\u884c\u5fc5\u9700\u4e4b\u5916\u7684\u6240\u6709\u6743\u80fd\u3002<\/li>\n<li>\u8bbe\u7f6e SECBIT_KEEP_CAPS \u6807\u5fd7&#xff08;\u6216\u8c03\u7528 prctl () \u7684 PR_SET_KEEPCAPS \u64cd\u4f5c\u5b9e\u73b0\u540c\u6837\u6548\u679c&#xff09;&#xff0c;\u4fdd\u8bc1\u4e0b\u4e00\u6b65\u64cd\u4f5c\u4e0d\u4f1a\u4e22\u5f03\u6743\u80fd\u3002<\/li>\n<li>\u5c06\u6240\u6709\u7528\u6237 ID \u8bbe\u7f6e\u4e3a\u975e 0 \u503c&#xff0c;\u907f\u514d\u8be5\u8fdb\u7a0b\u8bbf\u95ee root \u5c5e\u4e3b\u7684\u6587\u4ef6&#xff0c;\u6216\u662f\u901a\u8fc7 exec () \u91cd\u65b0\u83b7\u53d6\u6743\u80fd\u3002 \u5982\u679c\u6211\u4eec\u4ec5\u5e0c\u671b\u963b\u6b62\u8fdb\u7a0b\u5728\u6267\u884c exec () \u65f6\u91cd\u65b0\u83b7\u5f97\u7279\u6743&#xff0c;\u4f46\u4ecd\u9700\u8981\u5141\u8bb8\u5b83\u8bbf\u95ee root \u5c5e\u4e3b\u7684\u6587\u4ef6&#xff0c;\u5c31\u53ef\u4ee5\u628a\u4e0a\u9762\u4e24\u6b65\u5408\u5e76&#xff0c;\u53ea\u8bbe\u7f6e SECBIT_NOROOT \u6807\u5fd7\u3002&#xff08;\u5f53\u7136&#xff0c;\u5141\u8bb8\u8bbf\u95ee root \u5c5e\u4e3b\u6587\u4ef6\u672c\u8eab\u4f1a\u5e26\u6765\u5b89\u5168\u6f0f\u6d1e\u98ce\u9669\u3002&#xff09;<\/li>\n<li>\u5728\u7a0b\u5e8f\u540e\u7eed\u6574\u4e2a\u8fd0\u884c\u751f\u547d\u5468\u671f\u5185&#xff0c;\u53ef\u901a\u8fc7 libcap API&#xff0c;\u6309\u9700\u5c06\u8bb8\u53ef\u6743\u80fd\u96c6\u4e2d\u4fdd\u7559\u7684\u6743\u80fd\u5728\u6709\u6548\u6743\u80fd\u96c6\u4e2d\u542f\u7528\u6216\u6e05\u9664&#xff0c;\u4ee5\u6b64\u5b8c\u6210\u9700\u8981\u7279\u6743\u7684\u4efb\u52a1\u3002<\/li>\n<p>\u4e00\u4e9b\u4e3a 2.6.24 \u7248\u672c\u4e4b\u524d\u7684 Linux \u5185\u6838\u7f16\u8bd1\u7684\u5e94\u7528\u7a0b\u5e8f\u5c31\u91c7\u7528\u4e86\u8fd9\u79cd\u65b9\u6848\u3002<\/p>\n<p>\u5728\u5185\u6838\u5f00\u53d1\u8005\u7fa4\u4f53\u4e2d&#xff0c;\u6709\u90e8\u5206\u4eba\u5f53\u521d\u53cd\u5bf9\u4e3a\u53ef\u6267\u884c\u6587\u4ef6\u5b9e\u73b0\u6587\u4ef6\u6743\u80fd\u3002\u4ed6\u4eec\u8ba4\u4e3a&#xff0c;\u4e0a\u6587\u4ecb\u7ecd\u7684\u8fd9\u79cd\u65b9\u6848\u6709\u4e00\u4e2a\u660e\u663e\u4f18\u70b9&#xff1a;\u5e94\u7528\u5f00\u53d1\u8005\u6e05\u695a\u8be5\u53ef\u6267\u884c\u7a0b\u5e8f\u9700\u8981\u54ea\u4e9b\u6743\u80fd\u3002\u4e0e\u4e4b\u76f8\u5bf9&#xff0c;\u7cfb\u7edf\u7ba1\u7406\u5458\u5f80\u5f80\u96be\u4ee5\u8f7b\u6613\u786e\u5b9a\u8fd9\u4e00\u4fe1\u606f\u3002<\/p>\n<h3>39.11 Summary<\/h3>\n<p>Linux \u6743\u80fd\u673a\u5236\u5c06\u7279\u6743\u64cd\u4f5c\u5212\u5206\u6210\u76f8\u4e92\u72ec\u7acb\u7684\u7c7b\u522b&#xff0c;\u5141\u8bb8\u4e3a\u8fdb\u7a0b\u6388\u4e88\u90e8\u5206\u6743\u80fd&#xff0c;\u540c\u65f6\u62d2\u7edd\u6388\u4e88\u53e6\u4e00\u4e9b\u6743\u80fd\u3002\u8be5\u673a\u5236\u76f8\u6bd4\u4f20\u7edf\u7684\u5168\u6709\u6216\u5168\u65e0\u7279\u6743\u6a21\u578b\u662f\u4e00\u5927\u6539\u8fdb&#xff1a;\u4f20\u7edf\u6a21\u578b\u4e0b&#xff0c;\u8fdb\u7a0b\u8981\u4e48\u62e5\u6709\u5168\u90e8\u64cd\u4f5c\u7279\u6743&#xff08;\u7528\u6237 ID \u4e3a 0&#xff09;&#xff0c;\u8981\u4e48\u5b8c\u5168\u6ca1\u6709\u7279\u6743&#xff08;\u975e 0 \u7528\u6237 ID&#xff09;\u3002\u81ea\u5185\u6838 2.6.24 \u8d77&#xff0c;Linux \u652f\u6301\u5c06\u6743\u80fd\u9644\u52a0\u5230\u6587\u4ef6\u4e0a&#xff0c;\u8fd9\u6837\u8fdb\u7a0b\u5c31\u53ef\u4ee5\u901a\u8fc7\u6267\u884c\u7a0b\u5e8f\u6765\u83b7\u5f97\u9009\u5b9a\u7684\u6743\u80fd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7b14\u8bb0\u548c\u7ec3\u4e60\u535a\u5ba2\u603b\u76ee\u5f55\u89c1&#xff1a;\u5f00\u59cb\u8bfbTLPI\u3002<br \/>\n\u672c\u7ae0\u4ecb\u7ecd Linux \u6743\u80fd&#xff08;capabilities&#xff09;\u673a\u5236\u3002\u8be5\u673a\u5236\u5c06\u4f20\u7edf UNIX\u300c\u8981\u4e48\u5168\u90e8\u6743\u9650\u3001\u8981\u4e48\u6ca1\u6709\u6743\u9650\u300d\u7684\u7279\u6743\u6a21\u578b&#xff0c;\u62c6\u5206\u4e3a\u82e5\u5e72\u53ef\u72ec\u7acb\u542f\u7528\u6216\u7981\u7528\u7684\u5355\u9879\u6743\u80fd\u3002\u501f\u52a9\u6743\u80fd\u673a\u5236&#xff0c;\u7a0b\u5e8f\u53ef\u4ee5\u6267\u884c\u90e8\u5206\u7279\u6743\u64cd\u4f5c&#xff0c;\u540c\u65f6\u88ab\u7981\u6b62\u6267\u884c\u5176\u4f59\u7279\u6743\u64cd\u4f5c\u3002<br \/>\n39.1 Rationale for Capabilities<br \/>\n\u4f20\u7edf UNIX \u7279\u6743\u673a\u5236\u5c06\u8fdb\u7a0b\u5206\u4e3a\u4e24\u7c7b&amp;#xff1a<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[12995,12997,12998,12996,58],"topic":[],"class_list":["post-114185","post","type-post","status-publish","format-standard","hentry","category-server","tag-capabiity","tag-libcap","tag-privilege","tag-tlpi","tag-linux"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>TLPI \u7b2c39\u7ae0 \u8bfb\u4e66\u7b14\u8bb0\uff1aCapabilities - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/114185.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"TLPI \u7b2c39\u7ae0 \u8bfb\u4e66\u7b14\u8bb0\uff1aCapabilities - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u7b14\u8bb0\u548c\u7ec3\u4e60\u535a\u5ba2\u603b\u76ee\u5f55\u89c1&#xff1a;\u5f00\u59cb\u8bfbTLPI\u3002 \u672c\u7ae0\u4ecb\u7ecd Linux \u6743\u80fd&#xff08;capabilities&#xff09;\u673a\u5236\u3002\u8be5\u673a\u5236\u5c06\u4f20\u7edf UNIX\u300c\u8981\u4e48\u5168\u90e8\u6743\u9650\u3001\u8981\u4e48\u6ca1\u6709\u6743\u9650\u300d\u7684\u7279\u6743\u6a21\u578b&#xff0c;\u62c6\u5206\u4e3a\u82e5\u5e72\u53ef\u72ec\u7acb\u542f\u7528\u6216\u7981\u7528\u7684\u5355\u9879\u6743\u80fd\u3002\u501f\u52a9\u6743\u80fd\u673a\u5236&#xff0c;\u7a0b\u5e8f\u53ef\u4ee5\u6267\u884c\u90e8\u5206\u7279\u6743\u64cd\u4f5c&#xff0c;\u540c\u65f6\u88ab\u7981\u6b62\u6267\u884c\u5176\u4f59\u7279\u6743\u64cd\u4f5c\u3002 39.1 Rationale for Capabilities \u4f20\u7edf UNIX \u7279\u6743\u673a\u5236\u5c06\u8fdb\u7a0b\u5206\u4e3a\u4e24\u7c7b&amp;#xff1a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/114185.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-08T07:09:02+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/114185.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/114185.html\",\"name\":\"TLPI \u7b2c39\u7ae0 \u8bfb\u4e66\u7b14\u8bb0\uff1aCapabilities - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-08T07:09:02+00:00\",\"dateModified\":\"2026-10-08T07:09:02+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/114185.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/114185.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/114185.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"TLPI \u7b2c39\u7ae0 \u8bfb\u4e66\u7b14\u8bb0\uff1aCapabilities\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"TLPI \u7b2c39\u7ae0 \u8bfb\u4e66\u7b14\u8bb0\uff1aCapabilities - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/114185.html","og_locale":"zh_CN","og_type":"article","og_title":"TLPI \u7b2c39\u7ae0 \u8bfb\u4e66\u7b14\u8bb0\uff1aCapabilities - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u7b14\u8bb0\u548c\u7ec3\u4e60\u535a\u5ba2\u603b\u76ee\u5f55\u89c1&#xff1a;\u5f00\u59cb\u8bfbTLPI\u3002 \u672c\u7ae0\u4ecb\u7ecd Linux \u6743\u80fd&#xff08;capabilities&#xff09;\u673a\u5236\u3002\u8be5\u673a\u5236\u5c06\u4f20\u7edf UNIX\u300c\u8981\u4e48\u5168\u90e8\u6743\u9650\u3001\u8981\u4e48\u6ca1\u6709\u6743\u9650\u300d\u7684\u7279\u6743\u6a21\u578b&#xff0c;\u62c6\u5206\u4e3a\u82e5\u5e72\u53ef\u72ec\u7acb\u542f\u7528\u6216\u7981\u7528\u7684\u5355\u9879\u6743\u80fd\u3002\u501f\u52a9\u6743\u80fd\u673a\u5236&#xff0c;\u7a0b\u5e8f\u53ef\u4ee5\u6267\u884c\u90e8\u5206\u7279\u6743\u64cd\u4f5c&#xff0c;\u540c\u65f6\u88ab\u7981\u6b62\u6267\u884c\u5176\u4f59\u7279\u6743\u64cd\u4f5c\u3002 39.1 Rationale for Capabilities \u4f20\u7edf UNIX \u7279\u6743\u673a\u5236\u5c06\u8fdb\u7a0b\u5206\u4e3a\u4e24\u7c7b&amp;#xff1a","og_url":"https:\/\/www.wsisp.com\/helps\/114185.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-08T07:09:02+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"13 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/114185.html","url":"https:\/\/www.wsisp.com\/helps\/114185.html","name":"TLPI \u7b2c39\u7ae0 \u8bfb\u4e66\u7b14\u8bb0\uff1aCapabilities - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-08T07:09:02+00:00","dateModified":"2026-10-08T07:09:02+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/114185.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/114185.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/114185.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"TLPI \u7b2c39\u7ae0 \u8bfb\u4e66\u7b14\u8bb0\uff1aCapabilities"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/114185","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=114185"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/114185\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=114185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=114185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=114185"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=114185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}