How to add an exception to Sandbox?

My MacOS program is printing a message in the terminal window in XCode

networkd_settings_read_from_file Sandbox is preventing this process from reading networkd settings file at "/Library/Preferences/com.apple.networkd.plist", please add an exception.

How do I do this? I don't see a way to add arbitrary File Access on the Signing & Capabilities tab under app setup.

XCode 13.3.1 OSX Monterey 12.3.1 Mac Mini M1

Answered by DTS Engineer in 711956022

That preferences file isn’t meant for your app, meaning that this message is essentially log noise. See my On Log Noise post for my thoughts on that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

That preferences file isn’t meant for your app, meaning that this message is essentially log noise. See my On Log Noise post for my thoughts on that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

In my case it got resolved adding the Outgoing Connections capability.

In my case it got resolved adding the Outgoing Connections capability.

But does your app actually need to make outgoing network connections? If so, you would have needed to claim the com.apple.security.network.client entitlement regardless of this log message. And if it doesn’t, claiming that entitlement just to quieten this log noise is a mistake.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Revisiting this topic since there is an exact title match and my application needs to make an outgoing connection.

Looking at the application log outputs (quoted below) I think I have two problems: 1. my machine is not resolving "localhost" properly; and, 2. which is relevant to this thread, I am sandboxed out of making network connections. I am hoping there is a resource I should be using to sort these problems. FWIW my system is the result of system upgrades dating back to 1988 so I'll not be surprised if something went wrong and it's only now I have noticed. 🤪

The recurring theme is socket error:

public static let SOCKET_ERR_GETADDRINFO_FAILED			= -9989

Following the code I can confirm the error is at the request for a socket, and before any database login credentials have been presented. The database is perfectly functional from the point of view of psql and pgadmin4 (but they are likely using the unix:port to connect, ie., not the "localhost" route).

Any help will be appreciated. G

Context: Building an application for personal productivity and learning exercise ("TheBooks3") to hook into the PostgreSQL server I am running on a local network

Using: macOS Ventura 13.1 (Apple M1) Xcode 14.2 swift-driver version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51) Target: arm64-apple-macosx13.0

Packages: PostgresClientKit (master), which uses Sockets 2.0.4

Application output below. The "DEBUG: ..." are from my application the other messages are produced through the Sockets class,

  1. With host = machine's own specific local network IP as per Network settings
DEBUG: We got to here
2023-01-14 08:10:55.833361+1100 TheBooks3[62799:3524343] [] networkd_settings_read_from_file Sandbox is preventing this process from reading networkd settings file at "/Library/Preferences/com.apple.networkd.plist", please add an exception.
2023-01-14 08:10:55.833473+1100 TheBooks3[62799:3524343] [] networkd_settings_read_from_file Sandbox is preventing this process from reading networkd settings file at "/Library/Preferences/com.apple.networkd.plist", please add an exception.
[2023-01-13T21:10:55.834Z Connection-1 severe] Unable to connect socket: Error code: -9989(0x-2705), Operation not permitted
DEBUG: Open connection failed
Database connection attempted
DEBUG: AccessDataBase.deinit
  1. With host = "localhost"
DEBUG: We got to here
2023-01-14 08:24:41.310094+1100 TheBooks3[63380:3534819] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:8 Err:-1 Errno:1 Operation not permitted
2023-01-14 08:24:41.310237+1100 TheBooks3[63380:3534819] [si_destination_compare] socket(PF_SYSTEM, SOCK_DGRAM, SYSPROTO_CONTROL) failed: Operation not permitted
2023-01-14 08:24:41.310259+1100 TheBooks3[63380:3534819] [si_destination_compare] socket(PF_SYSTEM, SOCK_DGRAM, SYSPROTO_CONTROL) failed: Operation not permitted
[2023-01-13T21:24:41.311Z Connection-1 severe] Unable to connect socket: Error code: -9989(0x-2705), Operation not permitted
DEBUG: Open connection failed
Database connection attempted
DEBUG: AccessDataBase.deinit
  1. with host = "127.0.0.1"
DEBUG: We got to here
[2023-01-13T21:27:35.028Z Connection-1 severe] Unable to connect socket: Error code: -9989(0x-2705), Operation not permitted
DEBUG: Open connection failed
Database connection attempted
DEBUG: AccessDataBase.deinit

The fix is as follows in Xcode: Select the project -> Targets -> Signing & Capabilities [All] -> App Sandbox enable either or both options Incoming Connections (Server) Outgoing Connections (Client)

This really helps, thanks a lot

How to add an exception to Sandbox?
 
 
Q