blob: 87eaf091be34d25e0bb40adf7e36d7b852a80c73 [file] [log] [blame]
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08001/*
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 */
San Mehat6e1f2152009-04-23 09:15:08 -070051#define AID_SDCARD_RW 1015 /* external storage write access */
San Mehat4a6f2322009-05-14 19:44:59 -070052#define AID_VPN 1016 /* vpn system */
Chung-yih Wang1f75d702009-06-01 19:04:05 +080053#define AID_KEYSTORE 1017 /* keystore subsystem */
Mike Lockwood93ac1552010-05-06 13:30:09 -040054#define AID_USB 1018 /* USB devices */
aimitakeshie572d592010-07-27 08:38:35 +090055#define AID_DRM 1019 /* DRM server */
56#define AID_DRMIO 1020 /* DRM IO server */
Mike Lockwoodc29919c2010-09-27 08:01:58 -040057#define AID_GPS 1021 /* GPS daemon */
Nick Pelly85905a62010-10-14 23:30:51 -070058#define AID_NFC 1022 /* nfc subsystem */
Mike Lockwood2e0047b2010-10-29 10:55:54 -040059#define AID_MEDIA_RW 1023 /* internal media storage write access */
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080060
61#define AID_SHELL 2000 /* adb and debug shell user */
62#define AID_CACHE 2001 /* cache access */
63#define AID_DIAG 2002 /* access to diagnostic resources */
64
65/* The 3000 series are intended for use as supplemental group id's only.
66 * They indicate special Android capabilities that the kernel is aware of. */
67#define AID_NET_BT_ADMIN 3001 /* bluetooth: create any socket */
68#define AID_NET_BT 3002 /* bluetooth: create sco, rfcomm or l2cap sockets */
69#define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */
70#define AID_NET_RAW 3004 /* can create raw INET sockets */
Chia-chi Yeh88dc6572009-06-19 14:59:08 +080071#define AID_NET_ADMIN 3005 /* can configure interfaces and routing tables. */
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080072
73#define AID_MISC 9998 /* access to misc storage */
74#define AID_NOBODY 9999
75
76#define AID_APP 10000 /* first app user */
77
78#if !defined(EXCLUDE_FS_CONFIG_STRUCTURES)
79struct android_id_info {
80 const char *name;
81 unsigned aid;
82};
83
Nick Kralevich4688ac52010-08-31 09:44:43 -070084static const struct android_id_info android_ids[] = {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080085 { "root", AID_ROOT, },
86 { "system", AID_SYSTEM, },
87 { "radio", AID_RADIO, },
88 { "bluetooth", AID_BLUETOOTH, },
89 { "graphics", AID_GRAPHICS, },
90 { "input", AID_INPUT, },
91 { "audio", AID_AUDIO, },
92 { "camera", AID_CAMERA, },
93 { "log", AID_LOG, },
94 { "compass", AID_COMPASS, },
95 { "mount", AID_MOUNT, },
96 { "wifi", AID_WIFI, },
97 { "dhcp", AID_DHCP, },
98 { "adb", AID_ADB, },
99 { "install", AID_INSTALL, },
100 { "media", AID_MEDIA, },
aimitakeshie572d592010-07-27 08:38:35 +0900101 { "drm", AID_DRM, },
102 { "drmio", AID_DRMIO, },
Nick Pelly85905a62010-10-14 23:30:51 -0700103 { "nfc", AID_NFC, },
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800104 { "shell", AID_SHELL, },
105 { "cache", AID_CACHE, },
106 { "diag", AID_DIAG, },
107 { "net_bt_admin", AID_NET_BT_ADMIN, },
108 { "net_bt", AID_NET_BT, },
San Mehat6e1f2152009-04-23 09:15:08 -0700109 { "sdcard_rw", AID_SDCARD_RW, },
Mike Lockwood2e0047b2010-10-29 10:55:54 -0400110 { "media_rw", AID_MEDIA_RW, },
San Mehat4a6f2322009-05-14 19:44:59 -0700111 { "vpn", AID_VPN, },
Chung-yih Wang1f75d702009-06-01 19:04:05 +0800112 { "keystore", AID_KEYSTORE, },
Mike Lockwood93ac1552010-05-06 13:30:09 -0400113 { "usb", AID_USB, },
Mike Lockwoodc29919c2010-09-27 08:01:58 -0400114 { "gps", AID_GPS, },
Chung-yih Wang1f75d702009-06-01 19:04:05 +0800115 { "inet", AID_INET, },
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800116 { "net_raw", AID_NET_RAW, },
Chia-chi Yeh88dc6572009-06-19 14:59:08 +0800117 { "net_admin", AID_NET_ADMIN, },
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800118 { "misc", AID_MISC, },
119 { "nobody", AID_NOBODY, },
120};
121
122#define android_id_count \
123 (sizeof(android_ids) / sizeof(android_ids[0]))
124
125struct fs_path_config {
126 unsigned mode;
127 unsigned uid;
128 unsigned gid;
129 const char *prefix;
130};
131
132/* Rules for directories.
133** These rules are applied based on "first match", so they
134** should start with the most specific path and work their
135** way up to the root.
136*/
137
138static struct fs_path_config android_dirs[] = {
139 { 00770, AID_SYSTEM, AID_CACHE, "cache" },
140 { 00771, AID_SYSTEM, AID_SYSTEM, "data/app" },
141 { 00771, AID_SYSTEM, AID_SYSTEM, "data/app-private" },
142 { 00771, AID_SYSTEM, AID_SYSTEM, "data/dalvik-cache" },
143 { 00771, AID_SYSTEM, AID_SYSTEM, "data/data" },
144 { 00771, AID_SHELL, AID_SHELL, "data/local/tmp" },
145 { 00771, AID_SHELL, AID_SHELL, "data/local" },
146 { 01771, AID_SYSTEM, AID_MISC, "data/misc" },
147 { 00770, AID_DHCP, AID_DHCP, "data/misc/dhcp" },
148 { 00771, AID_SYSTEM, AID_SYSTEM, "data" },
149 { 00750, AID_ROOT, AID_SHELL, "sbin" },
150 { 00755, AID_ROOT, AID_SHELL, "system/bin" },
Brian Swetland02863b92010-09-19 03:36:39 -0700151 { 00755, AID_ROOT, AID_SHELL, "system/vendor" },
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800152 { 00755, AID_ROOT, AID_SHELL, "system/xbin" },
Chia-chi Yeh88dc6572009-06-19 14:59:08 +0800153 { 00755, AID_ROOT, AID_ROOT, "system/etc/ppp" },
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800154 { 00777, AID_ROOT, AID_ROOT, "sdcard" },
155 { 00755, AID_ROOT, AID_ROOT, 0 },
156};
157
158/* Rules for files.
159** These rules are applied based on "first match", so they
160** should start with the most specific path and work their
161** way up to the root. Prefixes ending in * denotes wildcard
162** and will allow partial matches.
163*/
164static struct fs_path_config android_files[] = {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800165 { 00440, AID_ROOT, AID_SHELL, "system/etc/init.goldfish.rc" },
166 { 00550, AID_ROOT, AID_SHELL, "system/etc/init.goldfish.sh" },
167 { 00440, AID_ROOT, AID_SHELL, "system/etc/init.trout.rc" },
168 { 00550, AID_ROOT, AID_SHELL, "system/etc/init.ril" },
169 { 00550, AID_ROOT, AID_SHELL, "system/etc/init.testmenu" },
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800170 { 00550, AID_DHCP, AID_SHELL, "system/etc/dhcpcd/dhcpcd-run-hooks" },
171 { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/dbus.conf" },
Jaikumar Ganesheafdd862010-01-07 20:24:55 -0800172 { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/bluetooth/main.conf" },
173 { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/bluetooth/input.conf" },
174 { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/bluetooth/audio.conf" },
Danica Chang78fdd232010-08-12 15:42:30 -0700175 { 00440, AID_BLUETOOTH, AID_BLUETOOTH, "system/etc/bluetooth/network.conf" },
Eric Olsen35550192010-03-16 10:22:06 -0700176 { 00444, AID_NET_BT, AID_NET_BT, "system/etc/bluetooth/blacklist.conf" },
Jaikumar Ganesheafdd862010-01-07 20:24:55 -0800177 { 00640, AID_SYSTEM, AID_SYSTEM, "system/etc/bluetooth/auto_pairing.conf" },
Jean-Baptiste Querub0849292009-10-02 11:08:55 -0700178 { 00444, AID_RADIO, AID_AUDIO, "system/etc/AudioPara4.csv" },
Chia-chi Yeh88dc6572009-06-19 14:59:08 +0800179 { 00555, AID_ROOT, AID_ROOT, "system/etc/ppp/*" },
Bruce Beare96a2bb62010-06-24 14:36:38 -0700180 { 00555, AID_ROOT, AID_ROOT, "system/etc/rc.*" },
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800181 { 00644, AID_SYSTEM, AID_SYSTEM, "data/app/*" },
182 { 00644, AID_SYSTEM, AID_SYSTEM, "data/app-private/*" },
183 { 00644, AID_APP, AID_APP, "data/data/*" },
184 /* the following two files are INTENTIONALLY set-gid and not set-uid.
185 * Do not change. */
186 { 02755, AID_ROOT, AID_NET_RAW, "system/bin/ping" },
Nick Kralevich3e1aac62010-03-08 11:36:10 -0800187 { 02750, AID_ROOT, AID_INET, "system/bin/netcfg" },
David 'Digit' Turner1f4d9522010-03-02 18:05:23 -0800188 /* the following five files are INTENTIONALLY set-uid, but they
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800189 * are NOT included on user builds. */
190 { 06755, AID_ROOT, AID_ROOT, "system/xbin/su" },
191 { 06755, AID_ROOT, AID_ROOT, "system/xbin/librank" },
192 { 06755, AID_ROOT, AID_ROOT, "system/xbin/procrank" },
193 { 06755, AID_ROOT, AID_ROOT, "system/xbin/procmem" },
Dan Egnor328a4fb2009-05-15 12:57:58 -0700194 { 06755, AID_ROOT, AID_ROOT, "system/xbin/tcpdump" },
Wink Savillebbf1c642010-03-11 16:22:44 -0800195 { 04770, AID_ROOT, AID_RADIO, "system/bin/pppd-ril" },
David 'Digit' Turner1f4d9522010-03-02 18:05:23 -0800196 /* the following file is INTENTIONALLY set-uid, and IS included
197 * in user builds. */
198 { 06750, AID_ROOT, AID_SHELL, "system/bin/run-as" },
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800199 { 00755, AID_ROOT, AID_SHELL, "system/bin/*" },
200 { 00755, AID_ROOT, AID_SHELL, "system/xbin/*" },
Brian Swetland02863b92010-09-19 03:36:39 -0700201 { 00755, AID_ROOT, AID_SHELL, "system/vendor/bin/*" },
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800202 { 00750, AID_ROOT, AID_SHELL, "sbin/*" },
203 { 00755, AID_ROOT, AID_ROOT, "bin/*" },
204 { 00750, AID_ROOT, AID_SHELL, "init*" },
205 { 00644, AID_ROOT, AID_ROOT, 0 },
206};
207
208static inline void fs_config(const char *path, int dir,
209 unsigned *uid, unsigned *gid, unsigned *mode)
210{
211 struct fs_path_config *pc;
212 int plen;
213
214 pc = dir ? android_dirs : android_files;
215 plen = strlen(path);
216 for(; pc->prefix; pc++){
217 int len = strlen(pc->prefix);
218 if (dir) {
219 if(plen < len) continue;
220 if(!strncmp(pc->prefix, path, len)) break;
221 continue;
222 }
223 /* If name ends in * then allow partial matches. */
224 if (pc->prefix[len -1] == '*') {
225 if(!strncmp(pc->prefix, path, len - 1)) break;
226 } else if (plen == len){
227 if(!strncmp(pc->prefix, path, len)) break;
228 }
229 }
230 *uid = pc->uid;
231 *gid = pc->gid;
232 *mode = (*mode & (~07777)) | pc->mode;
233
234#if 0
235 fprintf(stderr,"< '%s' '%s' %d %d %o >\n",
236 path, pc->prefix ? pc->prefix : "", *uid, *gid, *mode);
237#endif
238}
239#endif
240#endif