1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 10:41:16 +02:00

Implement backwards-compatible RemoteStore::addToStore()

The SSHStore PR adds this functionality to the daemon, but we have to
handle the case where the Nix daemon is 1.11.

Also, don't require signatures for trusted users. This restores 1.11
behaviour.

Fixes https://github.com/NixOS/hydra/issues/398.
This commit is contained in:
Eelco Dolstra 2016-11-09 18:45:06 +01:00
parent a83b10f84c
commit 21c55ab3b5
3 changed files with 25 additions and 3 deletions

View file

@ -335,7 +335,28 @@ Path RemoteStore::queryPathFromHashPart(const string & hashPart)
void RemoteStore::addToStore(const ValidPathInfo & info, const ref<std::string> & nar,
bool repair, bool dontCheckSigs, std::shared_ptr<FSAccessor> accessor)
{
throw Error("RemoteStore::addToStore() not implemented");
auto conn(connections->get());
conn->to << wopImportPaths;
StringSink sink;
sink << 1 // == path follows
;
assert(nar->size() % 8 == 0);
sink((unsigned char *) nar->data(), nar->size());
sink
<< exportMagic
<< info.path
<< info.references
<< info.deriver
<< 0 // == no legacy signature
<< 0 // == no path follows
;
StringSource source(*sink.s);
conn->processStderr(0, &source);
auto importedPaths = readStorePaths<PathSet>(*this, conn->from);
assert(importedPaths.size() <= 1);
}

View file

@ -324,7 +324,7 @@ static void performOp(ref<LocalStore> store, bool trusted, unsigned int clientVe
case wopImportPaths: {
startWork();
TunnelSource source(from);
Paths paths = store->importPaths(source, 0);
Paths paths = store->importPaths(source, 0, trusted);
stopWork();
to << paths;
break;