1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-14 13:01:05 +01:00

libutil: Use openFileEnsureBeneathNoSymlinks in RestoreSink::createRegularFile

Add more assertions for preconditions of openFileEnsureBeneathNoSymlinks to prevent
misuse. Also start using it for regular file creation as well.
This commit is contained in:
Sergei Zimmerman 2025-11-26 03:47:42 +03:00
parent 6cc44e4fdf
commit 0778b861a9
No known key found for this signature in database
4 changed files with 10 additions and 1 deletions

View file

@ -351,6 +351,10 @@ TEST(openFileEnsureBeneathNoSymlinks, works)
sink.createDirectory(
CanonPath("a/b/c/f"), [](FileSystemObjectSink & dirSink, const CanonPath & relPath) {}),
SymlinkNotAllowed);
ASSERT_THROW(
sink.createRegularFile(
CanonPath("a/b/c/regular"), [](CreateRegularFileSink & crf) { crf("some contents"); }),
SymlinkNotAllowed);
}
AutoCloseFD dirFd = openDirectory(tmpDir);