mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 13:28:12 -05:00
guix-daemon: Disable garbage collection for remote connections.
* nix/nix-daemon/nix-daemon.cc (isRemoteConnection): New variable. (performOp): For wopCollectGarbage, throw an error when isRemoteConnection is set. (acceptConnection): Set isRemoteConnection when connection is not AF_UNIX. * tests/guix-daemon.sh: Add a test for the new behavior.
This commit is contained in:
parent
7c16af4646
commit
5cefb13ddd
2 changed files with 23 additions and 1 deletions
|
@ -54,7 +54,9 @@ static FdSink to(STDOUT_FILENO);
|
||||||
|
|
||||||
bool canSendStderr;
|
bool canSendStderr;
|
||||||
|
|
||||||
|
/* This variable is used to keep track of whether a connection
|
||||||
|
comes from a host other than the host running guix-daemon. */
|
||||||
|
static bool isRemoteConnection;
|
||||||
|
|
||||||
/* This function is called anytime we want to write something to
|
/* This function is called anytime we want to write something to
|
||||||
stderr. If we're in a state where the protocol allows it (i.e.,
|
stderr. If we're in a state where the protocol allows it (i.e.,
|
||||||
|
@ -529,6 +531,11 @@ static void performOp(bool trusted, unsigned int clientVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
case wopCollectGarbage: {
|
case wopCollectGarbage: {
|
||||||
|
if (isRemoteConnection) {
|
||||||
|
throw Error("Garbage collection is disabled for remote hosts.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
GCOptions options;
|
GCOptions options;
|
||||||
options.action = (GCOptions::GCAction) readInt(from);
|
options.action = (GCOptions::GCAction) readInt(from);
|
||||||
options.pathsToDelete = readStorePaths<PathSet>(from);
|
options.pathsToDelete = readStorePaths<PathSet>(from);
|
||||||
|
@ -934,6 +941,7 @@ static void acceptConnection(int fdSocket)
|
||||||
connection. Setting these to -1 means: do not change. */
|
connection. Setting these to -1 means: do not change. */
|
||||||
settings.clientUid = clientUid;
|
settings.clientUid = clientUid;
|
||||||
settings.clientGid = clientGid;
|
settings.clientGid = clientGid;
|
||||||
|
isRemoteConnection = (remoteAddr.ss_family != AF_UNIX);
|
||||||
|
|
||||||
/* Handle the connection. */
|
/* Handle the connection. */
|
||||||
from.fd = remote;
|
from.fd = remote;
|
||||||
|
|
|
@ -194,6 +194,20 @@ do
|
||||||
kill "$daemon_pid"
|
kill "$daemon_pid"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Make sure garbage collection from a TCP connection does not work.
|
||||||
|
|
||||||
|
tcp_socket="127.0.0.1:9999"
|
||||||
|
guix-daemon --listen="$tcp_socket" &
|
||||||
|
daemon_pid=$!
|
||||||
|
|
||||||
|
GUIX_DAEMON_SOCKET="guix://$tcp_socket"
|
||||||
|
export GUIX_DAEMON_SOCKET
|
||||||
|
|
||||||
|
if guix gc; then false; else true; fi
|
||||||
|
|
||||||
|
unset GUIX_DAEMON_SOCKET
|
||||||
|
kill "$daemon_pid"
|
||||||
|
|
||||||
# Log compression.
|
# Log compression.
|
||||||
|
|
||||||
guix-daemon --listen="$socket" --disable-chroot --debug --log-compression=gzip &
|
guix-daemon --listen="$socket" --disable-chroot --debug --log-compression=gzip &
|
||||||
|
|
Loading…
Reference in a new issue