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