>From b29d3a90e1487ebda5ac5b6bc146f8c95218eab6 Mon Sep 17 00:00:00 2001 From: Roel Janssen
Date: Thu, 19 Apr 2018 14:01:49 +0200 Subject: [PATCH] guix-daemon: Disable garbage collection for remote hosts. * nix/nix-daemon/nix-daemon.cc (performOp): Display appropriate error message; (acceptConnection): Set isRemoteConnection when connection is over TCP. * tests/guix-daemon.sh: Add a test for the new behavior. --- nix/nix-daemon/nix-daemon.cc | 10 +++++++++- tests/guix-daemon.sh | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/nix/nix-daemon/nix-daemon.cc b/nix/nix-daemon/nix-daemon.cc index deb7003d7..782e4acfc 100644 --- a/nix/nix-daemon/nix-daemon.cc +++ b/nix/nix-daemon/nix-daemon.cc @@ -54,7 +54,9 @@ static FdSink to(STDOUT_FILENO); 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 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: { + if (isRemoteConnection) { + throw Error("Garbage collection is disabled for remote hosts."); + break; + } + GCOptions options; options.action = (GCOptions::GCAction) readInt(from); options.pathsToDelete = readStorePaths