"Jeff Hostetler via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes: > From: Jeff Hostetler <jeffhost@xxxxxxxxxxxxx> > > Calls to `chdir()` are dangerous in a multi-threaded context. If > `unix_stream_listen()` or `unix_stream_connect()` is given a socket > pathname that is too long to fit in a `sockaddr_un` structure, it will > `chdir()` to the parent directory of the requested socket pathname, > create the socket using a relative pathname, and then `chdir()` back. > This is not thread-safe. > > Teach `unix_sockaddr_init()` to not allow calls to `chdir()` when this > flag is set. While it is clear that this will not affect any existing callers, I am not sure if this is a good direction to go in the longer term. I have to wonder if somebody actually relies on this "feature", though. As long as ENAMETOOLONG is passed back to the caller so that it can react to it, any caller that knows it is safe to chdir() at the point of calling "send_request()" should be able to chdir() itself and come back (or fork a child that chdirs and opens a unix domain socket there, and then send the file descriptor back to the parent process). Thanks.