Android7.1update.zip升级在system/bin下新增可执行文件没有可执行权限问题
Android7.1update.zip升級在system/bin下新增可執行文件沒有可執行權限問題
?
外出的設備,只能通過update.zip方式升級,比如要在設備/system/bin目錄下增加login,在需要時執行login,升級后發現login文件沒有可執行權限
msm8937_64:/ # ls -l system/bin/login
-rw-r--r-- 1 root root 1256440 2008-08-0120:00 system/bin/login
第1個root是指UID(文件的owner),第2個root是指GID(Group ID)
?
但我們需要有可執行文件,怎么解決呢,下面給出解決過程的嘗試及解決方法
1.????device\qcom\common\rootdir\etc\init.qcom.rc增加chmod來修改---無效
on boot
?????? …
chmod 0755/system/bin/login
?
2.????updater-script調用set_perm()設置權限---無效
更新失敗,/cache/recovery/last_log提示
提示line 15 col 48: unknown function"set_perm",原因未知
這是因為bootable\recovery\updater\updater.cpp的沒有實現set_perm(),下面給出android4.4版本下相關代碼:
// Maybe, at some future point, we candelete these functions? They have been// replaced by perm_set and perm_set_recursive.RegisterFunction("set_perm", SetPermFn); RegisterFunction("set_perm_recursive",SetPermFn);我們代碼是android7.1的,取而代之的是set_metadata_recursive和set_metadata命令,主要是修改文件或目錄權限和屬組等信息
比如:set_metadata("/system/bin/login","uid", 0, "gid", 0, "mode", 0755,"capabilities", 0x0, "selabel", "u:object_r:system_file:s0");-----------此方法可以解決此問題(推薦)
第1個0表示ROOT,上帝用戶: ROOT, 他的UID= 0; 上帝用戶永遠屬于任何UID
Uid和gid的值system\core\include\private\android_filesystem_config.h定義,比如:
/* This is the master Users and Groupsconfig for the platform.* DONOT 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 */ …set_metadata(filename,?key1,?value1[,?key2?,?value2,...])
Sets the keys ofthe given?filename?to?values. For example:?set_metadata("/system/bin/netcfg","uid", 0, "gid", 3003, "mode", 02750,"selabel", "u:object_r:system_file:s0","capabilities", 0x0).
set_metadata_recursive(dirname,?key1,?value1[,?key2,?value2,...])
Recursively setsthe keys of the given?dirname?and all its children to?values.For example:set_metadata_recursive("/system","uid", 0, "gid", 0, "fmode", 0644,"dmode", 0755, "selabel","u:object_r:system_file:s0", "capabilities", 0x0).
?
3.????另一種解決方法(但不推薦)
package_extract_dir()對應的PackageExtractDirFn()調用mzExtractRecursive(),此函數bootable\recovery\minzip\Zip.c在中實現
把UNZIP_FILEMODE的值由0644改為0755即可,但是如果之前用0644方式的升級包升級過,在此基礎上再升級,login權限還是0644其他,為了解決此問題,還需要在updater-script文件增加了delete("/system/bin/login");配合才能解決,但這種解決方法不是很合理,不推薦。
?
參考鏈接:
Android 5.x OTA Update官方文檔(四、OTA更新包解讀)
http://blog.csdn.net/huangyabin001/article/details/44873753
?
Flashing CM 11, I get`set_metadata_recursive: some changes failed`:
https://android.stackexchange.com/questions/62982/flashing-cm-11-i-get-set-metadata-recursive-some-changes-failed
總結
以上是生活随笔為你收集整理的Android7.1update.zip升级在system/bin下新增可执行文件没有可执行权限问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android recovery 模块知
- 下一篇: Android 5.x 权限问题解决方法