Android 安全机制2 沙箱机制

本文详细介绍了Android的沙箱机制,包括Android ID映射表(AID)、应用程序UID的概念,以及如何通过UID来保护文件资源的流程,旨在深入理解Android系统的安全措施。
摘要由CSDN通过智能技术生成

2 Android 沙箱机制



Android 沙箱实现了应用程序的相互隔离,用于对文件系统的实体访问进行控制,也可以对其他Android系统资源进行访问控制。
简单的说,每个应用程序无法访问其他应用程序的资源。沙箱系统的原理主要基于Linux系统的UID/GID机制。Android对传统的
Linux的UID/GID机制进行了修改。在 Linux 中,一个用户 ID 识别一个给定用户;在 Android 上,一个用户 ID 识别一个应用程序。
应用程序在安装时被分配用户 ID,应用程序在设备上的存续期间内,用户 ID 保持不变。权限是关于允许或限制应用程序(而不是用户)访问设备资源。



2.1 Android ID 映射表(AID) 

Android 系统沿用了Linux系统的UID/GID(用户组ID)的权限模型,但是并没有使用Linux传统的passwd和group文件来存储用户与用户组的
凭证信息,作为替代,Android定义了从名称到独特标识符的Android ID(AID)映射表。初始的映射表中定义了一些特权用户和一些系统关
键用户。并且保留了一段AID范围,用于提供给原生应用作为UID。
下面是从源码中截取的预定义的系统特权用户和用户组:(system/core/include/private/android_filesystem_config.h)
/* This is the master Users and Groups config for the platform.
 * DO NOT EVER RENUMBER
 */


#define AID_ROOT             0  /* traditional unix root user */


#define AID_SYSTEM        1000  /* system server */


#define AID_RADIO         1001  /* telephony subsystem, RIL */
#define AID_BLUETOOTH     1002  /* bluetooth subsystem */
#define AID_GRAPHICS      1003  /* graphics devices */
#define AID_INPUT         1004  /* input devices */
#define AID_AUDIO         1005  /* audio devices */
#define AID_CAMERA        1006  /* camera devices */
#define AID_LOG           1007  /* log devices */
#define AID_COMPASS       1008  /* compass device */
#define AID_MOUNT         1009  /* mountd socket */
#define AID_WIFI          1010  /* wifi subsystem */
#define AID_ADB           1011  /* android debug bridge (adbd) */
#define AID_INSTALL       1012  /* group for installing packages */
#define AID_MEDIA         1013  /* mediaserver process */
#define AID_DHCP          1014  /* dhcp client */
#define AID_SDCARD_RW     1015  /* external storage write access */
#define AID_VPN           1016  /* vpn system */
#define AID_KEYSTORE      1017  /* keystore subsystem */
#define AID_USB           1018  /* USB devices */
#define AID_DRM           1019  /* DRM server */
#define AID_MDNSR         1020  /* MulticastDNSResponder (service discovery) */
#define AID_GPS           1021  /* GPS daemon */
#define AID_UNUSED1       1022  /* deprecated, DO NOT USE */
#define AID_MEDIA_RW      1023  /* internal media storage write access */
#define AID_MTP           1024  /* MTP USB driver access */
#define AID_UNUSED2       1025  /* deprecated, DO NOT USE */
#define AID_DRMRPC        1026  /* group for drm rpc */
#define AID_NFC           1027  /* nfc subsystem */
#define AID_SDCARD_R      1028  /* external storage read access */
#define AID_CLAT          1029  /* clat part of nat464 */
#define AID_LOOP_RADIO    1030  /* loop radio devices */
#define AID_MEDIA_DRM     1031  /* MediaDrm plugins */
#define AID_PACKAGE_INFO  1032  /* access to installed package details */
#define AID_SDCARD_PICS   1033  /* external storage photos access */
#define AID_SDCARD_AV     1034  /* external storage audio/video access */
#define AID_SDCARD_ALL    1035  /* access all users external storage */


#define AID_SHELL         2000  /* adb and debug shell user */
#define AID_CACHE         2001  /* cache access */
#define AID_DIAG          2002  /* access to diagnostic resources */


编号3000系列只用于辅助用户组
/* The 3000 series are intended for use as supplemental group id's only.
 * They indicate special Android capabilities that the kernel is aware of. */
#define AID_NET_BT_ADMIN  3001  /* bluetooth
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值