问题描述
当我尝试在具有root访问权限的Android 10(galaxy A11)上运行某些命令时,出现ioctl“权限被拒绝”错误。例如:
# ip tuntap add mode tun
ioctl(TUNSETIFF): Permission denied
# ifconfig wlan0
ifconfig: ioctl 8927: Permission denied
等。
我尝试使用Google搜索该问题,但找不到任何解决方法。有人谈论SELinux的局限性。但是root checker表明SELinux的状态是允许的。
如何摆脱这个ioctl
错误,并使命令行实用程序在有根电话上正常工作?
解决方法
我能够通过将 ifconfig 脚本替换为以下内容来解决该问题:
错误命令:
./adb -s $device shell ifconfig wlan0 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}'
新命令:
./adb -s $device shell ip addr show wlan0 | grep -e wlan0$ | cut -d " " -f 6 | cut -d/ -f 1