Daemon程序打包后权限不对,导致安装后没有随系统运行

参考的大神的帖子
runadaemon
我在一年多以前也发帖问过,但是别的问题,后边因为项目原因没有继续研究下去。我的帖子

手机版本:iPhone4s,8.1.3
MAC版本:10.12.3
theos安装路径:~/theos

按照大神的帖子一步步的做下来,Makefile,control文件都是默认的。从修改plist文件,修改main.mm文件,创建layout目录,下载fauxsu并且修改权限和用户组为 root/wheel,以上步骤和帖子里情况都是一样的。


然后再次打包。发现deb的权限没有被修改。

将deb安装到手机上,在xcode上没有查看到日志。
因为我的手机系统图标都不见了,cydia也不能启动,其他插件暂时还无法安装。

帮忙看看deb权限的问题吧

权限问题已经解决
权限问题。在这篇帖子的回复里查看@LiserYu的回复

问题已经解决!原因是在El Capitan之后,mac 系统文件修改权限加入了系统完整性保护(System Integrity Protection,其目的是为了阻止系统文件,包括auvaltool,被修改,这是在El Capitan之后才有的一个新特性)所以需要先关闭这个功能之后,执行上面的 sudo chmod 语句才会有效,具体关闭方式是
重启电脑 并按住Command+R,进入recovery分区,之后从菜单栏中选择工具(Utilities)->终端(Terminal),之后在终端中输入csrutil disable; reboot 再回车即可。

使用这种方法已经能够修改deb的权限。安装后查看目录
/usr/bin 目录下存在 rootdaemond
/Library/LaunchDaemons 目录下存在 com.iosre.rootdaemond.plist

另外因为我的手机系统app都没有入口了,所以安装不了ps syslog等工具。我就修改了下main文件,添加了一个定时打印日志的循环

int main(int argc, char **argv, char **envp)
{
	NSLog(@"iOSRE: rootdaemond is launched!");
	system("iOSRE: rootdaemond is launched!");
	dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
		while (YES) {
		   [NSThread sleepForTimeInterval:5];
	           NSLog(@"rootdaemon begin to run");
		   }
	});

	CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, Reboot, CFSTR("com.iosre.rootdaemon.reboot"), NULL, CFNotificationSuspensionBehaviorCoalesce);
	CFRunLoopRun(); // keep it running in background
	return 0;
}

重启手机后。数据线连接手机查看日志。日志如下

localhost:Desktop songdh$ cat log | grep com.iosre.rootdaemond
May 27 17:02:46 Small4 com.apple.xpc.launchd[1] (com.iosre.rootdaemond[304]) <Error>: Program specified by service does not contain one of the requested architectures: P2PKlN
May 27 17:02:47 Small4 com.apple.xpc.launchd[1] (com.iosre.rootdaemond[405]) <Error>: Program specified by service does not contain one of the requested architectures: P2@xN
May 27 17:02:47 Small4 com.apple.xpc.launchd[1] (com.iosre.rootdaemond) <Notice>: Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
May 27 17:02:57 Small4 com.apple.xpc.launchd[1] (com.iosre.rootdaemond[425]) <Error>: Program specified by service does not contain one of the requested architectures: P2�xN
May 27 17:02:57 Small4 com.apple.xpc.launchd[1] (com.iosre.rootdaemond) <Notice>: Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
May 27 17:03:07 Small4 com.apple.xpc.launchd[1] (com.iosre.rootdaemond[527]) <Error>: Program specified by service does not contain one of the requested architectures: P2��lN
May 27 17:03:07 Small4 com.apple.xpc.launchd[1] (com.iosre.rootdaemond) <Notice>: Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
May 27 17:03:17 Small4 com.apple.xpc.launchd[1] (com.iosre.rootdaemond[597]) <Error>: Program specified by service does not contain one of the requested architectures: P2�wN
May 27 17:03:17 Small4 com.apple.xpc.launchd[1] (com.iosre.rootdaemond) <Notice>: Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
May 27 17:03:28 Small4 com.apple.xpc.launchd[1] (com.iosre.rootdaemond[600]) <Error>: Program specified by service does not contain one of the requested architectures: P2
May 27 17:03:28 Small4 com.apple.xpc.launchd[1] (com.iosre.rootdaemond) <Notice>: Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
May 27 17:03:38 Small4 com.apple.xpc.launchd[1] (com.iosre.rootdaemond[609]) <Error>: Program specified by service does not contain one of the requested architectures: P2@axN
May 27 17:03:38 Small4 com.apple.xpc.launchd[1] (com.iosre.rootdaemond) <Notice>: Service only ran for 0 seconds. Pushing respawn out by 10 seconds.

根据日志来看,代码里的日志都没有出现,但是却有很多com.iosre.rootdaemond进程的错误日志。而且还会定时打印日志。是不是daemon已经在运行了。
错误日志搜了下也没看出个所以然,
有没有遇到相同情况的