기능을 통해 Linux 프로세스는 루트 권한과 유사한 대부분의 권한을 제외하면서 함수를 실행하는 데 필요한 권한의 하위 집합을 유지할 수 있습니다.
원래의 기능 구현으로는 파일이 실행되어 파일 기능이 구성되지 않는 이상 프로세스를 분기하고 실행하여 기능을 상속하는 것이 불가능했습니다. 하지만 파일 기능은 결과적으로 보안 위험을 야기합니다. 이는 파일 기능으로 파일을 실행하는 모든 프로세스가 이러한 기능을 획득할 수 있기 때문입니다.
주변 기능을 사용하면 init에 의해 실행된 시스템 서비스가 .rc 파일에서 기능을 구성할 수 있으며, 이에 따라 fs_config.c 파일에서 구성을 분할하는 대신 단일 파일로 구성을 가져올 수 있습니다. 즉, init에 의해 실행된 모든 서비스에서, 서비스와 관련된 .rc 파일을 사용하여 서비스의 기능을 구성할 수 있습니다.
init에 의해 실행된 서비스의 기능 설정을 위한 메커니즘으로 주변 기능이 선호됩니다. 이렇게 하면 서비스 구성의 모든 측면을 하나의 .rc 파일에 유지할 수 있습니다. config.fs 파일의 caps 섹션을 사용하여 파일 시스템 기능을 구성하는 대신 주변 기능을 사용하는 것이 좋습니다.
init에 의해 실행되지 않은 서비스의 기능을 설정할 때는 계속해서 fs_config.c를 사용하여 파일 시스템 기능을 구성합니다.
주변 기능 사용 설정
지정된 서비스의 주변 기능을 사용 설정하려면 init에서 capabilities 키워드를 사용합니다. 최신 init 언어 세부정보는 init README.md를 참고하세요.
예를 들어 AOSP 서비스 wificond의 주변 기능을 사용 설정하려면 다음과 같이 wificond 서비스의 .rc 파일에서 적절한 사용자 및 그룹을 설정하고 capabilities 키워드를 사용하여 지정된 기능을 서비스에 제공해야 합니다.
service wificond /system/bin/wificond
class main
user wifi
group wifi net_raw net_admin
capabilities NET_RAW NET_ADMIN
Bionic 단위 테스트에는 주변 기능과 관련된 단위 테스트가 포함됩니다. 이외에도 서비스의 Android init에 'capabilities' 키워드를 사용한 후 서비스가 예상 기능을 얻는지 확인함으로써 이 특성의 런타임 테스트가 가능합니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[[["이해하기 쉬움","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."]]