summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2017-05-19 09:35:34 -0500
committerandroid-build-merger2017-05-19 09:35:34 -0500
commit645d62facbe00fa255b6b21da4acca269579ea0e (patch)
treeb27d04a38eacbc1416d3d09bd38d1bb5a6fa8713 /libcutils/fs_config.cpp
parent69b7fdaa173a881fbc69348f27c5bfa19b23c64c (diff)
parent7c466b936ab6b24aff9fcb5bee3e12a09fc59471 (diff)
downloadplatform-system-core-645d62facbe00fa255b6b21da4acca269579ea0e.tar.gz
platform-system-core-645d62facbe00fa255b6b21da4acca269579ea0e.tar.xz
platform-system-core-645d62facbe00fa255b6b21da4acca269579ea0e.zip
Merge changes Iad6ba65e,Ia6a7e8c9,Ida9405cb am: 037d2b71dc am: 219e7200be
am: 7c466b936a Change-Id: I9da0e906b391b9e4846c534eda77fb33d96e191a
Diffstat (limited to 'libcutils/fs_config.cpp')
-rw-r--r--libcutils/fs_config.cpp49
1 files changed, 32 insertions, 17 deletions
diff --git a/libcutils/fs_config.cpp b/libcutils/fs_config.cpp
index ea99595f4..40d3476ae 100644
--- a/libcutils/fs_config.cpp
+++ b/libcutils/fs_config.cpp
@@ -139,14 +139,8 @@ static const struct fs_path_config android_files[] = {
139 { 00600, AID_ROOT, AID_ROOT, 0, "odm/default.prop" }, 139 { 00600, AID_ROOT, AID_ROOT, 0, "odm/default.prop" },
140 { 00444, AID_ROOT, AID_ROOT, 0, odm_conf_dir + 1 }, 140 { 00444, AID_ROOT, AID_ROOT, 0, odm_conf_dir + 1 },
141 { 00444, AID_ROOT, AID_ROOT, 0, odm_conf_file + 1 }, 141 { 00444, AID_ROOT, AID_ROOT, 0, odm_conf_file + 1 },
142 { 00600, AID_ROOT, AID_ROOT, 0, "system/odm/build.prop" },
143 { 00600, AID_ROOT, AID_ROOT, 0, "system/odm/default.prop" },
144 { 00444, AID_ROOT, AID_ROOT, 0, "system/odm/etc/fs_config_dirs" },
145 { 00444, AID_ROOT, AID_ROOT, 0, "system/odm/etc/fs_config_files" },
146 { 00444, AID_ROOT, AID_ROOT, 0, oem_conf_dir + 1 }, 142 { 00444, AID_ROOT, AID_ROOT, 0, oem_conf_dir + 1 },
147 { 00444, AID_ROOT, AID_ROOT, 0, oem_conf_file + 1 }, 143 { 00444, AID_ROOT, AID_ROOT, 0, oem_conf_file + 1 },
148 { 00444, AID_ROOT, AID_ROOT, 0, "system/oem/etc/fs_config_dirs" },
149 { 00444, AID_ROOT, AID_ROOT, 0, "system/oem/etc/fs_config_files" },
150 { 00750, AID_ROOT, AID_SHELL, 0, "sbin/fs_mgr" }, 144 { 00750, AID_ROOT, AID_SHELL, 0, "sbin/fs_mgr" },
151 { 00755, AID_ROOT, AID_SHELL, 0, "system/bin/crash_dump32" }, 145 { 00755, AID_ROOT, AID_SHELL, 0, "system/bin/crash_dump32" },
152 { 00755, AID_ROOT, AID_SHELL, 0, "system/bin/crash_dump64" }, 146 { 00755, AID_ROOT, AID_SHELL, 0, "system/bin/crash_dump64" },
@@ -163,10 +157,6 @@ static const struct fs_path_config android_files[] = {
163 { 00555, AID_ROOT, AID_ROOT, 0, "system/etc/ppp/*" }, 157 { 00555, AID_ROOT, AID_ROOT, 0, "system/etc/ppp/*" },
164 { 00555, AID_ROOT, AID_ROOT, 0, "system/etc/rc.*" }, 158 { 00555, AID_ROOT, AID_ROOT, 0, "system/etc/rc.*" },
165 { 00440, AID_ROOT, AID_ROOT, 0, "system/etc/recovery.img" }, 159 { 00440, AID_ROOT, AID_ROOT, 0, "system/etc/recovery.img" },
166 { 00600, AID_ROOT, AID_ROOT, 0, "system/vendor/build.prop" },
167 { 00600, AID_ROOT, AID_ROOT, 0, "system/vendor/default.prop" },
168 { 00444, AID_ROOT, AID_ROOT, 0, "system/vendor/etc/fs_config_dirs" },
169 { 00444, AID_ROOT, AID_ROOT, 0, "system/vendor/etc/fs_config_files" },
170 { 00600, AID_ROOT, AID_ROOT, 0, "vendor/build.prop" }, 160 { 00600, AID_ROOT, AID_ROOT, 0, "vendor/build.prop" },
171 { 00600, AID_ROOT, AID_ROOT, 0, "vendor/default.prop" }, 161 { 00600, AID_ROOT, AID_ROOT, 0, "vendor/default.prop" },
172 { 00444, AID_ROOT, AID_ROOT, 0, ven_conf_dir + 1 }, 162 { 00444, AID_ROOT, AID_ROOT, 0, ven_conf_dir + 1 },
@@ -205,9 +195,6 @@ static const struct fs_path_config android_files[] = {
205 // Support RT scheduling in Bluetooth 195 // Support RT scheduling in Bluetooth
206 { 00700, AID_BLUETOOTH, AID_BLUETOOTH, CAP_MASK_LONG(CAP_NET_ADMIN) | 196 { 00700, AID_BLUETOOTH, AID_BLUETOOTH, CAP_MASK_LONG(CAP_NET_ADMIN) |
207 CAP_MASK_LONG(CAP_SYS_NICE), 197 CAP_MASK_LONG(CAP_SYS_NICE),
208 "system/vendor/bin/hw/android.hardware.bluetooth@1.0-service" },
209 { 00700, AID_BLUETOOTH, AID_BLUETOOTH, CAP_MASK_LONG(CAP_NET_ADMIN) |
210 CAP_MASK_LONG(CAP_SYS_NICE),
211 "vendor/bin/hw/android.hardware.bluetooth@1.0-service" }, 198 "vendor/bin/hw/android.hardware.bluetooth@1.0-service" },
212 199
213 // Support wifi_hal_legacy administering a network interface. 200 // Support wifi_hal_legacy administering a network interface.
@@ -233,8 +220,6 @@ static const struct fs_path_config android_files[] = {
233 { 00755, AID_ROOT, AID_SHELL, 0, "system/bin/*" }, 220 { 00755, AID_ROOT, AID_SHELL, 0, "system/bin/*" },
234 { 00755, AID_ROOT, AID_ROOT, 0, "system/lib/valgrind/*" }, 221 { 00755, AID_ROOT, AID_ROOT, 0, "system/lib/valgrind/*" },
235 { 00755, AID_ROOT, AID_ROOT, 0, "system/lib64/valgrind/*" }, 222 { 00755, AID_ROOT, AID_ROOT, 0, "system/lib64/valgrind/*" },
236 { 00755, AID_ROOT, AID_SHELL, 0, "system/vendor/bin/*" },
237 { 00755, AID_ROOT, AID_SHELL, 0, "system/vendor/xbin/*" },
238 { 00755, AID_ROOT, AID_SHELL, 0, "system/xbin/*" }, 223 { 00755, AID_ROOT, AID_SHELL, 0, "system/xbin/*" },
239 { 00755, AID_ROOT, AID_SHELL, 0, "vendor/bin/*" }, 224 { 00755, AID_ROOT, AID_SHELL, 0, "vendor/bin/*" },
240 { 00755, AID_ROOT, AID_SHELL, 0, "vendor/xbin/*" }, 225 { 00755, AID_ROOT, AID_SHELL, 0, "vendor/xbin/*" },
@@ -273,6 +258,36 @@ static int fs_config_open(int dir, int which, const char* target_out_path) {
273 return fd; 258 return fd;
274} 259}
275 260
261// if path is "vendor/<stuff>", "oem/<stuff>" or "odm/<stuff>"
262static bool is_partition(const char* path, size_t len) {
263 static const char* partitions[] = {"vendor/", "oem/", "odm/"};
264 for (size_t i = 0; i < (sizeof(partitions) / sizeof(partitions[0])); ++i) {
265 size_t plen = strlen(partitions[i]);
266 if (len <= plen) continue;
267 if (!strncmp(path, partitions[i], plen)) return true;
268 }
269 return false;
270}
271
272// alias prefixes of "<partition>/<stuff>" to "system/<partition>/<stuff>" or
273// "system/<partition>/<stuff>" to "<partition>/<stuff>"
274static bool prefix_cmp(const char* prefix, const char* path, size_t len) {
275 if (!strncmp(prefix, path, len)) return true;
276
277 static const char system[] = "system/";
278 if (!strncmp(path, system, strlen(system))) {
279 path += strlen(system);
280 } else if (len <= strlen(system)) {
281 return false;
282 } else if (strncmp(prefix, system, strlen(system))) {
283 return false;
284 } else {
285 prefix += strlen(system);
286 len -= strlen(system);
287 }
288 return is_partition(prefix, len) && !strncmp(prefix, path, len);
289}
290
276static bool fs_config_cmp(bool dir, const char* prefix, size_t len, const char* path, size_t plen) { 291static bool fs_config_cmp(bool dir, const char* prefix, size_t len, const char* path, size_t plen) {
277 if (dir) { 292 if (dir) {
278 if (plen < len) { 293 if (plen < len) {
@@ -281,13 +296,13 @@ static bool fs_config_cmp(bool dir, const char* prefix, size_t len, const char*
281 } else { 296 } else {
282 // If name ends in * then allow partial matches. 297 // If name ends in * then allow partial matches.
283 if (prefix[len - 1] == '*') { 298 if (prefix[len - 1] == '*') {
284 return !strncmp(prefix, path, len - 1); 299 return prefix_cmp(prefix, path, len - 1);
285 } 300 }
286 if (plen != len) { 301 if (plen != len) {
287 return false; 302 return false;
288 } 303 }
289 } 304 }
290 return !strncmp(prefix, path, len); 305 return prefix_cmp(prefix, path, len);
291} 306}
292 307
293void fs_config(const char* path, int dir, const char* target_out_path, unsigned* uid, unsigned* gid, 308void fs_config(const char* path, int dir, const char* target_out_path, unsigned* uid, unsigned* gid,