【发布时间】:2009-07-22 00:23:30
【问题描述】:
我正在通过 cocoa 应用程序运行卸载脚本,我注意到 launchctl 命令没有被执行。
这是调用脚本的部分代码(其中包含 sudo launchctl unload "name of the daemon")
//pFileName is the name of the File
NSString* pPath = [pCurrentBundle pathForResource:pFileName ofType:@"sh"];
char* const ppArgs[] = {const_cast<char*>([pPath fileSystemRepresentation]), NULL};
OSStatus status = AuthorizationExecuteWithPrivileges(m_AuthorizationRef, "/bin/sh", kAuthorizationFlagDefaults, ppArgs, NULL);
由于所有其他脚本命令都可以正确执行(并且在终端中可以正常卸载),我猜我没有 TN2083 状态的 root 权限(EUID 和 RUID 均为 0)。
【问题讨论】: