[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-07-27 UTC"],[],[],null,["# Ambient capabilities\n\nCapabilities allow Linux processes to drop most root-like privileges while\nretaining the subset of privileges that they require to perform their function.\nThe original implementation of capabilities made it impossible for fork+exec'd\nprocesses to inherit capabilities unless the files being executed had file\ncapabilities configured. File capabilities, in turn, present a security risk\nsince any process executing a file with file capabilities can gain\nthose capabilities.\n\n\nAmbient capabilities allow system services launched by init to configure\ncapabilities in their `.rc` files, bringing configuration into\na single file instead of splitting configuration in the\n`fs_config.c` file. This means that for any service launched by\ninit, you can use the `.rc` file associated with the service to\nconfigure capabilities for that service.\n\n\nAmbient capabilities are the preferred mechanism for setting capabilities\nfor services launched by init (this method keeps all aspects for the service\nconfiguration in a single `.rc` file). We recommend using ambient\ncapabilities instead of\n[configuring file\nsystem capabilities using the caps section](/docs/core/permissions/filesystem#configuring-the-caps-section) in `config.fs` files.\n\n\nWhen setting capabilities for services **not launched by init** ,\ncontinue to configure file system capabilities using\n`fs_config.c`.\n\nEnable ambient capabilities\n---------------------------\n\n\nTo enable ambient capabilities for a given service, use the\n`capabilities` keyword in init. For current init language\ndetails, refer to the\n[init README.md](https://android.googlesource.com/platform/system/core/+/android16-release/init/README.md).\n\n\nFor example, to enable ambient capabilities for the AOSP service\n`wificond`, the\n[.rc file](https://android.googlesource.com/platform/system/connectivity/wificond/+/android16-release/wificond.rc)\nfor the `wificond` service sets up the appropriate\nuser and groups and gives the service the specified capabilities using the\n`capabilities` keyword: \n\n```scdoc\nservice wificond /system/bin/wificond\n class main\n user wifi\n group wifi net_raw net_admin\n capabilities NET_RAW NET_ADMIN\n```\n\nReference implementation\n------------------------\n\n\nThe reference implementation is the Android common kernel \u003chttps://android.googlesource.com/kernel/common/\u003e\n\nRequired patches\n----------------\n\n| **Note:** The Android kernels 3.10 (android-3.10) and 3.14 (android-3.14) have been deprecated and removed.\n\n\nRequired patches have been backported to all the relevant Android common kernel\nbranches.\n\n\nThe main ambient capabilities patch \u003chttps://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=58319057b7847667f0c9585b9de0e8932b0fdb08\u003e\nhas been backported in:\n\n- android-3.18:\n - \u003chttps://android.googlesource.com/kernel/common/+/d6a9a74487e86b528c44965f871de75671b6adb0\u003e\n- android-4.1:\n - \u003chttps://android.googlesource.com/kernel/common/+/0381789d78d552462ef576d9759e9aa6fcaae3bb\u003e\n\n\nA small security fix \u003chttps://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b7f76ea2ef6739ee484a165ffbac98deb855d3d3\u003e\nhas been backported in:\n\n- android-3.18:\n - \u003chttps://android.googlesource.com/kernel/common/+/7bc0ef844a537ebb786ba0574932bd65751818c6\u003e\n- android-4.1:\n - \u003chttps://android.googlesource.com/kernel/common/+/dda568cc40d855bde2dfa9c04a7a1628c80b7f63\u003e\n\nValidation\n----------\n\n\n[Bionic\nunit tests](https://android.googlesource.com/platform/bionic/+/main#Running-the-tests) include unit tests for ambient capabilities. Beyond that, using\nthe \"capabilities\" keyword in Android init for a service, and then checking that\nthe service gets the expected capabilities would allow for runtime testing of\nthis feature."]]