1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-28 13:11:00 +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

@ -170,7 +170,7 @@ void RestoreSink::createRegularFile(const CanonPath & path, std::function<void(C
constexpr int flags = O_CREAT | O_EXCL | O_WRONLY | O_CLOEXEC;
if (!dirFd)
return ::open(p.c_str(), flags, 0666);
return ::openat(dirFd.get(), path.rel_c_str(), flags, 0666);
return unix::openFileEnsureBeneathNoSymlinks(dirFd.get(), path, flags, 0666);
}();
#endif
;