简体   繁体   English

在沙盒Mavericks应用程序中卸载USB设备

[英]Unmount USB device in sandboxed Mavericks application

i wrote a sandboxed app which deals with USB drives under Yosemite (10.10). 我写了一个沙盒应用程序,处理优胜美地(10.10)下的USB驱动器。 When the app is done with its stuff i want to offer the user an option to eject the device. 当应用程序完成其所有工作后,我想为用户提供退出设备的选项。

Under Yosemite thats not a problem, i successfully used 在优胜美地那没问题,我成功地使用了

DADiskUnmount() 

and

[NSWorkspace unmountAndEjectDeviceAtURL:error:]

But under Mavericks (10.9) both methodes won't work. 但是在小牛(10.9)下,这两种方法都行不通。 I double checked my whole code and i'm pretty confident there are no SDK conflicts. 我仔细检查了我的整个代码,我非常有信心没有SDK冲突。

I get the following error message 我收到以下错误消息

Sandbox denied authorizing right 'system.volume.external.unmount' by client <MyApp>

I got all USB related entitlements, use security-scoped bookmarks (with startAccessingSecurityScopedResource and without), repaired disk permissions on the test device, used different kinds of USB devices to test, checked if there are open files on the device and tried kDADiskUnmountOptionForce. 我获得了所有与USB相关的权利,使用了具有安全性范围的书签(带有startAccessingSecurityScopedResource和没有),修复了测试设备上的磁盘权限,使用了各种USB设备进行测试,检查了设备上是否有打开的文件,并尝试了kDADiskUnmountOptionForce。

The

system.volume.external.(adopt|encode|mount|rename|unmount) 

authorization right only appears on 10.8 and 10.9. 授权权限仅出现在10.8和10.9上。 source: link 来源: 链接

Is there a way to grant my app this right ? 有没有办法授予我的应用此权限?

It would be nice if someone could help me with this! 如果有人可以帮助我,那就太好了!

Aperture uses the sandbox "big red button" ( com.apple.security.temporary-exception.sbpl ) to do system.volume.external.mount / unmount . Aperture使用沙箱“红色大按钮”com.apple.security.temporary-exception.sbpl )执行system.volume.external.mount / unmount

From Aperture's entitlements file : Aperture的权利文件中

<key>com.apple.security.temporary-exception.sbpl</key> <string> (begin (allow authorization-right-obtain (right-name "system.volume.external.mount")) (allow authorization-right-obtain (right-name "system.volume.external.unmount")) (deny network-outbound (with no-log) (regex #"^/private/tmp/launch-")) (allow file-ioctl (literal "/dev/ptmx") (literal "/dev/null") (literal "/dev/tty") (regex #"^/dev/ttys")) (allow file-search) (allow ipc-posix-sem) (allow system-fsctl)) </string>

No idea whether Apple will allow this in the MAS though. 不过,不知道苹果是否会在MAS中允许这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM