summaryrefslogtreecommitdiff
path: root/include/private/android_filesystem_config.h
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2015-04-01 07:46:14 -0700
committerMark Salyzyn <salyzyn@google.com>2015-04-06 10:04:16 -0700
commita21c29ee818515d5cde79a01bee86c1e27057096 (patch)
treeb169afae34e9cec6882c2fe6eba9c656245099f5 /include/private/android_filesystem_config.h
parent8b2c7dee59f0ca89e6a0866537054a0d41dbae97 (diff)
android_filesystem_config: move fs_config to libcutils
Bug: 19908228 Change-Id: Id51c0c50eb2677824d052882f4263193a08e1402
Diffstat (limited to 'include/private/android_filesystem_config.h')
-rw-r--r--include/private/android_filesystem_config.h136
1 files changed, 27 insertions, 109 deletions
diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h
index a3d11a787..167f5a10b 100644
--- a/include/private/android_filesystem_config.h
+++ b/include/private/android_filesystem_config.h
@@ -22,8 +22,6 @@
#ifndef _ANDROID_FILESYSTEM_CONFIG_H_
#define _ANDROID_FILESYSTEM_CONFIG_H_
-#include <string.h>
-#include <sys/stat.h>
#include <sys/types.h>
#include <stdint.h>
@@ -114,6 +112,14 @@
#define AID_SHARED_GID_END 59999 /* start of gids for apps in each user to share */
#if !defined(EXCLUDE_FS_CONFIG_STRUCTURES)
+/*
+ * Used in:
+ * bionic/libc/bionic/stubs.cpp
+ * external/libselinux/src/android.c
+ * system/core/logd/LogStatistics.cpp
+ * system/core/init/ueventd.cpp
+ * system/core/init/util.cpp
+ */
struct android_id_info {
const char *name;
unsigned aid;
@@ -191,116 +197,28 @@ struct fs_path_config {
const char *prefix;
};
-/* Rules for directories.
-** These rules are applied based on "first match", so they
-** should start with the most specific path and work their
-** way up to the root.
-*/
-
-static const struct fs_path_config android_dirs[] = {
- { 00770, AID_SYSTEM, AID_CACHE, 0, "cache" },
- { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app" },
- { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app-private" },
- { 00771, AID_ROOT, AID_ROOT, 0, "data/dalvik-cache" },
- { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/data" },
- { 00771, AID_SHELL, AID_SHELL, 0, "data/local/tmp" },
- { 00771, AID_SHELL, AID_SHELL, 0, "data/local" },
- { 01771, AID_SYSTEM, AID_MISC, 0, "data/misc" },
- { 00770, AID_DHCP, AID_DHCP, 0, "data/misc/dhcp" },
- { 00771, AID_SHARED_RELRO, AID_SHARED_RELRO, 0, "data/misc/shared_relro" },
- { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media" },
- { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media/Music" },
- { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data" },
- { 00750, AID_ROOT, AID_SHELL, 0, "sbin" },
- { 00755, AID_ROOT, AID_SHELL, 0, "system/bin" },
- { 00755, AID_ROOT, AID_SHELL, 0, "system/vendor" },
- { 00755, AID_ROOT, AID_SHELL, 0, "system/xbin" },
- { 00755, AID_ROOT, AID_ROOT, 0, "system/etc/ppp" },
- { 00755, AID_ROOT, AID_SHELL, 0, "vendor" },
- { 00777, AID_ROOT, AID_ROOT, 0, "sdcard" },
- { 00755, AID_ROOT, AID_ROOT, 0, 0 },
-};
-
-/* Rules for files.
-** These rules are applied based on "first match", so they
-** should start with the most specific path and work their
-** way up to the root. Prefixes ending in * denotes wildcard
-** and will allow partial matches.
-*/
-static const struct fs_path_config android_files[] = {
- { 00440, AID_ROOT, AID_SHELL, 0, "system/etc/init.goldfish.rc" },
- { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.goldfish.sh" },
- { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.ril" },
- { 00550, AID_DHCP, AID_SHELL, 0, "system/etc/dhcpcd/dhcpcd-run-hooks" },
- { 00555, AID_ROOT, AID_ROOT, 0, "system/etc/ppp/*" },
- { 00555, AID_ROOT, AID_ROOT, 0, "system/etc/rc.*" },
- { 00644, AID_SYSTEM, AID_SYSTEM, 0, "data/app/*" },
- { 00644, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media/*" },
- { 00644, AID_SYSTEM, AID_SYSTEM, 0, "data/app-private/*" },
- { 00644, AID_APP, AID_APP, 0, "data/data/*" },
-
- /* the following five files are INTENTIONALLY set-uid, but they
- * are NOT included on user builds. */
- { 04750, AID_ROOT, AID_SHELL, 0, "system/xbin/su" },
- { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/librank" },
- { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/procrank" },
- { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/procmem" },
- { 04770, AID_ROOT, AID_RADIO, 0, "system/bin/pppd-ril" },
-
- /* the following files have enhanced capabilities and ARE included in user builds. */
- { 00750, AID_ROOT, AID_SHELL, (1 << CAP_SETUID) | (1 << CAP_SETGID), "system/bin/run-as" },
-
- { 00750, AID_ROOT, AID_ROOT, 0, "system/bin/uncrypt" },
- { 00750, AID_ROOT, AID_ROOT, 0, "system/bin/install-recovery.sh" },
- { 00755, AID_ROOT, AID_SHELL, 0, "system/bin/*" },
- { 00755, AID_ROOT, AID_ROOT, 0, "system/lib/valgrind/*" },
- { 00755, AID_ROOT, AID_ROOT, 0, "system/lib64/valgrind/*" },
- { 00755, AID_ROOT, AID_SHELL, 0, "system/xbin/*" },
- { 00755, AID_ROOT, AID_SHELL, 0, "system/vendor/bin/*" },
- { 00755, AID_ROOT, AID_SHELL, 0, "vendor/bin/*" },
- { 00750, AID_ROOT, AID_SHELL, 0, "sbin/*" },
- { 00755, AID_ROOT, AID_ROOT, 0, "bin/*" },
- { 00750, AID_ROOT, AID_SHELL, 0, "init*" },
- { 00750, AID_ROOT, AID_SHELL, 0, "sbin/fs_mgr" },
- { 00640, AID_ROOT, AID_SHELL, 0, "fstab.*" },
- { 00644, AID_ROOT, AID_ROOT, 0, 0 },
-};
-
-static inline void fs_config(const char *path, int dir,
- unsigned *uid, unsigned *gid, unsigned *mode, uint64_t *capabilities)
-{
- const struct fs_path_config *pc;
- int plen;
+/* Rules for directories and files has moved to system/code/libcutils/fs_config.c */
- if (path[0] == '/') {
- path++;
- }
+#ifdef __cplusplus
+extern "C" {
+#endif
- pc = dir ? android_dirs : android_files;
- plen = strlen(path);
- for(; pc->prefix; pc++){
- int len = strlen(pc->prefix);
- if (dir) {
- if(plen < len) continue;
- if(!strncmp(pc->prefix, path, len)) break;
- continue;
- }
- /* If name ends in * then allow partial matches. */
- if (pc->prefix[len -1] == '*') {
- if(!strncmp(pc->prefix, path, len - 1)) break;
- } else if (plen == len){
- if(!strncmp(pc->prefix, path, len)) break;
- }
- }
- *uid = pc->uid;
- *gid = pc->gid;
- *mode = (*mode & (~07777)) | pc->mode;
- *capabilities = pc->capabilities;
+/*
+ * Used in:
+ * build/tools/fs_config/fs_config.c
+ * build/tools/fs_get_stats/fs_get_stats.c
+ * external/genext2fs/genext2fs.c
+ * external/squashfs-tools/squashfs-tools/android.c
+ * system/core/cpio/mkbootfs.c
+ * system/core/adb/file_sync_service.cpp
+ * system/extras/ext4_utils/canned_fs_config.c
+ */
+void fs_config(const char *path, int dir,
+ unsigned *uid, unsigned *gid, unsigned *mode, uint64_t *capabilities);
-#if 0
- fprintf(stderr,"< '%s' '%s' %d %d %o >\n",
- path, pc->prefix ? pc->prefix : "", *uid, *gid, *mode);
-#endif
+#ifdef __cplusplus
}
#endif
+
+#endif
#endif