[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: nix: Guard against removing temporary roots of li
From: |
guix-commits |
Subject: |
branch master updated: nix: Guard against removing temporary roots of living processes. |
Date: |
Fri, 07 Oct 2022 16:58:17 -0400 |
This is an automated email from the git hooks/post-receive script.
apteryx pushed a commit to branch master
in repository guix.
The following commit(s) were added to refs/heads/master by this push:
new bb0beaecde nix: Guard against removing temporary roots of living
processes.
bb0beaecde is described below
commit bb0beaecdee1a2315a1269b1746d238c8ab0e699
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Fri Oct 7 16:51:06 2022 -0400
nix: Guard against removing temporary roots of living processes.
Fixes <https://issues.guix.gnu.org/25018>.
* nix/libstore/gc.cc (readTempRoots): Add a check to guard against removing
the temporary roots of a living process.
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
---
nix/libstore/gc.cc | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/nix/libstore/gc.cc b/nix/libstore/gc.cc
index 16519116e4..f101de92d6 100644
--- a/nix/libstore/gc.cc
+++ b/nix/libstore/gc.cc
@@ -2,6 +2,7 @@
#include "misc.hh"
#include "local-store.hh"
+#include <string>
#include <functional>
#include <queue>
#include <algorithm>
@@ -226,10 +227,10 @@ static void readTempRoots(PathSet & tempRoots, FDs & fds)
//FDPtr fd(new AutoCloseFD(openLockFile(path, false)));
//if (*fd == -1) continue;
- /* Try to acquire a write lock without blocking. This can
- only succeed if the owning process has died. In that case
- we don't care about its temporary roots. */
- if (lockFile(*fd, ltWrite, false)) {
+ /* Try to acquire a write lock without blocking. This can only
+ succeed if the owning process has died, in which case we don't care
+ about its temporary roots, or if we are the owning process. */
+ if (i.name != std::to_string(getpid()) && lockFile(*fd, ltWrite,
false)) {
printMsg(lvlError, format("removing stale temporary roots file
`%1%'") % path);
unlink(path.c_str());
writeFull(*fd, "d");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: nix: Guard against removing temporary roots of living processes.,
guix-commits <=