AuthorizationExecuteWithPrivileges 管道?
好吧,我有一些代码,例如:
FILE *file;
AuthorizationRef authorizationRef;
OSStatus status;
...
status = AuthorizationExecuteWithPrivileges(authorizationRef, "/sbin/mount_hfs", kAuthorizationFlagDefaults, args, &file);
...
执行时我也收到预期错误“mount_hfs:无效参数”。 有没有简单的方法来跟踪这个错误? 就像:
return NO; //if error is "mount_hfs: Invalid argument"
我
return YES; //if no errors
试过这个
if( file != NULL )
{
while( fgets(buffer,255,file) != NULL )
{
printf("%s",buffer);
}
pclose(file);
}
文件不为空但没有打印:|
Well, I have some code like:
FILE *file;
AuthorizationRef authorizationRef;
OSStatus status;
...
status = AuthorizationExecuteWithPrivileges(authorizationRef, "/sbin/mount_hfs", kAuthorizationFlagDefaults, args, &file);
...
also I am getting expected error "mount_hfs: Invalid argument" while executing.
Is there easy way to track this error?
like:
return NO; //if error is "mount_hfs: Invalid argument"
and
return YES; //if no errors
I have tried this
if( file != NULL )
{
while( fgets(buffer,255,file) != NULL )
{
printf("%s",buffer);
}
pclose(file);
}
file isn't null but no print :|
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
谷歌搜索 SMJobless。这就是你应该使用的,但我还没有弄清楚如何在该模型中使用命令的参数。
Google for SMJobless. That's what your supposed to use, but I haven't figured how to use arguments for commands in that model.