Home | History | Annotate | Download | only in private
      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 <sys/cdefs.h>
     26 #include <sys/types.h>
     27 #include <stdint.h>
     28 
     29 #if defined(__ANDROID__)
     30 #include <linux/capability.h>
     31 #else
     32 #include "android_filesystem_capability.h"
     33 #endif
     34 
     35 #define CAP_MASK_LONG(cap_name)  (1ULL << (cap_name))
     36 
     37 /* This is the master Users and Groups config for the platform.
     38  * DO NOT EVER RENUMBER
     39  */
     40 
     41 #define AID_ROOT             0  /* traditional unix root user */
     42 
     43 #define AID_SYSTEM        1000  /* system server */
     44 
     45 #define AID_RADIO         1001  /* telephony subsystem, RIL */
     46 #define AID_BLUETOOTH     1002  /* bluetooth subsystem */
     47 #define AID_GRAPHICS      1003  /* graphics devices */
     48 #define AID_INPUT         1004  /* input devices */
     49 #define AID_AUDIO         1005  /* audio devices */
     50 #define AID_CAMERA        1006  /* camera devices */
     51 #define AID_LOG           1007  /* log devices */
     52 #define AID_COMPASS       1008  /* compass device */
     53 #define AID_MOUNT         1009  /* mountd socket */
     54 #define AID_WIFI          1010  /* wifi subsystem */
     55 #define AID_ADB           1011  /* android debug bridge (adbd) */
     56 #define AID_INSTALL       1012  /* group for installing packages */
     57 #define AID_MEDIA         1013  /* mediaserver process */
     58 #define AID_DHCP          1014  /* dhcp client */
     59 #define AID_SDCARD_RW     1015  /* external storage write access */
     60 #define AID_VPN           1016  /* vpn system */
     61 #define AID_KEYSTORE      1017  /* keystore subsystem */
     62 #define AID_USB           1018  /* USB devices */
     63 #define AID_DRM           1019  /* DRM server */
     64 #define AID_MDNSR         1020  /* MulticastDNSResponder (service discovery) */
     65 #define AID_GPS           1021  /* GPS daemon */
     66 #define AID_UNUSED1       1022  /* deprecated, DO NOT USE */
     67 #define AID_MEDIA_RW      1023  /* internal media storage write access */
     68 #define AID_MTP           1024  /* MTP USB driver access */
     69 #define AID_UNUSED2       1025  /* deprecated, DO NOT USE */
     70 #define AID_DRMRPC        1026  /* group for drm rpc */
     71 #define AID_NFC           1027  /* nfc subsystem */
     72 #define AID_SDCARD_R      1028  /* external storage read access */
     73 #define AID_CLAT          1029  /* clat part of nat464 */
     74 #define AID_LOOP_RADIO    1030  /* loop radio devices */
     75 #define AID_MEDIA_DRM     1031  /* MediaDrm plugins */
     76 #define AID_PACKAGE_INFO  1032  /* access to installed package details */
     77 #define AID_SDCARD_PICS   1033  /* external storage photos access */
     78 #define AID_SDCARD_AV     1034  /* external storage audio/video access */
     79 #define AID_SDCARD_ALL    1035  /* access all users external storage */
     80 #define AID_LOGD          1036  /* log daemon */
     81 #define AID_SHARED_RELRO  1037  /* creator of shared GNU RELRO files */
     82 #define AID_DBUS          1038  /* dbus-daemon IPC broker process */
     83 #define AID_TLSDATE       1039  /* tlsdate unprivileged user */
     84 #define AID_MEDIA_EX      1040  /* mediaextractor process */
     85 #define AID_AUDIOSERVER   1041  /* audioserver process */
     86 #define AID_METRICS_COLL  1042  /* metrics_collector process */
     87 #define AID_METRICSD      1043  /* metricsd process */
     88 #define AID_WEBSERV       1044  /* webservd process */
     89 #define AID_DEBUGGERD     1045  /* debuggerd unprivileged user */
     90 #define AID_MEDIA_CODEC   1046  /* mediacodec process */
     91 #define AID_CAMERASERVER  1047  /* cameraserver process */
     92 #define AID_FIREWALL      1048  /* firewalld process */
     93 #define AID_TRUNKS        1049  /* trunksd process (TPM daemon) */
     94 #define AID_NVRAM         1050  /* Access-controlled NVRAM */
     95 #define AID_DNS           1051  /* DNS resolution daemon (system: netd) */
     96 #define AID_DNS_TETHER    1052  /* DNS resolution daemon (tether: dnsmasq) */
     97 /* Changes to this file must be made in AOSP, *not* in internal branches. */
     98 
     99 #define AID_SHELL         2000  /* adb and debug shell user */
    100 #define AID_CACHE         2001  /* cache access */
    101 #define AID_DIAG          2002  /* access to diagnostic resources */
    102 
    103 /* The range 2900-2999 is reserved for OEM, and must never be
    104  * used here */
    105 #define AID_OEM_RESERVED_START 2900
    106 #define AID_OEM_RESERVED_END   2999
    107 
    108 /* The 3000 series are intended for use as supplemental group id's only.
    109  * They indicate special Android capabilities that the kernel is aware of. */
    110 #define AID_NET_BT_ADMIN  3001  /* bluetooth: create any socket */
    111 #define AID_NET_BT        3002  /* bluetooth: create sco, rfcomm or l2cap sockets */
    112 #define AID_INET          3003  /* can create AF_INET and AF_INET6 sockets */
    113 #define AID_NET_RAW       3004  /* can create raw INET sockets */
    114 #define AID_NET_ADMIN     3005  /* can configure interfaces and routing tables. */
    115 #define AID_NET_BW_STATS  3006  /* read bandwidth statistics */
    116 #define AID_NET_BW_ACCT   3007  /* change bandwidth statistics accounting */
    117 #define AID_NET_BT_STACK  3008  /* bluetooth: access config files */
    118 #define AID_READPROC      3009  /* Allow /proc read access */
    119 #define AID_WAKELOCK      3010  /* Allow system wakelock read/write access */
    120 
    121 /* The range 5000-5999 is also reserved for OEM, and must never be used here. */
    122 #define AID_OEM_RESERVED_2_START 5000
    123 #define AID_OEM_RESERVED_2_END   5999
    124 
    125 #define AID_EVERYBODY     9997  /* shared between all apps in the same profile */
    126 #define AID_MISC          9998  /* access to misc storage */
    127 #define AID_NOBODY        9999
    128 
    129 #define AID_APP          10000  /* first app user */
    130 
    131 #define AID_ISOLATED_START 99000 /* start of uids for fully isolated sandboxed processes */
    132 #define AID_ISOLATED_END   99999 /* end of uids for fully isolated sandboxed processes */
    133 
    134 #define AID_USER        100000  /* offset for uid ranges for each user */
    135 
    136 #define AID_SHARED_GID_START 50000 /* start of gids for apps in each user to share */
    137 #define AID_SHARED_GID_END   59999 /* start of gids for apps in each user to share */
    138 
    139 #if !defined(EXCLUDE_FS_CONFIG_STRUCTURES)
    140 /*
    141  * Used in:
    142  *  bionic/libc/bionic/stubs.cpp
    143  *  external/libselinux/src/android.c
    144  *  system/core/logd/LogStatistics.cpp
    145  *  system/core/init/ueventd.cpp
    146  *  system/core/init/util.cpp
    147  */
    148 struct android_id_info {
    149     const char *name;
    150     unsigned aid;
    151 };
    152 
    153 static const struct android_id_info android_ids[] = {
    154     { "root",          AID_ROOT, },
    155 
    156     { "system",        AID_SYSTEM, },
    157 
    158     { "radio",         AID_RADIO, },
    159     { "bluetooth",     AID_BLUETOOTH, },
    160     { "graphics",      AID_GRAPHICS, },
    161     { "input",         AID_INPUT, },
    162     { "audio",         AID_AUDIO, },
    163     { "camera",        AID_CAMERA, },
    164     { "log",           AID_LOG, },
    165     { "compass",       AID_COMPASS, },
    166     { "mount",         AID_MOUNT, },
    167     { "wifi",          AID_WIFI, },
    168     { "adb",           AID_ADB, },
    169     { "install",       AID_INSTALL, },
    170     { "media",         AID_MEDIA, },
    171     { "dhcp",          AID_DHCP, },
    172     { "sdcard_rw",     AID_SDCARD_RW, },
    173     { "vpn",           AID_VPN, },
    174     { "keystore",      AID_KEYSTORE, },
    175     { "usb",           AID_USB, },
    176     { "drm",           AID_DRM, },
    177     { "mdnsr",         AID_MDNSR, },
    178     { "gps",           AID_GPS, },
    179     // AID_UNUSED1
    180     { "media_rw",      AID_MEDIA_RW, },
    181     { "mtp",           AID_MTP, },
    182     // AID_UNUSED2
    183     { "drmrpc",        AID_DRMRPC, },
    184     { "nfc",           AID_NFC, },
    185     { "sdcard_r",      AID_SDCARD_R, },
    186     { "clat",          AID_CLAT, },
    187     { "loop_radio",    AID_LOOP_RADIO, },
    188     { "mediadrm",      AID_MEDIA_DRM, },
    189     { "package_info",  AID_PACKAGE_INFO, },
    190     { "sdcard_pics",   AID_SDCARD_PICS, },
    191     { "sdcard_av",     AID_SDCARD_AV, },
    192     { "sdcard_all",    AID_SDCARD_ALL, },
    193     { "logd",          AID_LOGD, },
    194     { "shared_relro",  AID_SHARED_RELRO, },
    195     { "dbus",          AID_DBUS, },
    196     { "tlsdate",       AID_TLSDATE, },
    197     { "mediaex",       AID_MEDIA_EX, },
    198     { "audioserver",   AID_AUDIOSERVER, },
    199     { "metrics_coll",  AID_METRICS_COLL },
    200     { "metricsd",      AID_METRICSD },
    201     { "webserv",       AID_WEBSERV },
    202     { "debuggerd",     AID_DEBUGGERD, },
    203     { "mediacodec",    AID_MEDIA_CODEC, },
    204     { "cameraserver",  AID_CAMERASERVER, },
    205     { "firewall",      AID_FIREWALL, },
    206     { "trunks",        AID_TRUNKS, },
    207     { "nvram",         AID_NVRAM, },
    208     { "dns",           AID_DNS, },
    209     { "dns_tether",    AID_DNS_TETHER, },
    210 
    211     { "shell",         AID_SHELL, },
    212     { "cache",         AID_CACHE, },
    213     { "diag",          AID_DIAG, },
    214 
    215     { "net_bt_admin",  AID_NET_BT_ADMIN, },
    216     { "net_bt",        AID_NET_BT, },
    217     { "inet",          AID_INET, },
    218     { "net_raw",       AID_NET_RAW, },
    219     { "net_admin",     AID_NET_ADMIN, },
    220     { "net_bw_stats",  AID_NET_BW_STATS, },
    221     { "net_bw_acct",   AID_NET_BW_ACCT, },
    222     { "net_bt_stack",  AID_NET_BT_STACK, },
    223     { "readproc",      AID_READPROC, },
    224     { "wakelock",      AID_WAKELOCK, },
    225 
    226     { "everybody",     AID_EVERYBODY, },
    227     { "misc",          AID_MISC, },
    228     { "nobody",        AID_NOBODY, },
    229 };
    230 
    231 #define android_id_count \
    232     (sizeof(android_ids) / sizeof(android_ids[0]))
    233 
    234 struct fs_path_config {
    235     unsigned mode;
    236     unsigned uid;
    237     unsigned gid;
    238     uint64_t capabilities;
    239     const char *prefix;
    240 };
    241 
    242 /* Rules for directories and files has moved to system/code/libcutils/fs_config.c */
    243 
    244 __BEGIN_DECLS
    245 
    246 /*
    247  * Used in:
    248  *  build/tools/fs_config/fs_config.c
    249  *  build/tools/fs_get_stats/fs_get_stats.c
    250  *  system/extras/ext4_utils/make_ext4fs_main.c
    251  *  external/squashfs-tools/squashfs-tools/android.c
    252  *  system/core/cpio/mkbootfs.c
    253  *  system/core/adb/file_sync_service.cpp
    254  *  system/extras/ext4_utils/canned_fs_config.c
    255  */
    256 void fs_config(const char *path, int dir, const char *target_out_path,
    257                unsigned *uid, unsigned *gid, unsigned *mode, uint64_t *capabilities);
    258 
    259 ssize_t fs_config_generate(char *buffer, size_t length, const struct fs_path_config *pc);
    260 
    261 __END_DECLS
    262 
    263 #endif
    264 #endif
    265