参照 http://bbs.iosre.com/t/run-a-daemon-as-root-on-ios/212 写 daemon
总是报错 信息如下:
dpkg-deb -c com.cuit.rootdaemonserver_0.0.1-39_iphoneos-arm.deb
drwxr-xr-x a360/staff 0 2015-04-09 14:31 ./
drwxr-xr-x a360/staff 0 2015-04-09 10:45 ./Library/
drwxr-xr-x a360/staff 0 2015-04-09 14:23 ./Library/LaunchDaemons/
-rw-rw-r-- a360/staff 410 2015-04-09 14:23 ./Library/LaunchDaemons/com.cuit.rootdaemonserver.plist
drwxr-xr-x a360/staff 0 2015-04-09 14:31 ./usr/
drwxr-xr-x a360/staff 0 2015-04-09 14:31 ./usr/bin/
-rwxr-xr-x a360/staff 50640 2015-04-09 14:31 ./usr/bin/rootdaemonserver
plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.cuit.rootdaemonserver</string>
<key>ProgramArguments</key>
<array>
<string>/usr/libexec/rootdaemonserver</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
试过改了权限跟 openssh daemon一样 依然报错 chown root:wheel xxx.plist
然后改plist 格式和 Library/LaunchDaemons/com.openssh.sshd.plist 一样还是报错
不知道怎么回事,google说是格式问题
plutil -linit 是显示 OK 的
直接load 报错,如果安装后 reboot 直接无反应。
iPhone4:/ root# launchctl load Library/LaunchDaemons/com.cuit.rootdaemonserver.plist
launchctl: Dubious permissions on file (skipping): Library/LaunchDaemons/com.cuit.rootdaemonserver.plist
nothing found to load
二进制文件可以直接执行成功!就是不能
static void Reboot(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
NSLog(@"Cuit: reboot");
system("reboot");
}
void CFRunLoopRun()
{
while(1)
{
NSLog(@"Cuit: ~_~");
sleep(3);
}
}
int main(int argc, char **argv, char **envp)
{
NSLog(@"Cuit: rootdaemonserver is launched");
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, Reboot,
CFSTR("com.cuit.rootdaemonserver.reboot"),
NULL,//If NULL, callback is called when a notification named name is posted by any object.
CFNotificationSuspensionBehaviorCoalesce);
CFRunLoopRun(); // keep it running in background
NSLog(@"Cuit: end");
return 0;
}