AndroidQ(10.0) system app 增加访问 sys/class/ 权限

发布时间:2024-12-19 08:33

如何设置网络访问权限 #生活技巧# #数码产品使用技巧# #网络设备设置教程#

问题由来

System app 需要读取网卡地址,而网卡地址存储在 sys/class/net/eth0/address

所以通过 cat sys/class/net/eth0/address 就能获取设备网卡地址

但是安全等级越来越高,

1|HTC5K:/ $ cat sys/class/net/eth0/address

cat: sys/class/net/eth0/address: Permission denied

HTC5K:/ $ ifconfig

ifconfig: ioctl 8927: Permission denied

avc: denied { search } for name=“net” dev=“sysfs” ino=12684 scontext=u:r:system_app:s0 tcontext=u:object_r:sysfs_net:s0 tclass=dir permissive=0

avc: denied { read } for name=“address” dev=“sysfs” ino=25277 scontext=u:r:system_app:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=0

avc: denied { open } for path="/sys/devices/platform/1100a000.spi/spi_master/spi32766/spi32766.0/net/eth0/address" dev=“sysfs” ino=25277 scontext=u:r:system_app:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=0

增加权限

device/mediatek/sepolicy/basic/non_plat/system_app.te

allow system_app self:netlink_kobject_uevent_socket {read bind create setopt }; # system_app need to read from sysfs /sys/class/switch/hdmi/state r_dir_file(system_app, sysfs_switch); +allow system_app sysfs_net:dir { search read }; +allow system_app sysfs:file { open read }; 123456

编译报错

libsepol.report_failure: neverallow on line 91 of system/sepolicy/private/coredomain.te (or line 32781 of policy.conf) violated by allow system_app sysfs:file { read open };
libsepol.check_assertions: 1 neverallow failures occurred
Error while expanding policy

修改忽略规则

system/sepolicy/private/coredomain.te
system/sepolicy/prebuilts/api/29.0/private/coredomain.te

@@ -102,6 +102,7 @@ full_treble_only(` -init -ueventd -vold + -system_app } sysfs:file no_rw_file_perms; # /dev 12345678

网址:AndroidQ(10.0) system app 增加访问 sys/class/ 权限 https://www.yuejiaxmz.com/news/view/516403

相关内容

Android系统优化
【安全问题】ZooKeeper未授权访问
民生银行全民生活App新版“10”力如何?有新意也有挑战 细节处仍需下功夫 作为 民生银行 信用卡官方App,“全民生活”10.0版新增了权益频道,打造了短视频内容社区,丰富了“金融+非金融”服务...
Oracle数据库数据安全面面观
全程水处理器SYS
vue组件中是否可以访问实例data中数据?
System Error
慎选理财APP开放权限 黑客利用漏洞半天提现千万
访问异常页面
Accessibility(可访问性)

随便看看