mirror of
https://github.com/NixOS/nix
synced 2025-06-27 08:31:16 +02:00
* `nix-store --export --sign': sign the Nix archive using the RSA key
in /nix/etc/nix/signing-key.sec
This commit is contained in:
parent
6c9fdb17fb
commit
46e0919ced
8 changed files with 125 additions and 32 deletions
|
@ -282,27 +282,36 @@ Hash hashFile(HashType ht, const Path & path)
|
|||
}
|
||||
|
||||
|
||||
struct HashSink : Sink
|
||||
HashSink::HashSink(HashType ht) : ht(ht)
|
||||
{
|
||||
HashType ht;
|
||||
Ctx ctx;
|
||||
virtual void operator ()
|
||||
(const unsigned char * data, unsigned int len)
|
||||
{
|
||||
update(ht, ctx, data, len);
|
||||
}
|
||||
};
|
||||
ctx = new Ctx;
|
||||
start(ht, *ctx);
|
||||
}
|
||||
|
||||
HashSink::~HashSink()
|
||||
{
|
||||
delete ctx;
|
||||
}
|
||||
|
||||
void HashSink::operator ()
|
||||
(const unsigned char * data, unsigned int len)
|
||||
{
|
||||
update(ht, *ctx, data, len);
|
||||
}
|
||||
|
||||
Hash HashSink::finish()
|
||||
{
|
||||
Hash hash(ht);
|
||||
nix::finish(ht, *ctx, hash.hash);
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
Hash hashPath(HashType ht, const Path & path, PathFilter & filter)
|
||||
{
|
||||
HashSink sink;
|
||||
sink.ht = ht;
|
||||
Hash hash(ht);
|
||||
start(ht, sink.ctx);
|
||||
HashSink sink(ht);
|
||||
dumpPath(path, sink, filter);
|
||||
finish(ht, sink.ctx, hash.hash);
|
||||
return hash;
|
||||
return sink.finish();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define __HASH_H
|
||||
|
||||
#include "types.hh"
|
||||
#include "serialise.hh"
|
||||
|
||||
|
||||
namespace nix {
|
||||
|
@ -81,7 +82,23 @@ Hash compressHash(const Hash & hash, unsigned int newSize);
|
|||
/* Parse a string representing a hash type. */
|
||||
HashType parseHashType(const string & s);
|
||||
|
||||
|
||||
|
||||
typedef union Ctx;
|
||||
|
||||
class HashSink : public Sink
|
||||
{
|
||||
private:
|
||||
HashType ht;
|
||||
Ctx * ctx;
|
||||
|
||||
public:
|
||||
HashSink(HashType ht);
|
||||
~HashSink();
|
||||
virtual void operator () (const unsigned char * data, unsigned int len);
|
||||
Hash finish();
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -761,7 +761,7 @@ void killUser(uid_t uid)
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
string runProgram(Path program)
|
||||
string runProgram(Path program, bool searchPath, const Strings & args)
|
||||
{
|
||||
/* Create a pipe. */
|
||||
Pipe pipe;
|
||||
|
@ -781,8 +781,17 @@ string runProgram(Path program)
|
|||
|
||||
if (dup2(pipe.writeSide, STDOUT_FILENO) == -1)
|
||||
throw SysError("dupping from-hook write side");
|
||||
|
||||
execl(program.c_str(), program.c_str(), (char *) 0);
|
||||
|
||||
std::vector<const char *> cargs; /* careful with c_str()! */
|
||||
cargs.push_back(program.c_str());
|
||||
for (Strings::const_iterator i = args.begin(); i != args.end(); ++i)
|
||||
cargs.push_back(i->c_str());
|
||||
cargs.push_back(0);
|
||||
|
||||
if (searchPath)
|
||||
execvp(program.c_str(), (char * *) &cargs[0]);
|
||||
else
|
||||
execv(program.c_str(), (char * *) &cargs[0]);
|
||||
throw SysError(format("executing `%1%'") % program);
|
||||
|
||||
} catch (std::exception & e) {
|
||||
|
|
|
@ -231,7 +231,8 @@ void killUser(uid_t uid);
|
|||
|
||||
/* Run a program and return its stdout in a string (i.e., like the
|
||||
shell backtick operator). */
|
||||
string runProgram(Path program);
|
||||
string runProgram(Path program, bool searchPath = false,
|
||||
const Strings & args = Strings());
|
||||
|
||||
/* Wrapper around _exit() on Unix and ExitProcess() on Windows. (On
|
||||
Cygwin, _exit() doesn't seem to do the right thing.) */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue