Skip to content

Commit

Permalink
Implement backwards-compatible RemoteStore::addToStore()
Browse files Browse the repository at this point in the history
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 NixOS/hydra#398.
  • Loading branch information
edolstra committed Nov 9, 2016
1 parent a83b10f commit 21c55ab
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
3 changes: 2 additions & 1 deletion release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let

buildInputs =
[ curl bison flex perl libxml2 libxslt bzip2 xz
pkgconfig sqlite libsodium
pkgconfig sqlite libsodium boehmgc
docbook5 docbook5_xsl
autoconf-archive
] ++ lib.optional (!lib.inNixShell) git;
Expand All @@ -34,6 +34,7 @@ let
--with-dbi=${perlPackages.DBI}/${perl.libPrefix}
--with-dbd-sqlite=${perlPackages.DBDSQLite}/${perl.libPrefix}
--with-www-curl=${perlPackages.WWWCurl}/${perl.libPrefix}
--enable-gc
'';

postUnpack = ''
Expand Down
23 changes: 22 additions & 1 deletion src/libstore/remote-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down
2 changes: 1 addition & 1 deletion src/nix-daemon/nix-daemon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 21c55ab

Please sign in to comment.