Android权限分析

  • 格式:doc
  • 大小:142.00 KB
  • 文档页数:18
#define AID_NET_ADMIN 3005 /* can configure interfaces and routing tables. */
#define AID_MISC 9998 /* access to misc storage */
#define AID_NOBODY 9999
#define AID_NET_BT 3002 /* bluetooth: create sco, rfcomm or l2cap sockets */
#define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */
#define AID_NET_RAW 3004 /* can create raw INET sockets */
5).FIFO。用于进程间通信,也叫命名管道,只能由相关进程使用。
6).套接字。用于网络间进程通信,也可用于本机的非网络通信。一般都在 /dev/socket 下。
7).符号链接。指向另一个文件。
注:查看文件详细信息时Байду номын сангаас文件类型显示在文件权限位的前面。命令:
ls -l 或 ll 命令
2.文件访问权限位
1).普通文件。对应 system.img 和 ramdisk.img 中的所有文件。
2).目录文件。对应 system.img 和 ramdisk.img 中的所有目录。
3).块特殊文件。基本存在于 /sys、/proc 和 /dev 三个目录中。
4).字符特殊文件。基本存在于 /sys、/proc 和 /dev 三个目录中。
/* 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: create any socket */
** images generated by build tools (mkbootfs and mkyaffs2image) and
** by the device side of adb.
*/
#ifndef _ANDROID_FILESYSTEM_CONFIG_H_
#define _ANDROID_FILESYSTEM_CONFIG_H_
文件访问权限位的组成:
u(owner)|g(group) |o(other)
r w xr w xr w x
4 2 14 2 14 2 1
注:修改文件权限时使用 chmod 命令,格式如下:
chmod path 644
chmod path 777
Android 是一个多进程系统,每一个应用程序(不论是 C 或 C++ 编译而成的二进制程序,还是运行在 dalvik 虚拟机中的 APK 包格式的 Java 程序)都运行在自己的进程中。Android 使用标准的 Linux 功能集实现了大多数应用程序和系统之间的安全性,例如通过被分配给应用程序的用户和用户组 ID,但该权限粒度较大,一般用于控制进程可访问的具体资源和设备。Android 中更细粒度的安全特性则通过“许可”机制来提供,该机制能够对一个指定进程可实现的特定操作进行约束。
#define AID_SHELL 2000 /* adb and debug shell user */
#define AID_CACHE 2001 /* cache access */
#define AID_DIAG 2002 /* access to diagnostic resources */
{ "root", AID_ROOT, },
{ "system", AID_SYSTEM, },
{ "radio", AID_RADIO, },
{ "bluetooth", AID_BLUETOOTH, },
{ "graphics", AID_GRAPHICS, },
{ "input", AID_INPUT, },
#define AID_APP 10000 /* first app user */
#if !defined(EXCLUDE_FS_CONFIG_STRUCTURES)
struct android_id_info {
const char *name;
unsigned aid;
};
static struct android_id_info android_ids[] = {
Android权限分析
Linux 系统同 Unix 系统一样,通过信任状(credential)把进程与一个特定的用户或用户组捆绑在一起。信任状决定了每个进程能做什么,不能做什么,从而保证整个系统的数据完整性和整体稳定性。
1.文件类型
Linux 中的文件共有如下几种类型,由于 Android 中不同类型的文件会通过不同的方式来设置权限位,故简单介绍 Linux 中的文件类型如下:
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
/* This is the master Users and Groups config for the platform.
** DO NOT EVER RENUMBER.
*/
{ "audio", AID_AUDIO, },
{ "camera", AID_CAMERA, },
{ "log", AID_LOG, },
{ "compass", AID_COMPASS, },
{ "mount", AID_MOUNT, },
{ "wifi", AID_WIFI, },
{ "dhcp", AID_DHCP, },
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* This file is used to define the properties of the filesystem
#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_LOG 1007 /* log devices */
#define AID_COMPASS 1008 /* compass device */
#define AID_MOUNT 1009 /* mountd socket */
#define AID_WIFI 1010 /* wifi subsystem */
{ "net_bt", AID_NET_BT, },
{ "sdcard_rw", AID_SDCARD_RW, },
{ "vpn", AID_VPN, },
{ "keystore", AID_KEYSTORE, },
{ "inet", AID_INET, },
{ "net_raw", AID_NET_RAW, },
{ "net_admin", AID_NET_ADMIN, },
{ "misc", AID_MISC, },
{ "nobody", AID_NOBODY, },
};
#define android_id_count \
(sizeof(android_ids) / sizeof(android_ids[0]))
1.文件系统中的权限设定
Android 系统编译完成后会生成三个后缀为 img 的文件,ramdisk.img、system.img、userdata.img,各自包含许多目录和文件。Android 系统编译时会使用两个 Android 命令 mkbootfs 和 mkyaffs2image 来生成这些 img文件,这两个命令都会调用文件 android_filesystem_config.h 中预制的权限,来写入这些目录和文件资源初始的访问权限。
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* you may not use this file except in compliance with the License.