about summary refs log tree commit diff
path: root/src/libutil/util.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-07-12T12·01+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-07-12T12·03+0200
commitaeb810b01e17d040f9592681ee271f15874dce50 (patch)
treefbf5e93aeb43f6b900f4c813ea5655385b041bdf /src/libutil/util.cc
parent25a00cae5bf702b9e844b05923a9c59de9df6788 (diff)
Garbage collector: Don't follow symlinks arbitrarily
Only indirect roots (symlinks to symlinks to the Nix store) are now
supported.
Diffstat (limited to 'src/libutil/util.cc')
-rw-r--r--src/libutil/util.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index b1231e4557..dad5f624bd 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -148,6 +148,15 @@ string baseNameOf(const Path & path)
 }
 
 
+bool isInDir(const Path & path, const Path & dir)
+{
+    return path[0] == '/'
+        && string(path, 0, dir.size()) == dir
+        && path.size() >= dir.size() + 2
+        && path[dir.size()] == '/';
+}
+
+
 struct stat lstat(const Path & path)
 {
     struct stat st;