about summary refs log tree commit diff
path: root/src/libutil/util.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2007-02-21T14·31+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2007-02-21T14·31+0000
commit46e0919ced4646004cc0701b188d0a68e24e8924 (patch)
tree3262f8068c38489029753c528a123b2c685aea68 /src/libutil/util.cc
parent6c9fdb17fbda181fc09a9ce1f49662ef522d006b (diff)
* `nix-store --export --sign': sign the Nix archive using the RSA key
  in /nix/etc/nix/signing-key.sec

Diffstat (limited to 'src/libutil/util.cc')
-rw-r--r--src/libutil/util.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index fb6411408d08..7671c7c7e460 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -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) {