ThisProgramThis is an example of modifying Su in superuser. For more information about superuser, see these two articles.Article:
How to obtain the root permission of the rootexplorer?
Http://blog.csdn.net/a345017062/archive/2011/05/24/6441986.aspx
How to get the root permission for the rootexplorer? -- continue
Http://blog.csdn.net/a345017062/archive/2011/05/24/6442306.aspx
Here, we will only describe how this program runs and its principles.
I. How to run
The format used is "toolroot specific shell command", for example
Toolroot pwd
Ii. Principles
First, toolroot changes the UID and gid of the current process:
If (setgid (0) | setuid (0) {<br/> logw ("Su: Permission denied (% s)", strerror (errno )); <br/> return-1; <br/>}
Here, the user of the toolroot program file should be root. For more information, see setgid and setuid in advanced Unix programming.
Next, toolroot runs the sh program to execute the PWD command, and then packs it into logwrapper to view the output of the PWD command.
The program is open-source and can be downloaded from:
Http://code.google.com/p/flying-on-android/