I am trying to write file to the root partition of the device. It is a Jailbreak app so it is installed in /Applications. When writing to the root filesystem using NSFileManager
the write fails with a "Permission Denied" error.
It seems like my app is not running as root. It is installed in /Applications though. How can my app become root?
It is true, the app has to run as root to access non mobile directories. After discussing this with Optimo and Saurik I finally found the right way to get root privileges.
setuid(0);
and setgid(0);
Open the original executable file and replace its content with this script:
#!/bin/bash dir=$(dirname "$0") exec "${dir}"/COPIED_EXECUTABLE_NAME "$@"
Directly launching a root app fails on iOS. Therefore we replace the app's main executable with a script that launches the root executable.
In terminal, navigate to the app bundle.
chmod 0775
the original executable file and chmod 6775
the copied executable file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.