Skip to content

Commit

Permalink
local-store: fix infinite loop on Windows
Browse files Browse the repository at this point in the history
Also switch to std::filesystem.
  • Loading branch information
puffnfresh committed Jan 14, 2025
1 parent 2e2198f commit 3bd7fa3
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/libstore/local-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,15 @@ LocalStore::LocalStore(

/* Ensure that the store and its parents are not symlinks. */
if (!settings.allowSymlinkedStore) {
Path path = realStoreDir;
struct stat st;
while (path != "/") {
st = lstat(path);
if (S_ISLNK(st.st_mode))
std::filesystem::path path = realStoreDir.get();
std::filesystem::path root = path.root_path();
while (path != root) {
if (std::filesystem::is_symlink(path))
throw Error(
"the path '%1%' is a symlink; "
"this is not allowed for the Nix store and its parent directories",
path);
path = dirOf(path);
path = path.parent_path();
}
}

Expand Down

0 comments on commit 3bd7fa3

Please sign in to comment.