标签:uid root and tgid path 显示 mis 目录 igp
关于Android8.1的app权限申请问题例如如何让普通app可以写/sdcard/Android/ 目录
/ # cat /data/system/packages.xml | grep bluetooth
<package name="com.mediatek.bluetooth.dtt" codePath="/system/app/BtTool" nativeLibraryPath="/system/app/BtTool/lib" publicFlags="940097093" privateFlags="0" pkgFlagsEx="0" ft="16a1f147ac8" it="16a1f147ac8" ut="16a1f147ac8" version="27" sharedUserId="1000" isOrphaned="true">
有的应用会显示userId="10024"之类的,而不是sharedUserId
/ #
/ # cat /data/system/packages.list | grep bluetooth
com.mediatek.bluetooth.dtt 1000 0 /data/user/0/com.mediatek.bluetooth.dtt platform:targetSdkVersion=27 3002,1023,1015,3003,3001
其中1000是userId,后面的3002,1023,1015,3003,3001是groups,静态的组
/ #
/ #
/ # ps -A | grep -i bluetooth
system 1928 423 1073940 55904 SyS_epoll_wait b331bb40 S com.mediatek.bluetooth.dtt
/ # cd /proc/1928
/proc/1928 # ls
attr clear_refs coredump_filter environ fdinfo loginuid maps mounts ns oom_score_adj root sessionid stat syscall wchan
auxv cmdline cpuset exe io make-it-fail mem mountstats oom_adj pagemap sched smaps statm task
cgroup comm cwd fd limits map_files mountinfo net oom_score personality schedstat stack status timerslack_ns
/proc/1928 # cat status
Name: k.bluetooth.dtt
State: S (sleeping)
Tgid: 1928
Ngid: 0
Pid: 1928
PPid: 423
TracerPid: 0
Uid: 1000 1000 1000 1000
Gid: 1000 1000 1000 1000
FDSize: 256
Groups: 1000 1015 1023 3001 3002 3003 9997 9997
VmPeak: 1074776 kB
VmSize: 1073940 kB
VmLck: 0 kB
VmPin: 0 kB
VmHWM: 56452 kB
VmRSS: 55904 kB
VmData: 118120 kB
VmStk: 8192 kB
VmExe: 20 kB
VmLib: 96592 kB
VmPTE: 248 kB
VmPMD: 0 kB
VmSwap: 0 kB
Threads: 11
SigQ: 4/5694
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000001204
SigIgn: 0000000000000000
SigCgt: 00000006400084f8
CapInh: 0000000000000000
CapPrm: 0000000000000000
CapEff: 0000000000000000
CapBnd: 0000000000000000
CapAmb: 0000000000000000
Seccomp: 0
Cpus_allowed: f
Cpus_allowed_list: 0-3
Mems_allowed: 1
Mems_allowed_list: 0
voluntary_ctxt_switches: 60
nonvoluntary_ctxt_switches: 22
其中,Groups: 1000 1015 1023 3001 3002 3003 9997 9997 是进程动态真实的属于的组。
实现代码在kernel/fs/proc/base.c ONE("status", S_IRUGO, proc_pid_status),
system/core/include/private/android_filesystem_config.h
其中定义了user和group id号。
#define AID_SDCARD_RW 1015 / external storage write access /
frameworks/base/data/etc/platform.xml 中定义,需要加入group gid,那么一般应用才能访问
<permission name="android.permission.WRITE_EXTERNAL_STORAGE" />
<group gid="media_rw" />
<group gid="sdcard_rw" />
</permission>
编译后,在/system/etc/permissions/platform.xml中。
可以adb pull后进行修改并试验。
这样修改后,一般app就可以修改内置sdcard了。
例如/sdcard/Android目录下创建新目录。
因为一般应用可以在AndroidManifest.xml中申请android.permission.WRITE_EXTERNAL_STORAGE,但是android.permission.WRITE_MEDIA_STORAGE却是私有的系统app才能申请的。
另外文件frameworks/base/data/etc/privapp-permissions-platform.xml 有系统app权限的特定定义。
另外我的相关培训视频请看:
欢迎观看我发布的各个课程: https://edu.51cto.com/lecturer/8896847.html
标签:uid root and tgid path 显示 mis 目录 igp
原文地址:https://blog.51cto.com/8906847/2379464