about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-05-04T10·45+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-05-04T10·45+0000
commitf92c9a0ac585d30e245c6667cbce4b035659cb11 (patch)
tree4c9d10130d3ce67a4ca724170614f09a404e16aa
parent7fa338f4bac16f83b65b95fb0397b534d5ba5d5b (diff)
* Allow unprivileged users to do `nix-store --clear-failed-paths' and
  `nix-store --query-failed-paths'.

-rw-r--r--src/libstore/local-store.hh3
-rw-r--r--src/libstore/remote-store.cc19
-rw-r--r--src/libstore/remote-store.hh4
-rw-r--r--src/libstore/store-api.hh7
-rw-r--r--src/libstore/worker-protocol.hh2
-rw-r--r--src/nix-store/nix-store.cc4
-rw-r--r--src/nix-worker/nix-worker.cc17
7 files changed, 51 insertions, 5 deletions
diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh
index 2fd640e398c4..c1e0e335f225 100644
--- a/src/libstore/local-store.hh
+++ b/src/libstore/local-store.hh
@@ -184,11 +184,8 @@ public:
     /* Query whether `path' previously failed to build. */
     bool hasPathFailed(const Path & path);
 
-    /* Return the set of paths that have failed to build.*/
     PathSet queryFailedPaths();
 
-    /* Clear the "failed" status of the given paths.  The special
-       value `*' causes all failed paths to be cleared. */
     void clearFailedPaths(const PathSet & paths);
 
 private:
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index c5d7975b521b..334ad95cf9df 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -451,6 +451,25 @@ void RemoteStore::collectGarbage(const GCOptions & options, GCResults & results)
 }
 
 
+PathSet RemoteStore::queryFailedPaths()
+{
+    openConnection();
+    writeInt(wopQueryFailedPaths, to);
+    processStderr();
+    return readStorePaths(from);
+}
+
+
+void RemoteStore::clearFailedPaths(const PathSet & paths)
+{
+    openConnection();
+    writeInt(wopClearFailedPaths, to);
+    writeStringSet(paths, to);
+    processStderr();
+    readInt(from);
+}
+
+
 void RemoteStore::processStderr(Sink * sink, Source * source)
 {
     unsigned int msg;
diff --git a/src/libstore/remote-store.hh b/src/libstore/remote-store.hh
index 8bab1d8c4857..02a1c475252d 100644
--- a/src/libstore/remote-store.hh
+++ b/src/libstore/remote-store.hh
@@ -70,6 +70,10 @@ public:
 
     void collectGarbage(const GCOptions & options, GCResults & results);
     
+    PathSet queryFailedPaths();
+
+    void clearFailedPaths(const PathSet & paths);
+    
 private:
     AutoCloseFD fdSocket;
     FdSink to;
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index 095fdd24bb28..fbe0cce81e94 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -209,6 +209,13 @@ public:
 
     /* Perform a garbage collection. */
     virtual void collectGarbage(const GCOptions & options, GCResults & results) = 0;
+
+    /* Return the set of paths that have failed to build.*/
+    virtual PathSet queryFailedPaths() = 0;
+
+    /* Clear the "failed" status of the given paths.  The special
+       value `*' causes all failed paths to be cleared. */
+    virtual void clearFailedPaths(const PathSet & paths) = 0;
 };
 
 
diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh
index c3096010b6c4..392a69acf654 100644
--- a/src/libstore/worker-protocol.hh
+++ b/src/libstore/worker-protocol.hh
@@ -36,6 +36,8 @@ typedef enum {
     wopQuerySubstitutablePathInfo = 21,
     wopQueryDerivationOutputs = 22,
     wopQueryValidPaths = 23,
+    wopQueryFailedPaths = 24,
+    wopClearFailedPaths = 25,
 } WorkerOp;
 
 
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index 148fd6add48e..3b34b9dae6f4 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -670,7 +670,7 @@ static void opQueryFailedPaths(Strings opFlags, Strings opArgs)
 {
     if (!opArgs.empty() || !opFlags.empty())
         throw UsageError("no arguments expected");
-    PathSet failed = ensureLocalStore().queryFailedPaths();
+    PathSet failed = store->queryFailedPaths();
     foreach (PathSet::iterator, i, failed)
         cout << format("%1%\n") % *i;
 }
@@ -680,7 +680,7 @@ static void opClearFailedPaths(Strings opFlags, Strings opArgs)
 {
     if (!opFlags.empty())
         throw UsageError("no flags expected");
-    ensureLocalStore().clearFailedPaths(PathSet(opArgs.begin(), opArgs.end()));
+    store->clearFailedPaths(PathSet(opArgs.begin(), opArgs.end()));
 }
 
 
diff --git a/src/nix-worker/nix-worker.cc b/src/nix-worker/nix-worker.cc
index a41fb2e154af..d41877e881a0 100644
--- a/src/nix-worker/nix-worker.cc
+++ b/src/nix-worker/nix-worker.cc
@@ -528,6 +528,23 @@ static void performOp(unsigned int clientVersion,
         break;
     }
 
+    case wopQueryFailedPaths: {
+        startWork();
+        PathSet paths = store->queryFailedPaths();
+        stopWork();
+        writeStringSet(paths, to);
+        break;
+    }
+
+    case wopClearFailedPaths: {
+        PathSet paths = readStringSet(from);
+        startWork();
+        store->clearFailedPaths(paths);
+        stopWork();
+        writeInt(1, to);
+        break;
+    }
+
     default:
         throw Error(format("invalid operation %1%") % op);
     }