קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
יכולות מאפשרות לתהליכים ב-Linux לבטל את רוב ההרשאות שדומות להרשאות root, תוך שמירה על קבוצת המשנה של ההרשאות שנדרשות להם כדי לבצע את הפונקציה שלהם.
ההטמעה המקורית של היכולות מנעה מאפשרות של תהליכים שהופעלו באמצעות fork+exec לרשת את היכולות, אלא אם הוגדר בקובצי ההפעלה היכולות של הקובץ. יכולות הקבצים, מצידן, מהוות סיכון אבטחה, כי כל תהליך שמריץ קובץ עם יכולות קבצים יכול לקבל את היכולות האלה.
יכולות הסביבה מאפשרות לשירותי המערכת שמופעלים על ידי init להגדיר יכולות בקבצים שלהם מסוג .rc, וכך להעביר את ההגדרות לקובץ אחד במקום לפצל אותן לקובץ fs_config.c. כלומר, לכל שירות שמופעל על ידי init, אפשר להשתמש בקובץ .rc שמשויך לשירות כדי להגדיר את היכולות של השירות הזה.
יכולות הסביבה הן המנגנון המועדף להגדרת יכולות לשירותים שמופעלים על ידי init (השיטה הזו שומרת את כל ההיבטים של הגדרת השירות בקובץ .rc יחיד). מומלץ להשתמש ביכולות הסביבה במקום להגדיר את יכולות מערכת הקבצים באמצעות הקטע caps בקובצי config.fs.
כשמגדירים יכולות לשירותים שלא הופעלו על ידי init, ממשיכים להגדיר את יכולות מערכת הקבצים באמצעות fs_config.c.
הפעלת יכולות אווירה
כדי להפעיל את יכולות הסביבה לשירות נתון, משתמשים במילות המפתח capabilities ב-init. לפרטים על השפות הנוכחיות של init, אפשר לעיין בקובץ README.md של init.
לדוגמה, כדי להפעיל את היכולות של הסביבה לשירות AOSP wificond, קובץ ה-rc של השירות wificond מגדיר את המשתמש והקבוצות המתאימים ומעניק לשירות את היכולות שצוינו באמצעות מילת המפתח capabilities:
service wificond /system/bin/wificond
class main
user wifi
group wifi net_raw net_admin
capabilities NET_RAW NET_ADMIN
בדיקות יחידה של Bionic כוללות בדיקות יחידה של יכולות אווירה. בנוסף, אפשר להשתמש במילות המפתח 'capabilities' ב-Android init לשירות, ואז לבדוק שהשירות מקבל את היכולות הצפויות, כדי לבדוק את התכונה הזו בסביבת זמן ריצה.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת 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."]]