Issue
I recently found a way to maintain root access on my android device using a dropbear SSH server that I modified to run at boot as root using init.d, a lil scripting magic & some config scripts I made. If you want you can check it out here... Anyways for an experiment I removed the su binary and Superuser.apk from the system. I've managed to get them copied back to the system, but I don't know how to set the appropriate permissions for the su binary. If I look in Super User app on another rooted phone and go to update, it shows -rwsr -sr-x
as the permissions on the binary. How can I set these same permission manually & what do they mean? Specifically the s part.
Solution
The s part is the setuid
bit. Wikipedia:
setuid and setgid (short for "set user ID upon execution" and "set group ID upon execution", respectively) are Unix access rights flags that allow users to run an executable with the permissions of the executable's owner or group respectively and to change behaviour in directories.
That permission string means:
- the owner can read, write, and execute
- users in the file's group can read and execute
- other users can read and execute
- the file has setuid set
You can set that specific permission by running chmod 06755 /system/bin/su
. That's the octal (= "out of eight", like decimal is "out of ten" and hexadecimal is "out of sixteen") encoding for:
- the setuid bit (4) and setgid bit (2) = 6
- all permissions for the owner (7)
- read and execute for group (5)
- read and execute for others (5)
Answered By - Christian Ternus