* Remove queryPathHash().

* Help for nix-worker.
This commit is contained in:
Eelco Dolstra 2006-12-02 14:27:24 +00:00
parent fcd9900d74
commit 8ba5d32769
4 changed files with 32 additions and 2 deletions

View file

@ -98,7 +98,10 @@ bool RemoteStore::hasSubstitutes(const Path & path)
Hash RemoteStore::queryPathHash(const Path & path) Hash RemoteStore::queryPathHash(const Path & path)
{ {
throw Error("not implemented 3"); writeInt(wopQueryPathHash, to);
writeString(path, to);
string hash = readString(from);
return parseHash(htSHA256, hash);
} }

View file

@ -4,6 +4,11 @@ nix_worker_SOURCES = main.cc
nix_worker_LDADD = ../libmain/libmain.la ../libstore/libstore.la ../libutil/libutil.la \ nix_worker_LDADD = ../libmain/libmain.la ../libstore/libstore.la ../libutil/libutil.la \
../boost/format/libformat.la ${bdb_lib} ${aterm_lib} ../boost/format/libformat.la ${bdb_lib} ${aterm_lib}
main.o: help.txt.hh
%.txt.hh: %.txt
../bin2c/bin2c helpText < $< > $@ || (rm $@ && exit 1)
AM_CXXFLAGS = \ AM_CXXFLAGS = \
-I$(srcdir)/.. ${bdb_include} $(aterm_include) -I$(srcdir)/../libutil \ -I$(srcdir)/.. ${bdb_include} $(aterm_include) -I$(srcdir)/../libutil \
-I$(srcdir)/../libstore -I$(srcdir)/../libmain -I$(srcdir)/../libstore -I$(srcdir)/../libmain

10
src/nix-worker/help.txt Normal file
View file

@ -0,0 +1,10 @@
Usage: nix-worker [OPTIONS...] [--daemon | --slave]
`nix-worker' is a helper program used to implement secure, multi-user
Nix stores. In `--daemon' mode, it goes into the background and waits
for incoming connections on a Unix domain socket, and forks a process
for each connection to perform the Nix store operations requested by
the caller. In `--slave' mode, `nix-worker' is called directly, and
the caller and the worker communicate with each other over
stdin/stdout. In this mode, the `nix-worker' program should have
appropriate setuid privileges.

View file

@ -5,6 +5,8 @@
#include "worker-protocol.hh" #include "worker-protocol.hh"
#include "archive.hh" #include "archive.hh"
#include <iostream>
using namespace nix; using namespace nix;
@ -48,12 +50,13 @@ void processConnection(Source & from, Sink & to)
switch (op) { switch (op) {
case wopQuit: case wopQuit: {
/* Close the database. */ /* Close the database. */
store.reset((StoreAPI *) 0); store.reset((StoreAPI *) 0);
writeInt(1, to); writeInt(1, to);
quit = true; quit = true;
break; break;
}
case wopIsValidPath: { case wopIsValidPath: {
Path path = readStorePath(from); Path path = readStorePath(from);
@ -67,6 +70,12 @@ void processConnection(Source & from, Sink & to)
break; break;
} }
case wopQueryPathHash: {
Path path = readStorePath(from);
writeString(printHash(store->queryPathHash(path)), to);
break;
}
case wopQueryReferences: case wopQueryReferences:
case wopQueryReferrers: { case wopQueryReferrers: {
Path path = readStorePath(from); Path path = readStorePath(from);
@ -153,8 +162,11 @@ void run(Strings args)
} }
#include "help.txt.hh"
void printHelp() void printHelp()
{ {
std::cout << string((char *) helpText, sizeof helpText);
} }