3 ms·
> To those wondering why and when this is needed - it is useful for cases when your primary process lacks rights required to open a file or a device (!). So ano
by clarry 13y ago
> To those wondering why and when this is needed - it is useful for cases when your primary process lacks rights required to open a file or a device (!). So another, privileged process does the open on its behalf and sends the resulting file descriptor to the primary process for processing.
But be careful with who can connect to that socket and grab that fd. If you just name that socket and then tell another process to open it, there's a race. In a traditional privsep scenario the socket between the privileged and unprivileged process is created prior to and shared between them with fork(). Other scenarios (e.g. daemon serving fds to local clients that weren't initially there), you'll need some way to communicate with that client before you can tell it to grab the fd; why not use that ipc socket?
EDIT: Just to clarify, I'm commenting on the approach used by the linked library on github.