aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/uds-remote-store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2021-08-24 13:52:55 +0200
committerEelco Dolstra <edolstra@gmail.com>2021-10-05 10:44:59 +0200
commit43d4d75e22ea1f7ee2936fe725c1f7ea7a5005e6 (patch)
tree1d450f1f359210e17f1c0c72a8953ac8f72084a9 /src/libstore/uds-remote-store.cc
parent08cc572f8935f9078ef3747187c65b904d5675c7 (diff)
Connect/bind Unix domain sockets in a child process
In the child process, we can do a chdir() and avoid the problem of the path not fitting into sockaddr_un.
Diffstat (limited to 'src/libstore/uds-remote-store.cc')
-rw-r--r--src/libstore/uds-remote-store.cc11
1 files changed, 1 insertions, 10 deletions
diff --git a/src/libstore/uds-remote-store.cc b/src/libstore/uds-remote-store.cc
index cfadccf68..02e81b022 100644
--- a/src/libstore/uds-remote-store.cc
+++ b/src/libstore/uds-remote-store.cc
@@ -65,16 +65,7 @@ ref<RemoteStore::Connection> UDSRemoteStore::openConnection()
throw SysError("cannot create Unix domain socket");
closeOnExec(conn->fd.get());
- string socketPath = path ? *path : settings.nixDaemonSocketFile;
-
- struct sockaddr_un addr;
- addr.sun_family = AF_UNIX;
- if (socketPath.size() + 1 >= sizeof(addr.sun_path))
- throw Error("socket path '%1%' is too long", socketPath);
- strcpy(addr.sun_path, socketPath.c_str());
-
- if (::connect(conn->fd.get(), (struct sockaddr *) &addr, sizeof(addr)) == -1)
- throw SysError("cannot connect to daemon at '%1%'", socketPath);
+ nix::connect(conn->fd.get(), path ? *path : settings.nixDaemonSocketFile);
conn->from.fd = conn->fd.get();
conn->to.fd = conn->fd.get();