将文件复制到 iPhone 系统文件夹

发布于 2024-08-19 16:56:08 字数 206 浏览 5 评论 0原文

我正在为越狱的 iPhone 进行开发。我需要将文件写入(复制)到 iPhone 系统文件夹(/Library/LaunchDaemons),只有 ROOT 具有写入权限。我如何通过我的代码将文件写入此类文件夹。我知道我可以使用 NSFileManager 的 copyItemAtPath:toPath 方法来复制文件,但我无法写入,因为我无权在此类文件夹上写入。

有什么建议吗?

I am developing for Jailbroken iPhone. I need to write(copy) a file to iPhone System Folders (/Library/LaunchDaemons) to which only ROOT has write access. How can i write a file to such folders through my Code. I know i can use NSFileManager's copyItemAtPath:toPath method to copy the file, but i cant write as i dont have permission to write on such folders.

Any Suggestions??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

痴情换悲伤 2024-08-26 16:56:08

我想我已经找到了这个问题的答案。为了写入系统文件夹,您需要拥有对该文件夹的写入权限。我的应用程序附加了一个守护进程,因此我必须将该守护进程复制到 /System/Library/LaunchDaemons 才能使该守护进程正常工作。因此,当我正在为 JB iPhone 进行开发并且人们将使用 Cydia 安装我的应用程序时,为什么不让 Cydia 将我的应用程序的文件安装到正确的位置。我让 Cydia 将 Daemon 文件复制到 /System/Library/LaunchDaemon 文件夹中。现在的问题是 Cydia 如何知道将文件粘贴到哪里。答案很简单,只需在 .deb 文件中创建适当的文件夹,cydia 就会粘贴位于 .deb 文件内的文件夹中的文件。

例如,如果您有一个守护进程,并且希望 Cydia 将其粘贴到 /System/Library/LaunchDaemons ,请在制作 .deb 之前制作如下文件结构

+- MyApp
   +- Applications
      +Myapp.app
   +-DEBIAN
    -control
   +-System
     +-Library
       +-LaunchDaemons
         +- com.myLaunchDaemon.plist

Cydia 在安装应用程序时会将 com.myLaunchDaemon.plist 文件粘贴到 System/ 中Library/LaunchDaemons,重新启动,就可以了。

i think i have found the answer to this question. In order to write to System folders you need to have permission to write on that folder. My app had a Daemon attached to it, so i had to copy that Daemon to /System/Library/LaunchDaemons to make that Daemon work. So as i am developing for JB iphone and people are going to install my app using Cydia, why not to make Cydia install the files of my app to proper locations. I made Cydia to copy the Daemon file into /System/Library/LaunchDaemon folder. Now the question is how Cydia will know where to paste the files. Answer is simple, just make the proper folders in .deb file and cydia will paste the files located in the folders inside the .deb file.

For Example if you have a Daemon and you want Cydia to paste it to /System/Library/LaunchDaemons , make the file structure like this before making a .deb

+- MyApp
   +- Applications
      +Myapp.app
   +-DEBIAN
    -control
   +-System
     +-Library
       +-LaunchDaemons
         +- com.myLaunchDaemon.plist

Cydia while installing your app will paste the com.myLaunchDaemon.plist file in System/Library/LaunchDaemons, reboot and you are good to go.

一腔孤↑勇 2024-08-26 16:56:08

您的应用程序可以以 root 或 setuid root 身份运行。

Your app could run as root or setuid root.

放赐 2024-08-26 16:56:08

与其以 root 身份运行整个应用程序,不如设计一个可以安装文件的小型辅助工具。然后只有该辅助工具必须以 root 身份运行。

有关 SUID 二进制文件的更多信息,请查看 http://en.wikipedia.org/wiki/Setuid作为一个好的开始。

Instead of running your whole app as root it is much better design to have a small helper tool that will install the files. Then only that helper tool has to run as root.

For more info about SUID binaries check http://en.wikipedia.org/wiki/Setuid as a good start.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文