mirror of
https://github.com/NixOS/nix.git
synced 2025-11-12 13:36:02 +01:00
Allow the gc roots daemon to use a long socket path
`chdir` to the directory of the socket and only use a relative path to it to bypass the socket path length limit (like it's done in `nix::bind`, except that there's no need to fork here since we can afford changing the directory of the process)
This commit is contained in:
parent
5c6b9bc361
commit
6c0e7450de
1 changed files with 6 additions and 2 deletions
|
|
@ -119,8 +119,12 @@ int main(int argc, char * * argv)
|
|||
struct sockaddr_un addr;
|
||||
addr.sun_family = AF_UNIX;
|
||||
|
||||
unlink(opts.socketPath.c_str());
|
||||
strcpy(addr.sun_path, opts.socketPath.c_str());
|
||||
auto socketDir = opts.socketPath.parent_path();
|
||||
auto socketFilename = opts.socketPath.filename();
|
||||
chdir(socketDir.c_str());
|
||||
|
||||
fs::remove(socketFilename);
|
||||
strcpy(addr.sun_path, socketFilename.c_str());
|
||||
if (bind(mySock, (struct sockaddr*) &addr, sizeof(addr)) == -1) {
|
||||
throw Error("Cannot bind to socket");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue