Not receiving any UDP data on a socket when App Sandbox is on in Cocoa app

霸气de小男生 提交于 2019-12-14 02:30:12

问题


I have a cocoa app written in Swift 3.0, which is using framework written using C++/Boost to receive UDP data on socket. But when the App Sandbox Capability is switched on in cocoa app i am not receiving any data from the socket, which i am also using to send data to the server first. When App Sandbox is switched off everything is working as expected. Entitlements com.apple.security.network.client and om.apple.security.network.server are set to YES.

Is there anything i can do to make it working with App Sandbox switched on (which is mandatory for apps in Mac App Store)?


回答1:


I was able to make it work with both com.apple.security.network.client and com.apple.security.network.server enabled and i am using much higher then 1024 ports. We had actually problems with firewalls and another end backend. So to sum it up it is possible to open socket and receive UDP data on cocoa sandboxed app, but you need to have com.apple.security.network.server enabled.




回答2:


It's possible to use the following entitlements to allow UDP/TCP socket connections:

com.apple.security.network.client
com.apple.security.network.server

According to Apple's "Elevating Privileges Safely" section in the documentation, opening raw sockets, or port numbers below 1024 (UDP/TCP) require elevated privileges. Elevating privileges is apparently not permitted at all in Sandboxed Apps.

Circumstances Requiring Elevated Privileges

Regardless of whether a user is logged in as an administrator, a program might have to obtain administrative or root privileges in order to accomplish a task. Examples of tasks that require elevated privileges include:

* manipulating file permissions, ownership
* creating, reading, updating, or deleting system and user files
* opening privileged ports (those with port numbers less than 1024) for TCP and UDP connections
* opening raw sockets
* managing processes
* reading the contents of virtual memory
* changing system settings
* loading kernel extensions

If you have to perform a task that requires elevated privileges, you must be aware of the fact that running with elevated privileges means that if there are any security vulnerabilities in your program, an attacker can obtain elevated privileges as well, and would then be able to perform any of the operations listed above.

Note: Elevating privileges is not allowed in applications submitted to the Mac App Store (and is not possible in iOS).



来源:https://stackoverflow.com/questions/41396350/not-receiving-any-udp-data-on-a-socket-when-app-sandbox-is-on-in-cocoa-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!