1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-21 09:49:36 +01:00

Merge pull request #14110 from Mic92/ptsname

Fix thread-safety issue with ptsname() usage
This commit is contained in:
Jörg Thalheim 2025-09-29 13:49:58 +02:00 committed by GitHub
commit b6f4788a8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 39 additions and 3 deletions

View file

@ -18,6 +18,7 @@
#include "nix/store/user-lock.hh"
#include "nix/store/globals.hh"
#include "nix/store/build/derivation-env-desugar.hh"
#include "nix/util/terminal.hh"
#include <queue>
@ -808,8 +809,7 @@ std::optional<Descriptor> DerivationBuilderImpl::startBuild()
if (!builderOut)
throw SysError("opening pseudoterminal master");
// FIXME: not thread-safe, use ptsname_r
std::string slaveName = ptsname(builderOut.get());
std::string slaveName = getPtsName(builderOut.get());
if (buildUser) {
if (chmod(slaveName.c_str(), 0600))
@ -923,7 +923,7 @@ void DerivationBuilderImpl::prepareSandbox()
void DerivationBuilderImpl::openSlave()
{
std::string slaveName = ptsname(builderOut.get());
std::string slaveName = getPtsName(builderOut.get());
AutoCloseFD builderOut = open(slaveName.c_str(), O_RDWR | O_NOCTTY);
if (!builderOut)