客户需求:
1. Provide a listing of all of files on the device, formatted per the examples below. See the detailed formatting requirements in Section 2.2, "Permissions - Other Writable" in Document 19423, Android Implementaiton Details.
a. A listing compatible with the formatting below can be obtained by appropriately converting the ouput of the ls -l -R command to a CSV file and importing it into this spreadsheet.
2. For all files which are writable by "other" provide a rational and and an explanation for why the setting is believed to be appropriate and safe.
客户主要意思是要获取当前手机上的文件权限中other中有w权限的文件或目录,全部列出来。
实现过程:
1:找出当前手机中所有文件的权限列表并导出至本地,(手机是debug版本)
adb root
adb remount
adb shell
ls -al -R > data/perm_all.txt
由于当前的操作环境是Windows 7,所以将perm_all.txt pull至本地。
adb pull data/perm_all.txt d:\perm_all.txt
2:从perm_all.txt中找出other 带w的权限,这里是比较关键的一点。将perm_all.txt拷贝到Ubuntu系统目录下。然后执行以下命令:
grep "[^l][r-][w-][xsStT-][r-][w-][xsStT-][r-][w][xsStT-]" ./perm_all.txt > perm_002.txt
这里我们排除了link类型的文件。
3:在打开perm_002.txt文件后,发现有不少重复数据行,所以还要去重复处理。
awk '!a[$0]++' perm_002.txt > perm_new.txt
经过这一番操作后,就基本达到客户要求了,不过接下来还要给这些类型文件写些理由,为什么允许可以有w权限,这个才是最头疼的。
网友评论