diff options
Diffstat (limited to 'src/libstore/local-store.cc')
-rw-r--r-- | src/libstore/local-store.cc | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 143f093e5bac..237800209714 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -710,7 +710,18 @@ void deleteFromStore(const Path & _path, unsigned long long & bytesFreed) } txn.commit(); - deletePath(path, bytesFreed); + try { + /* First try to delete it ourselves. */ + deletePath(path, bytesFreed); + } catch (SysError & e) { + /* If this failed due to a permission error, then try it with + the setuid helper. */ + if (haveBuildUsers() && !amPrivileged()) { + getOwnership(path); + deletePath(path, bytesFreed); + } else + throw; + } } |