Hello,
I am working on a cross-platform application where IPC between a LaunchDaemon and a LaunchAgent is implemented via Unix domain sockets. On macOS, the socket path length is restricted to 104 characters. What is the Apple-recommended directory for these sockets to ensure the path remains under the limit while allowing a non-sandboxed agent to communicate with a root daemon? Standard paths like $TMPDIR are often too long for this purpose.
Thank you in advance!
On macOS, the socket path length is restricted to 104 characters
That’s not quite right. While sockaddr_un has a fairly short limit, a Unix domain socket address actually supports a path length up to 253 bytes, which is SOCK_MAXADDRLEN minus the two byte header containing sun_family and sun_len. However, sockaddr_un is defined such that sun_path is 104.
So, if you’re happy to do some gnarly pointer play, you can use longer paths, long enough to allow them to live within an app group container.
Oh, wait, you said not sandboxed. Well, in that case, you don’t need to put them in an app group container, but you can still take advantage of the long path support.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"