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:
parent
6cc44e4fdf
commit
0778b861a9
4 changed files with 10 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue