打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Android下使用chcon修改文件的安全上下文(file_contexts)
在init.rc中运行某一可执行程序时,需要修改selinux规则,否则会提示要为该服务添加selinux角色。其中的一步是在file_contexts

添加节点或文件的安全安全上下文,如device/qcom/sepolicy/common/file_contexts

  1. /dev/coresight-tmc-etr-stream                   u:object_r:qdss_device:s0  
  2. /dev/system_health_monitor                      u:object_r:system_health_monitor_device:s0  
  3. /dev/qce                                        u:object_r:qce_device:s0  
  4. /dev/msm-rng                                    u:object_r:rng_device:s0  
  5. /dev/qbt1000                                    u:object_r:qbt1000_device:s0  
  6. /dev/at_.*                                      u:object_r:at_device:s0  
  7. /dev/sg.*                                       u:object_r:sg_device:s0/system/bin/audiod                               
  8. /system/bin/charger_monitor                     u:object_r:charger_monitor_exec:s0  
  9. /system/bin/hvdcp_opti                          u:object_r:hvdcp_exec:s0  
  10. /system/bin/cnd                                 u:object_r:cnd_exec:s0  
  11. /system/bin/diag_callback_client                u:object_r:diag_exec:s0  

修改后,编译并烧写boot.img,用ls -Z查看文件的安全信息,发现是u:object_r:system_file:s0,但我的的目的是改成u:ubject_r:xxx_exec:s0,

说明我的修改没有生效。但通过adb push该文件到系统是,我的目的就达到了。想起了Android生成system.img时有用到flle_contexts这个

参数,file_contexts可能还涉及system.img,继续烧写system.img,目标实现了。也就是说,不仅要修改file_contexts文件,还要将该文件

放到out目录下的system文件夹下进行编译,同时烧写boot.img和system才能修改该文件的安全上下文。但在recovery下通过其他方式(非

OTA)替换该文件时,该文件又变成了system_file,这时可使用chcon手工修改该文件的file_contexts,如chcon u:object_r:xxx_exec:s0 xxx,

具体用法可参考(http://www.jianshu.com/p/a3572eee341c)
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
android中system.img的打包过程
[cofface]Android 7.0 file
解压,打包Android的imgags
SEAndroid安全机制中的文件安全上下文关联分析
android memory leak analysis tools
Android adb等 获取root权限
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服