This definitely works as I described. Consider the test code below. If I build it and install it in the usual way:
% sudo cp Test701588 /Library/PrivilegedHelperTools
% sudo cp com.example.Test701588.plist /Library/LaunchDaemons
% sudo launchctl load /Library/LaunchDaemons/com.example.Test701588.plist
% sudo launchctl start com.example.Test701588
I see this in the system log:
type: default
time: 09:49:18.417639+0000
process: Test701588
subsystem: com.example.Test701588
category: url
message: will start load, url: http://example.com
type: default
time: 09:49:18.655806+0000
process: Test701588
subsystem: com.example.Test701588
category: url
message: did load, status: 200, bytes: 1256
As you can see, ATS did not block my http
request.
This is on macOS 12.2.1 with Xcode 13.2.1.
As to what’s happening in your case, I’m not sure what’s going on. As a first step I recommend that you rule out this:
running in uid 1 context
It’s possible that your use of the daemon
(1) UID is causing ATS to kick in. You can easily test this by repeating my test with a tweaked launchd
property list.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
import Foundation
import os.log
func main() {
let logger = Logger(subsystem: "com.example.Test701588", category: "url")
let url = URL(string: "http://example.com")!
logger.log("will start load, url: \(url, privacy: .public)")
let request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: 60.0)
URLSession.shared.dataTask(with: request) { (data, response, error) in
if let error = error as NSError? {
logger.log("did not load, transport error: \(error.domain as String, privacy: .public) / \(error.code)")
exit(EXIT_FAILURE)
}
let response = response as! HTTPURLResponse
let data = data!
NSLog("task finished with status %d, bytes %d", response.statusCode, data.count)
logger.log("did load, status: \(response.statusCode), bytes: \(data.count)")
exit(EXIT_FAILURE)
}.resume()
dispatchMain()
}
main()
% cat com.example.Test701588.plist
…
<dict>
<key>Label</key>
<string>com.example.Test701588</string>
<key>ProgramArguments</key>
<array>
<string>/Library/PrivilegedHelperTools/Test701588</string>
</array>
</dict>
</plist>