Advertisement
Perka

include/private/android_filesystem_config.h

Feb 5th, 2012
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.16 KB | None | 0 0
  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.  
  25. #include <string.h>
  26. #include <sys/stat.h>
  27. #include <sys/types.h>
  28.  
  29. /* This is the master Users and Groups config for the platform.
  30. ** DO NOT EVER RENUMBER.
  31. */
  32.  
  33. #define AID_ROOT 0 /* traditional unix root user */
  34.  
  35. #define AID_SYSTEM 1000 /* system server */
  36.  
  37. #define AID_RADIO 1001 /* telephony subsystem, RIL */
  38. #define AID_BLUETOOTH 1002 /* bluetooth subsystem */
  39. #define AID_GRAPHICS 1003 /* graphics devices */
  40. #define AID_INPUT 1004 /* input devices */
  41. #define AID_AUDIO 1005 /* audio devices */
  42. #define AID_CAMERA 1006 /* camera devices */
  43. #define AID_LOG 1007 /* log devices */
  44. #define AID_COMPASS 1008 /* compass device */
  45. #define AID_MOUNT 1009 /* mountd socket */
  46. #define AID_WIFI 1010 /* wifi subsystem */
  47. #define AID_ADB 1011 /* android debug bridge (adbd) */
  48. #define AID_INSTALL 1012 /* group for installing packages */
  49. #define AID_MEDIA 1013 /* mediaserver process */
  50. #define AID_DHCP 1014 /* dhcp client */
  51. #define AID_SDCARD_RW 1015 /* external storage write access */
  52. #define AID_VPN 1016 /* vpn system */
  53. #define AID_KEYSTORE 1017 /* keystore subsystem */
  54. #define AID_USB 1018 /* USB devices */
  55. #define AID_DRM 1019 /* DRM server */
  56. #define AID_AVAILABLE 1020 /* available for use */
  57. #define AID_GPS 1021 /* GPS daemon */
  58. #define AID_UNUSED1 1022 /* deprecated, DO NOT USE */
  59. #define AID_MEDIA_RW 1023 /* internal media storage write access */
  60. #define AID_MTP 1024 /* MTP USB driver access */
  61. #define AID_UNUSED2 1025 /* deprecated, DO NOT USE */
  62. #define AID_DRMRPC 1026 /* group for drm rpc */
  63. #define AID_NFC 1027 /* nfc subsystem */
  64.  
  65. #define AID_SHELL 2000 /* adb and debug shell user */
  66. #define AID_CACHE 2001 /* cache access */
  67. #define AID_DIAG 2002 /* access to diagnostic resources */
  68.  
  69. /* The 3000 series are intended for use as supplemental group id's only.
  70. * They indicate special Android capabilities that the kernel is aware of. */
  71. #define AID_NET_BT_ADMIN 3001 /* bluetooth: create any socket */
  72. #define AID_NET_BT 3002 /* bluetooth: create sco, rfcomm or l2cap sockets */
  73. #define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */
  74. #define AID_NET_RAW 3004 /* can create raw INET sockets */
  75. #define AID_NET_ADMIN 3005 /* can configure interfaces and routing tables. */
  76. #define AID_NET_BW_STATS 3006 /* read bandwidth statistics */
  77. #define AID_NET_BW_ACCT 3007 /* change bandwidth statistics accounting */
  78. #define AID_QCOM_ONCRPC 3008 /* can read/write /dev/oncrpc files */
  79.  
  80. #if defined(MOTOROLA_UIDS)
  81. #define AID_MOT_OSH 5000 /* OSH */
  82. #define AID_MOT_ACCY 9000 /* access to accessory */
  83. #define AID_MOT_PWRIC 9001 /* power IC */
  84. #define AID_MOT_USB 9002 /* mot usb */
  85. #define AID_MOT_DRM 9003 /* can access DRM resource. */
  86. #define AID_MOT_TCMD 9004 /* mot_tcmd */
  87. #define AID_MOT_SEC_RTC 9005 /* mot cpcap rtc */
  88. #define AID_MOT_TOMBSTONE 9006
  89. #define AID_MOT_TPAPI 9007 /* mot_tpapi */
  90. #define AID_MOT_SECCLKD 9008 /* mot_secclkd */
  91. #define AID_MOT_WHISPER 9009 /* Whisper Protocol access */
  92. #define AID_MOT_CAIF 9010 /* can create CAIF sockets */
  93. #define AID_MOT_DLNA 9011 /* DLNA native */
  94. #endif // MOTOROLA_UIDS
  95.  
  96. #define AID_MISC 9998 /* access to misc storage */
  97. #define AID_NOBODY 9999
  98.  
  99. #define AID_APP 10000 /* first app user */
  100.  
  101. #if !defined(EXCLUDE_FS_CONFIG_STRUCTURES)
  102. struct android_id_info {
  103. const char *name;
  104. unsigned aid;
  105. };
  106.  
  107. static const struct android_id_info android_ids[] = {
  108. { "root", AID_ROOT, },
  109. { "system", AID_SYSTEM, },
  110. { "radio", AID_RADIO, },
  111. { "bluetooth", AID_BLUETOOTH, },
  112. { "graphics", AID_GRAPHICS, },
  113. { "input", AID_INPUT, },
  114. { "audio", AID_AUDIO, },
  115. { "camera", AID_CAMERA, },
  116. { "log", AID_LOG, },
  117. { "compass", AID_COMPASS, },
  118. { "mount", AID_MOUNT, },
  119. { "wifi", AID_WIFI, },
  120. { "dhcp", AID_DHCP, },
  121. { "adb", AID_ADB, },
  122. { "install", AID_INSTALL, },
  123. { "media", AID_MEDIA, },
  124. { "drm", AID_DRM, },
  125. { "available", AID_AVAILABLE, },
  126. { "nfc", AID_NFC, },
  127. { "drmrpc", AID_DRMRPC, },
  128. { "shell", AID_SHELL, },
  129. { "cache", AID_CACHE, },
  130. { "diag", AID_DIAG, },
  131. { "net_bt_admin", AID_NET_BT_ADMIN, },
  132. { "net_bt", AID_NET_BT, },
  133. { "sdcard_rw", AID_SDCARD_RW, },
  134. { "media_rw", AID_MEDIA_RW, },
  135. { "vpn", AID_VPN, },
  136. { "keystore", AID_KEYSTORE, },
  137. { "usb", AID_USB, },
  138. { "mtp", AID_MTP, },
  139. { "gps", AID_GPS, },
  140. { "inet", AID_INET, },
  141. { "net_raw", AID_NET_RAW, },
  142. { "net_admin", AID_NET_ADMIN, },
  143. { "net_bw_stats", AID_NET_BW_STATS, },
  144. { "net_bw_acct", AID_NET_BW_ACCT, },
  145. { "qcom_oncrpc", AID_QCOM_ONCRPC, },
  146. #if defined(MOTOROLA_UIDS)
  147. { "mot_osh", AID_MOT_OSH, },
  148. { "mot_accy", AID_MOT_ACCY, },
  149. { "mot_pwric", AID_MOT_PWRIC, },
  150. { "mot_usb", AID_MOT_USB, },
  151. { "mot_drm", AID_MOT_DRM, },
  152. { "mot_tcmd", AID_MOT_TCMD, },
  153. { "mot_sec_rtc", AID_MOT_SEC_RTC, },
  154. { "mot_tombstone", AID_MOT_TOMBSTONE, },
  155. { "mot_tpapi", AID_MOT_TPAPI, },
  156. { "mot_secclkd", AID_MOT_SECCLKD, },
  157. { "mot_whisper", AID_MOT_WHISPER, },
  158. { "mot_caif", AID_MOT_CAIF, },
  159. { "mot_dlna", AID_MOT_DLNA, },
  160. #endif
  161. { "misc", AID_MISC, },
  162. { "nobody", AID_NOBODY, },
  163. };
  164.  
  165. #define android_id_count \
  166. (sizeof(android_ids) / sizeof(android_ids[0]))
  167.  
  168. struct fs_path_config {
  169. unsigned mode;
  170. unsigned uid;
  171. unsigned gid;
  172. const char *prefix;
  173. };
  174.  
  175. /* Rules for directories.
  176. ** These rules are applied based on "first match", so they
  177. ** should start with the most specific path and work their
  178. ** way up to the root.
  179. */
  180.  
  181. static struct fs_path_config android_dirs[] = {
  182. { 00770, AID_SYSTEM, AID_CACHE, "cache" },
  183. { 00771, AID_SYSTEM, AID_SYSTEM, "data/app" },
  184. { 00771, AID_SYSTEM, AID_SYSTEM, "data/app-private" },
  185. { 00771, AID_SYSTEM, AID_SYSTEM, "data/dalvik-cache" },
  186. { 00771, AID_SYSTEM, AID_SYSTEM, "data/data" },
  187. { 00771, AID_SHELL, AID_SHELL, "data/local/tmp" },
  188. { 00771, AID_SHELL, AID_SHELL, "data/local" },
  189. { 01771, AID_SYSTEM, AID_MISC, "data/misc" },
  190. { 00770, AID_DHCP, AID_DHCP, "data/misc/dhcp" },
  191. { 00775, AID_MEDIA_RW, AID_MEDIA_RW, "data/media" },
  192. { 00775, AID_MEDIA_RW, AID_MEDIA_RW, "data/media/Music" },
  193. { 00771, AID_SYSTEM, AID_SYSTEM, "data" },
  194. { 00750, AID_ROOT, AID_SHELL, "sbin" },
  195. { 00755, AID_ROOT, AID_SHELL, "system/bin" },
  196. { 00755, AID_ROOT, AID_SHELL, "system/vendor" },
  197. { 00755, AID_ROOT, AID_SHELL, "system/xbin" },
  198. { 00755, AID_ROOT, AID_ROOT, "system/etc/ppp" },
  199. { 00777, AID_ROOT, AID_ROOT, "sdcard" },
  200. { 00755, AID_ROOT, AID_ROOT, 0 },
  201. };
  202.  
  203. /* Rules for files.
  204. ** These rules are applied based on "first match", so they
  205. ** should start with the most specific path and work their
  206. ** way up to the root. Prefixes ending in * denotes wildcard
  207. ** and will allow partial matches.
  208. */
  209. static struct fs_path_config android_files[] = {
  210. { 00440, AID_ROOT, AID_SHELL, "system/etc/init.goldfish.rc" },
  211. { 00550, AID_ROOT, AID_SHELL, "system/etc/init.goldfish.sh" },
  212. { 00440, AID_ROOT, AID_SHELL, "system/etc/init.trout.rc" },
  213. { 00550, AID_ROOT, AID_SHELL, "system/etc/init.ril" },
  214. { 00550, AID_ROOT, AID_SHELL, "system/etc/init.testmenu" },
  215. { 00550, AID_DHCP, AID_SHELL, "system/etc/dhcpcd/dhcpcd-run-hooks" },
  216. { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/dbus.conf" },
  217. { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/bluetooth/main.conf" },
  218. { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/bluetooth/input.conf" },
  219. { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/bluetooth/audio.conf" },
  220. { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/bluetooth/network.conf" },
  221. { 00444, AID_NET_BT, AID_NET_BT, "system/etc/bluetooth/blacklist.conf" },
  222. { 00640, AID_SYSTEM, AID_SYSTEM, "system/etc/bluetooth/auto_pairing.conf" },
  223. { 00444, AID_RADIO, AID_AUDIO, "system/etc/AudioPara4.csv" },
  224. { 00555, AID_ROOT, AID_ROOT, "system/etc/ppp/*" },
  225. { 00555, AID_ROOT, AID_ROOT, "system/etc/rc.*" },
  226. { 00644, AID_SYSTEM, AID_SYSTEM, "data/app/*" },
  227. { 00644, AID_MEDIA_RW, AID_MEDIA_RW, "data/media/*" },
  228. { 00644, AID_SYSTEM, AID_SYSTEM, "data/app-private/*" },
  229. { 00644, AID_APP, AID_APP, "data/data/*" },
  230. /* the following two files are INTENTIONALLY set-gid and not set-uid.
  231. * Do not change. */
  232. { 02755, AID_ROOT, AID_NET_RAW, "system/bin/ping" },
  233. { 02750, AID_ROOT, AID_INET, "system/bin/netcfg" },
  234. /* the following five files are INTENTIONALLY set-uid, but they
  235. * are NOT included on user builds. */
  236. { 06755, AID_ROOT, AID_ROOT, "system/xbin/su" },
  237. { 06755, AID_ROOT, AID_ROOT, "system/xbin/librank" },
  238. { 06755, AID_ROOT, AID_ROOT, "system/xbin/procrank" },
  239. { 06755, AID_ROOT, AID_ROOT, "system/xbin/procmem" },
  240. { 06755, AID_ROOT, AID_ROOT, "system/xbin/tcpdump" },
  241. { 04770, AID_ROOT, AID_RADIO, "system/bin/pppd-ril" },
  242. /* the following file is INTENTIONALLY set-uid, and IS included
  243. * in user builds. */
  244. { 06750, AID_ROOT, AID_SHELL, "system/bin/run-as" },
  245. { 00755, AID_ROOT, AID_SHELL, "system/bin/*" },
  246. { 00755, AID_ROOT, AID_ROOT, "system/lib/valgrind/*" },
  247. { 00755, AID_ROOT, AID_SHELL, "system/xbin/*" },
  248. { 00755, AID_ROOT, AID_SHELL, "system/vendor/bin/*" },
  249. { 00750, AID_ROOT, AID_SHELL, "sbin/*" },
  250. { 00755, AID_ROOT, AID_ROOT, "bin/*" },
  251. { 00750, AID_ROOT, AID_SHELL, "init*" },
  252. { 00750, AID_ROOT, AID_SHELL, "charger*" },
  253. { 00755, AID_ROOT, AID_SHELL, "system/etc/init.d/*" },
  254. { 00644, AID_ROOT, AID_ROOT, 0 },
  255. };
  256.  
  257. static inline void fs_config(const char *path, int dir,
  258. unsigned *uid, unsigned *gid, unsigned *mode)
  259. {
  260. struct fs_path_config *pc;
  261. int plen;
  262.  
  263. pc = dir ? android_dirs : android_files;
  264. plen = strlen(path);
  265. for(; pc->prefix; pc++){
  266. int len = strlen(pc->prefix);
  267. if (dir) {
  268. if(plen < len) continue;
  269. if(!strncmp(pc->prefix, path, len)) break;
  270. continue;
  271. }
  272. /* If name ends in * then allow partial matches. */
  273. if (pc->prefix[len -1] == '*') {
  274. if(!strncmp(pc->prefix, path, len - 1)) break;
  275. } else if (plen == len){
  276. if(!strncmp(pc->prefix, path, len)) break;
  277. }
  278. }
  279. *uid = pc->uid;
  280. *gid = pc->gid;
  281. *mode = (*mode & (~07777)) | pc->mode;
  282.  
  283. #if 0
  284. fprintf(stderr,"< '%s' '%s' %d %d %o >\n",
  285. path, pc->prefix ? pc->prefix : "", *uid, *gid, *mode);
  286. #endif
  287. }
  288. #endif
  289. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement