mirror of
https://github.com/NixOS/nix.git
synced 2025-12-22 17:01:08 +01:00
Merge pull request #14848 from NixOS/backport-14785-to-2.31-maintenance
[Backport 2.31-maintenance] libstore: include path in the world-writable error
This commit is contained in:
commit
9b597aa64f
1 changed files with 5 additions and 6 deletions
|
|
@ -652,17 +652,17 @@ static void handleChildException(bool sendException)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool checkNotWorldWritable(std::filesystem::path path)
|
static void checkNotWorldWritable(std::filesystem::path path)
|
||||||
{
|
{
|
||||||
while (true) {
|
while (true) {
|
||||||
auto st = lstat(path);
|
auto st = lstat(path);
|
||||||
if (st.st_mode & S_IWOTH)
|
if (st.st_mode & S_IWOTH)
|
||||||
return false;
|
throw Error("Path %s is world-writable or a symlink. That's not allowed for security.", path);
|
||||||
if (path == path.parent_path())
|
if (path == path.parent_path())
|
||||||
break;
|
break;
|
||||||
path = path.parent_path();
|
path = path.parent_path();
|
||||||
}
|
}
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DerivationBuilderImpl::startBuilder()
|
void DerivationBuilderImpl::startBuilder()
|
||||||
|
|
@ -700,9 +700,8 @@ void DerivationBuilderImpl::startBuilder()
|
||||||
|
|
||||||
createDirs(buildDir);
|
createDirs(buildDir);
|
||||||
|
|
||||||
if (buildUser && !checkNotWorldWritable(buildDir))
|
if (buildUser)
|
||||||
throw Error(
|
checkNotWorldWritable(buildDir);
|
||||||
"Path %s or a parent directory is world-writable or a symlink. That's not allowed for security.", buildDir);
|
|
||||||
|
|
||||||
/* Create a temporary directory where the build will take
|
/* Create a temporary directory where the build will take
|
||||||
place. */
|
place. */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue