安卓11 出现 avc:denied{ getattr} for path ="/system/xbin/su“
时间: 2023-12-17 17:02:05 浏览: 32
这是因为 Android 11 引入了一种名为 Scoped Storage 的新的文件系统访问策略,它限制了应用程序对系统文件的访问权限。在 Android 11 中,应用程序无法直接访问 /system 目录,因此如果您的应用程序需要访问 /system/xbin/su,您需要以 root 用户身份运行您的应用程序或者通过使用 system_server 进程来访问该目录。请注意,以 root 用户身份运行应用程序可能会导致安全问题,因此请谨慎操作。
相关问题
安卓11 出现 avc:denied{ ioctl} for path ="socket:[415004]“
这个问题通常是因为您的应用程序缺少必要的权限,无法执行 ioctl 操作。在 Android 11 中,应用程序需要在 AndroidManifest.xml 文件中声明权限才能执行某些操作。请检查您的应用程序是否声明了适当的权限,并确保您的应用程序已经被授予这些权限。如果您的应用程序需要访问系统级别的功能,请确保声明了 android.permission.ACCESS_SUPERUSER 权限,并且您的设备已经获取了 root 权限。如果问题仍然存在,请尝试使用 Android Debug Bridge (ADB) 工具来获取更多的详细信息,以便更好地调试问题。
[ 62.097451] type=1400 audit(1686032696.903:62): avc: denied { map } for comm="network.sh" path="/system/bin/sh" dev="dm-7" ino=720 scontext=u:r:network_sh:s0 tcontext=u:object_r:shell_exec:s0 tclass=file permissive=1 [ 62.097570] type=1400 audit(1686032696.903:62): avc: denied { read } for comm="network.sh" path="/system/bin/sh" dev="dm-7" ino=720 scontext=u:r:network_sh:s0 tcontext=u:object_r:shell_exec:s0 tclass=file permissive=1 [ 62.097709] type=1400 audit(1686032696.903:62): avc: denied { execute } for comm="network.sh" path="/system/bin/sh" dev="dm-7" ino=720 scontext=u:r:network_sh:s0 tcontext=u:object_r:shell_exec:s0 tclass=file permissive=1 [ 62.113304] type=1400 audit(1686032696.935:63): avc: denied { getattr } for comm="network.sh" path="/system/bin/sh" dev="dm-7" ino=720 scontext=u:r:network_sh:s0 tcontext=u:object_r:shell_exec:s0 tclass=file permissive=1 [ 62.143732] type=1400 audit(1686032696.971:64): avc: denied { read } for comm="network.sh" name="ifconfig" dev="dm-7" ino=561 scontext=u:r:network_sh:s0 tcontext=u:object_r:init-ifconfig_exec:s0 tclass=lnk_file permissive=1 [ 62.150395] type=1400 audit(1686032696.971:64): avc: denied { getattr } for comm="network.sh" path="/system/bin/toybox" dev="dm-7" ino=766 scontext=u:r:network_sh:s0 tcontext=u:object_r:toolbox_exec:s0 tclass=file permissive=1 [ 62.150484] type=1400 audit(1686032696.979:65): avc: denied { execute } for comm="network.sh" name="toybox" dev="dm-7" ino=766 scontext=u:r:network_sh:s0 tcontext=u:object_r:toolbox_exec:s0 tclass=file permissive=1 [ 62.150537] type=1400 audit(1686032696.979:66): avc: denied { read open } for comm="network.sh" path="/system/bin/toybox" dev="dm-7" ino=766 scontext=u:r:network_sh:s0 tcontext=u:object_r:toolbox_exec:s0 tclass=file permissive=1 [ 62.150676] type=1400 audit(1686032696.979:66): avc: denied { execute_no_trans } for comm="network.sh" path="/system/bin/toybox" dev="dm-7" ino=766 scontext=u:r:network_sh:s0 tcontext=u:object_r:toolbox_exec:s0 tclass=file permissive=1 [ 62.151933] type=1400 audit(1686032696.979:66): avc: denied { map } for comm="ifconfig" path="/system/bin/toybox" dev="dm-7" ino=766 scontext=u:r:network_sh:s0 tcontext=u:object_r:toolbox_exec:s0 tclass=file permissive=1 改写avc规则
AVC(Access Vector Cache)规则是安卓系统中的访问控制规则,用于限制应用程序访问敏感资源的能力。修改这些规则需要 root 权限和对 SELinux 的了解。
如果您想尝试修改这些规则,可以按照以下步骤操作:
1. 获取 root 权限,并安装 SELinux policy 工具。
2. 使用 `audit2allow` 工具将 AVC 规则转换为 SELinux policy 规则。例如,对于上面的日志,可以使用以下命令:
```
$ adb shell dmesg | grep -E 'type=1400 audit' | audit2allow -M network_sh
```
这将生成一个名为 `network_sh.pp` 的 SELinux policy 文件。
3. 将 `network_sh.pp` 文件推送到设备上。
```
$ adb push network_sh.pp /data/local/tmp/
```
4. 使用 `semodule` 工具将 SELinux policy 文件加载到系统中。
```
$ adb shell su -c "semodule -i /data/local/tmp/network_sh.pp"
```
这样就可以成功改写 AVC 规则。但是请注意,这可能会导致系统安全性问题,因此请谨慎操作。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)