To create a small tool software requires root permissions. After countless attempts by Google, this problem is finally solved.
The idea has been mentioned in many articles. First, install the application to the/applications directory. I package it into Deb and install it through cydia;
Second, the springboard will not grant the root permission to the application when starting the application. If the user group of the executable file is root: wheel and the setuid bit is set, the application will not be executed, the specific manifestation is that the application exits after a flash. to bypass this problem, another executable file without setuid is required to serve as a bridge, this executable file is disguised as an application executable file. It is used to start a real application executable file.
The main steps are as follows:
1. After the device is jailbroken, ensure that appsync is installed.
2. Assume that the Application name is losttemp. Add setuid (0) and setgid (0) before the main function of the target application code. The two lines of code are compiled by xcode, bind the application bundle (losttemp. copy the file and change the name of the executable file, such as losttemp_root.
3. Compile another executable file (I directly modify the main function of the above application). The main function is similar to the following format. After compilation, change the executable file name to losttemp and copy it to the losttemp file described above. APP:
Nsstring * string = [[nsbundlemainbundle]
Pathforresource: @ "losttemp_root" oftype: Nil];
Argv [0] = (char *) [stringutf8string];
Execve ([stringutf8string], argv,
Null );
4. Change the losttemp permission of the executable losttemp file of losttemp to 755 (chmod), and change the losttemp_root permission to 4755.
5. Package losttemp. app as Deb and set the target installation directory to/Application
6. Put Deb in the/var/root/Media/cydia/autoinstall directory of the device. Restart the device and it should be OK.
Refer to the following articles:
Http://o0o0o0o.iteye.com/blog/983311
Http://wangxinglong.blog.51cto.com/679714/340161
Http://blog.sina.com.cn/s/blog_7879b14f01016q8n.html