开发者

Gain root acces in iOS and launch Daemon

I am an iPhone Developer, now I am making an App that need to run commands (like "launchctl") The only way I can launcht is with root privileges, but i dont know how to get root privileges.

I want to call it wit开发者_开发百科h System("launchctl....") or there is other way?

Thanks in advance ;)


You cannot get root privileges if your going to distribute this in the App Store. However, you can get root access if you're developing this for jailbroken devices.


I built a jailbreak app once that was trying to do something similar. I wasn't using launchctl, but I was issuing a call using system().

What I found was that even if I let my app run as user root, which requires more than what edc1591 outlined in his comment above, system calls would still run whatever command you passed it (e.g. launchctl) with user mobile privileges. (Aside: I think the reason might be related to this issue).

If you want to do that, I found a rather convoluted way of doing so. See that answer here.


First of all, using system(); is a C method and is not very reliable at all for executing commands like that, (I know from experience). What you would want to do, is copy the NSTask.h file from the foundation.framework into your project window and use it. the way to find it is by opening a new project for the mac and clicking show in finder on the foundation.framework and then copy it. (Make sure to remove the lines near the top that check if you have Mac OS 10.6 or greater)

Then try running it. If it still doesn't have the right privileges, try looking into setuid(); but other than that, i don't know how it's done. Maybe you can contact the developer of iFile, he would know how...


Unfortunately, there is no Apple sanctioned way to do this. In other words, apps that require root access will not be approved for use in the App Store. It is possible that Apple will grant an exception, but that's is seriously, extremely, unlikely.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜