diff options
author | Mark Salyzyn <salyzyn@google.com> | 2015-04-01 07:46:14 -0700 |
---|---|---|
committer | Mark Salyzyn <salyzyn@google.com> | 2015-04-06 15:04:05 -0700 |
commit | 3fe36779efdb4df8b489f6b57a492bcbafb2f211 (patch) | |
tree | 395d325124b283dd908182d1278c0e0c22d45efe /include | |
parent | 3490a395da012117abc4781337ea7b189aa3f0d7 (diff) | |
download | system_core-3fe36779efdb4df8b489f6b57a492bcbafb2f211.zip system_core-3fe36779efdb4df8b489f6b57a492bcbafb2f211.tar.gz system_core-3fe36779efdb4df8b489f6b57a492bcbafb2f211.tar.bz2 |
android_filesystem_config: move fs_config to libcutils
Bug: 19908228
Change-Id: Id51c0c50eb2677824d052882f4263193a08e1402
Diffstat (limited to 'include')
-rw-r--r-- | include/private/android_filesystem_config.h | 137 |
1 files changed, 27 insertions, 110 deletions
diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h index 74e5c82..167f5a1 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,117 +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" }, - { 00700, AID_SYSTEM, AID_SHELL, (1 << CAP_BLOCK_SUSPEND), "system/bin/inputflinger" }, - - { 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 |