The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /* This file is used to define the properties of the filesystem |
| 18 | ** images generated by build tools (mkbootfs and mkyaffs2image) and |
| 19 | ** by the device side of adb. |
| 20 | */ |
| 21 | |
| 22 | #ifndef _ANDROID_FILESYSTEM_CONFIG_H_ |
| 23 | #define _ANDROID_FILESYSTEM_CONFIG_H_ |
| 24 | |
Mark Salyzyn | 1604561 | 2015-04-06 12:51:35 -0700 | [diff] [blame] | 25 | #include <sys/cdefs.h> |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 26 | #include <sys/types.h> |
Nick Kralevich | e9e74f3 | 2013-02-07 14:22:12 -0800 | [diff] [blame] | 27 | #include <stdint.h> |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 28 | |
Elliott Hughes | 9b828ad | 2015-07-30 08:47:35 -0700 | [diff] [blame] | 29 | #if defined(__ANDROID__) |
Nick Kralevich | fe81357 | 2013-02-11 15:14:55 -0800 | [diff] [blame] | 30 | #include <linux/capability.h> |
| 31 | #else |
| 32 | #include "android_filesystem_capability.h" |
| 33 | #endif |
| 34 | |
Jorge Lucangeli Obes | e920c46 | 2015-09-02 16:19:59 -0700 | [diff] [blame] | 35 | #define CAP_MASK_LONG(cap_name) (1ULL << (cap_name)) |
| 36 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 37 | /* This is the master Users and Groups config for the platform. |
Jeff Sharkey | dfe0cba | 2013-07-03 17:08:29 -0700 | [diff] [blame] | 38 | * DO NOT EVER RENUMBER |
| 39 | */ |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 40 | |
| 41 | #define AID_ROOT 0 /* traditional unix root user */ |
| 42 | |
| 43 | #define AID_SYSTEM 1000 /* system server */ |
| 44 | |
| 45 | #define AID_RADIO 1001 /* telephony subsystem, RIL */ |
| 46 | #define AID_BLUETOOTH 1002 /* bluetooth subsystem */ |
| 47 | #define AID_GRAPHICS 1003 /* graphics devices */ |
| 48 | #define AID_INPUT 1004 /* input devices */ |
| 49 | #define AID_AUDIO 1005 /* audio devices */ |
| 50 | #define AID_CAMERA 1006 /* camera devices */ |
| 51 | #define AID_LOG 1007 /* log devices */ |
| 52 | #define AID_COMPASS 1008 /* compass device */ |
| 53 | #define AID_MOUNT 1009 /* mountd socket */ |
| 54 | #define AID_WIFI 1010 /* wifi subsystem */ |
| 55 | #define AID_ADB 1011 /* android debug bridge (adbd) */ |
| 56 | #define AID_INSTALL 1012 /* group for installing packages */ |
| 57 | #define AID_MEDIA 1013 /* mediaserver process */ |
| 58 | #define AID_DHCP 1014 /* dhcp client */ |
San Mehat | 6e1f215 | 2009-04-23 09:15:08 -0700 | [diff] [blame] | 59 | #define AID_SDCARD_RW 1015 /* external storage write access */ |
San Mehat | 4a6f232 | 2009-05-14 19:44:59 -0700 | [diff] [blame] | 60 | #define AID_VPN 1016 /* vpn system */ |
Chung-yih Wang | 1f75d70 | 2009-06-01 19:04:05 +0800 | [diff] [blame] | 61 | #define AID_KEYSTORE 1017 /* keystore subsystem */ |
Mike Lockwood | 93ac155 | 2010-05-06 13:30:09 -0400 | [diff] [blame] | 62 | #define AID_USB 1018 /* USB devices */ |
aimitakeshi | e572d59 | 2010-07-27 08:38:35 +0900 | [diff] [blame] | 63 | #define AID_DRM 1019 /* DRM server */ |
Robert Greenwalt | 1d91fcf | 2012-03-27 16:59:27 -0700 | [diff] [blame] | 64 | #define AID_MDNSR 1020 /* MulticastDNSResponder (service discovery) */ |
Mike Lockwood | c29919c | 2010-09-27 08:01:58 -0400 | [diff] [blame] | 65 | #define AID_GPS 1021 /* GPS daemon */ |
Jeff Hamilton | a6a36c0 | 2011-03-24 21:40:43 -0500 | [diff] [blame] | 66 | #define AID_UNUSED1 1022 /* deprecated, DO NOT USE */ |
Mike Lockwood | 2e0047b | 2010-10-29 10:55:54 -0400 | [diff] [blame] | 67 | #define AID_MEDIA_RW 1023 /* internal media storage write access */ |
Mike Lockwood | af7bdc6 | 2011-01-10 08:22:30 -0500 | [diff] [blame] | 68 | #define AID_MTP 1024 /* MTP USB driver access */ |
Nick Pelly | 097b4ed | 2011-11-21 14:55:59 -0800 | [diff] [blame] | 69 | #define AID_UNUSED2 1025 /* deprecated, DO NOT USE */ |
Jeffrey Tinker | 7005c03 | 2011-09-30 12:40:25 -0700 | [diff] [blame] | 70 | #define AID_DRMRPC 1026 /* group for drm rpc */ |
Nick Pelly | 097b4ed | 2011-11-21 14:55:59 -0800 | [diff] [blame] | 71 | #define AID_NFC 1027 /* nfc subsystem */ |
Dianne Hackborn | 50458cf | 2012-03-07 12:57:14 -0800 | [diff] [blame] | 72 | #define AID_SDCARD_R 1028 /* external storage read access */ |
Daniel Drown | b49183f | 2012-02-16 10:00:24 -0600 | [diff] [blame] | 73 | #define AID_CLAT 1029 /* clat part of nat464 */ |
Doug Zongker | 8cc9730 | 2013-01-29 10:50:22 -0800 | [diff] [blame] | 74 | #define AID_LOOP_RADIO 1030 /* loop radio devices */ |
Jeff Tinker | 08d6430 | 2013-04-23 19:54:17 -0700 | [diff] [blame] | 75 | #define AID_MEDIA_DRM 1031 /* MediaDrm plugins */ |
Jeff Sharkey | dfe0cba | 2013-07-03 17:08:29 -0700 | [diff] [blame] | 76 | #define AID_PACKAGE_INFO 1032 /* access to installed package details */ |
| 77 | #define AID_SDCARD_PICS 1033 /* external storage photos access */ |
| 78 | #define AID_SDCARD_AV 1034 /* external storage audio/video access */ |
| 79 | #define AID_SDCARD_ALL 1035 /* access all users external storage */ |
Nick Kralevich | 3e76e0a | 2011-12-15 11:43:38 -0800 | [diff] [blame] | 80 | #define AID_LOGD 1036 /* log daemon */ |
Torne (Richard Coles) | 234f696 | 2014-05-22 18:40:21 +0100 | [diff] [blame] | 81 | #define AID_SHARED_RELRO 1037 /* creator of shared GNU RELRO files */ |
Daniel Erat | f7b8cae | 2015-07-17 16:04:54 -0600 | [diff] [blame] | 82 | #define AID_DBUS 1038 /* dbus-daemon IPC broker process */ |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 83 | |
| 84 | #define AID_SHELL 2000 /* adb and debug shell user */ |
| 85 | #define AID_CACHE 2001 /* cache access */ |
| 86 | #define AID_DIAG 2002 /* access to diagnostic resources */ |
| 87 | |
Johan Redestig | 60ac636 | 2014-11-07 09:21:13 +0100 | [diff] [blame] | 88 | /* The range 2900-2999 is reserved for OEM, and must never be |
| 89 | * used here */ |
| 90 | #define AID_OEM_RESERVED_START 2900 |
| 91 | #define AID_OEM_RESERVED_END 2999 |
| 92 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 93 | /* The 3000 series are intended for use as supplemental group id's only. |
| 94 | * They indicate special Android capabilities that the kernel is aware of. */ |
| 95 | #define AID_NET_BT_ADMIN 3001 /* bluetooth: create any socket */ |
| 96 | #define AID_NET_BT 3002 /* bluetooth: create sco, rfcomm or l2cap sockets */ |
| 97 | #define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */ |
| 98 | #define AID_NET_RAW 3004 /* can create raw INET sockets */ |
Chia-chi Yeh | 88dc657 | 2009-06-19 14:59:08 +0800 | [diff] [blame] | 99 | #define AID_NET_ADMIN 3005 /* can configure interfaces and routing tables. */ |
Jeff Sharkey | 4f1df18 | 2011-05-02 17:52:03 -0700 | [diff] [blame] | 100 | #define AID_NET_BW_STATS 3006 /* read bandwidth statistics */ |
| 101 | #define AID_NET_BW_ACCT 3007 /* change bandwidth statistics accounting */ |
Matthew Xie | 971153a | 2012-10-04 12:35:27 -0700 | [diff] [blame] | 102 | #define AID_NET_BT_STACK 3008 /* bluetooth: access config files */ |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 103 | |
Jorge Lucangeli Obes | b93b9d4 | 2015-07-31 13:52:19 -0700 | [diff] [blame] | 104 | /* The range 5000-5999 is also reserved for OEM, and must never be used here. */ |
| 105 | #define AID_OEM_RESERVED_2_START 5000 |
| 106 | #define AID_OEM_RESERVED_2_END 5999 |
| 107 | |
Robin Lee | b3ef039 | 2014-04-25 15:16:02 +0100 | [diff] [blame] | 108 | #define AID_EVERYBODY 9997 /* shared between all apps in the same profile */ |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 109 | #define AID_MISC 9998 /* access to misc storage */ |
| 110 | #define AID_NOBODY 9999 |
| 111 | |
Dianne Hackborn | ca185ab | 2012-02-09 11:19:00 -0800 | [diff] [blame] | 112 | #define AID_APP 10000 /* first app user */ |
| 113 | |
| 114 | #define AID_ISOLATED_START 99000 /* start of uids for fully isolated sandboxed processes */ |
| 115 | #define AID_ISOLATED_END 99999 /* end of uids for fully isolated sandboxed processes */ |
| 116 | |
| 117 | #define AID_USER 100000 /* offset for uid ranges for each user */ |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 118 | |
Kenny Root | 7e41c84 | 2012-09-11 15:03:45 -0700 | [diff] [blame] | 119 | #define AID_SHARED_GID_START 50000 /* start of gids for apps in each user to share */ |
| 120 | #define AID_SHARED_GID_END 59999 /* start of gids for apps in each user to share */ |
| 121 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 122 | #if !defined(EXCLUDE_FS_CONFIG_STRUCTURES) |
Mark Salyzyn | a21c29e | 2015-04-01 07:46:14 -0700 | [diff] [blame] | 123 | /* |
| 124 | * Used in: |
| 125 | * bionic/libc/bionic/stubs.cpp |
| 126 | * external/libselinux/src/android.c |
| 127 | * system/core/logd/LogStatistics.cpp |
| 128 | * system/core/init/ueventd.cpp |
| 129 | * system/core/init/util.cpp |
| 130 | */ |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 131 | struct android_id_info { |
| 132 | const char *name; |
| 133 | unsigned aid; |
| 134 | }; |
| 135 | |
Nick Kralevich | 4688ac5 | 2010-08-31 09:44:43 -0700 | [diff] [blame] | 136 | static const struct android_id_info android_ids[] = { |
Jeff Sharkey | dfe0cba | 2013-07-03 17:08:29 -0700 | [diff] [blame] | 137 | { "root", AID_ROOT, }, |
| 138 | |
| 139 | { "system", AID_SYSTEM, }, |
| 140 | |
| 141 | { "radio", AID_RADIO, }, |
| 142 | { "bluetooth", AID_BLUETOOTH, }, |
| 143 | { "graphics", AID_GRAPHICS, }, |
| 144 | { "input", AID_INPUT, }, |
| 145 | { "audio", AID_AUDIO, }, |
| 146 | { "camera", AID_CAMERA, }, |
| 147 | { "log", AID_LOG, }, |
| 148 | { "compass", AID_COMPASS, }, |
| 149 | { "mount", AID_MOUNT, }, |
| 150 | { "wifi", AID_WIFI, }, |
| 151 | { "adb", AID_ADB, }, |
| 152 | { "install", AID_INSTALL, }, |
| 153 | { "media", AID_MEDIA, }, |
| 154 | { "dhcp", AID_DHCP, }, |
| 155 | { "sdcard_rw", AID_SDCARD_RW, }, |
| 156 | { "vpn", AID_VPN, }, |
| 157 | { "keystore", AID_KEYSTORE, }, |
| 158 | { "usb", AID_USB, }, |
| 159 | { "drm", AID_DRM, }, |
| 160 | { "mdnsr", AID_MDNSR, }, |
| 161 | { "gps", AID_GPS, }, |
| 162 | // AID_UNUSED1 |
| 163 | { "media_rw", AID_MEDIA_RW, }, |
| 164 | { "mtp", AID_MTP, }, |
| 165 | // AID_UNUSED2 |
| 166 | { "drmrpc", AID_DRMRPC, }, |
| 167 | { "nfc", AID_NFC, }, |
| 168 | { "sdcard_r", AID_SDCARD_R, }, |
| 169 | { "clat", AID_CLAT, }, |
| 170 | { "loop_radio", AID_LOOP_RADIO, }, |
| 171 | { "mediadrm", AID_MEDIA_DRM, }, |
| 172 | { "package_info", AID_PACKAGE_INFO, }, |
| 173 | { "sdcard_pics", AID_SDCARD_PICS, }, |
| 174 | { "sdcard_av", AID_SDCARD_AV, }, |
| 175 | { "sdcard_all", AID_SDCARD_ALL, }, |
Nick Kralevich | 3e76e0a | 2011-12-15 11:43:38 -0800 | [diff] [blame] | 176 | { "logd", AID_LOGD, }, |
Torne (Richard Coles) | 234f696 | 2014-05-22 18:40:21 +0100 | [diff] [blame] | 177 | { "shared_relro", AID_SHARED_RELRO, }, |
Daniel Erat | f7b8cae | 2015-07-17 16:04:54 -0600 | [diff] [blame] | 178 | { "dbus", AID_DBUS, }, |
Jeff Sharkey | dfe0cba | 2013-07-03 17:08:29 -0700 | [diff] [blame] | 179 | |
| 180 | { "shell", AID_SHELL, }, |
| 181 | { "cache", AID_CACHE, }, |
| 182 | { "diag", AID_DIAG, }, |
| 183 | |
| 184 | { "net_bt_admin", AID_NET_BT_ADMIN, }, |
| 185 | { "net_bt", AID_NET_BT, }, |
| 186 | { "inet", AID_INET, }, |
| 187 | { "net_raw", AID_NET_RAW, }, |
| 188 | { "net_admin", AID_NET_ADMIN, }, |
| 189 | { "net_bw_stats", AID_NET_BW_STATS, }, |
| 190 | { "net_bw_acct", AID_NET_BW_ACCT, }, |
| 191 | { "net_bt_stack", AID_NET_BT_STACK, }, |
| 192 | |
Robin Lee | b3ef039 | 2014-04-25 15:16:02 +0100 | [diff] [blame] | 193 | { "everybody", AID_EVERYBODY, }, |
Jeff Sharkey | dfe0cba | 2013-07-03 17:08:29 -0700 | [diff] [blame] | 194 | { "misc", AID_MISC, }, |
| 195 | { "nobody", AID_NOBODY, }, |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 196 | }; |
| 197 | |
| 198 | #define android_id_count \ |
| 199 | (sizeof(android_ids) / sizeof(android_ids[0])) |
Doug Zongker | 08c370c | 2012-05-03 14:16:54 -0700 | [diff] [blame] | 200 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 201 | struct fs_path_config { |
| 202 | unsigned mode; |
| 203 | unsigned uid; |
| 204 | unsigned gid; |
Nick Kralevich | e9e74f3 | 2013-02-07 14:22:12 -0800 | [diff] [blame] | 205 | uint64_t capabilities; |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 206 | const char *prefix; |
| 207 | }; |
| 208 | |
Mark Salyzyn | a21c29e | 2015-04-01 07:46:14 -0700 | [diff] [blame] | 209 | /* Rules for directories and files has moved to system/code/libcutils/fs_config.c */ |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 210 | |
Mark Salyzyn | 1604561 | 2015-04-06 12:51:35 -0700 | [diff] [blame] | 211 | __BEGIN_DECLS |
Mark Salyzyn | a21c29e | 2015-04-01 07:46:14 -0700 | [diff] [blame] | 212 | |
| 213 | /* |
| 214 | * Used in: |
| 215 | * build/tools/fs_config/fs_config.c |
| 216 | * build/tools/fs_get_stats/fs_get_stats.c |
| 217 | * external/genext2fs/genext2fs.c |
| 218 | * external/squashfs-tools/squashfs-tools/android.c |
| 219 | * system/core/cpio/mkbootfs.c |
| 220 | * system/core/adb/file_sync_service.cpp |
| 221 | * system/extras/ext4_utils/canned_fs_config.c |
| 222 | */ |
| 223 | void fs_config(const char *path, int dir, |
| 224 | unsigned *uid, unsigned *gid, unsigned *mode, uint64_t *capabilities); |
| 225 | |
Mark Salyzyn | 5d9e5ef | 2015-04-01 11:02:00 -0700 | [diff] [blame] | 226 | ssize_t fs_config_generate(char *buffer, size_t length, const struct fs_path_config *pc); |
| 227 | |
Mark Salyzyn | 1604561 | 2015-04-06 12:51:35 -0700 | [diff] [blame] | 228 | __END_DECLS |
Mark Salyzyn | a21c29e | 2015-04-01 07:46:14 -0700 | [diff] [blame] | 229 | |
| 230 | #endif |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 231 | #endif |