about summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/build.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 0d2879cc94a5..9f3420c684b6 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -1698,10 +1698,13 @@ void DerivationGoal::initChild()
 void DerivationGoal::deleteTmpDir(bool force)
 {
     if (tmpDir != "") {
-        if (keepFailed && !force)
+        if (keepFailed && !force) {
 	    printMsg(lvlError, 
 		format("builder for `%1%' failed; keeping build directory `%2%'")
                 % drvPath % tmpDir);
+            if (buildUser.enabled() && !amPrivileged())
+                getOwnership(tmpDir);
+        }
         else
             deletePathWrapped(tmpDir);
         tmpDir = "";