其他分享
首页 > 其他分享> > android-setuid在Galaxy s4上失败并显示PermissionDenied

android-setuid在Galaxy s4上失败并显示PermissionDenied

作者:互联网

我试图在C上为Android创建setuid程序.我在android 2.3-4.2上进行了测试,它在除Samsung Galaxy s4(i9500)之外的所有设备上都能正常运行.

我使用CF-Auto-Root将su安装在设备上,并且工作正常.但是我的应用程序运行不正常.

我已经将mysu安装到系统目录中并设置了所有权限:

shell@android:/ $ls -Z /system/bin/mysu
-rwsr-sr-x root     root              u:object_r:system_file:s0 mysu

那就是关于Chainfire的su:

shell@android:/ $ls -Z /system/xbin/su
-rwsr-sr-x root     root              u:object_r:system_file:s0 su

Selinux处于许可模式:

shell@android:/ $getsebool -a
android_cts --> on
app_bluetooth --> off
app_external_sdcard_rw --> on
app_internal_sdcard_rw --> on
app_ndk --> off
app_network --> on
app_read_logs --> off
app_vpn --> off
debugfs --> on
in_qemu --> off
manage_mac --> on
manage_selinux --> on
support_runas --> on
system_app_manage --> off

shell@android:/ $getenforce
Permissive

在mysu中,我在调用shell之前使用setuid和setgid,但它们在Galaxy S4上失败:

shell@android:/ $mysu
euid, egid: 0, 0
uid, gid: 2000, 2000
setgid(0): Permission denied
setuid (0): Permission denied
execv("/system/bin/sh", exec_args): Permission denied

我究竟做错了什么?除了setuid和setgid,Chainfire的su是什么?

解决方法:

解决方案:在调用setuid(0)之前先执行fork().

标签:setuid,su,galaxy,linux,android
来源: https://codeday.me/bug/20191122/2063409.html