mirror of
https://github.com/dlang/phobos.git
synced 2025-05-01 15:40:36 +03:00
std.process: Skip permission test when running as root
A spawnProcess unittest checks that we are unable to enter a directory if we don't have the right permissions. However, programs running under the root user can chdir to a directory, despite it not having execute permissions. Thus, skip this test when running as root.
This commit is contained in:
parent
2882ff113f
commit
d777855000
1 changed files with 10 additions and 7 deletions
|
@ -1188,13 +1188,16 @@ version (Posix) @system unittest
|
||||||
// can't run in directory if user does not have search permission on this directory
|
// can't run in directory if user does not have search permission on this directory
|
||||||
version(Posix)
|
version(Posix)
|
||||||
{
|
{
|
||||||
import core.sys.posix.sys.stat : S_IRUSR;
|
if (core.sys.posix.unistd.getuid() != 0)
|
||||||
auto directoryNoSearch = uniqueTempPath();
|
{
|
||||||
mkdir(directoryNoSearch);
|
import core.sys.posix.sys.stat : S_IRUSR;
|
||||||
scope(exit) rmdirRecurse(directoryNoSearch);
|
auto directoryNoSearch = uniqueTempPath();
|
||||||
setAttributes(directoryNoSearch, S_IRUSR);
|
mkdir(directoryNoSearch);
|
||||||
assertThrown!ProcessException(spawnProcess(prog.path, null, Config.none, directoryNoSearch));
|
scope(exit) rmdirRecurse(directoryNoSearch);
|
||||||
assertThrown!ProcessException(spawnProcess(prog.path, null, Config.detached, directoryNoSearch));
|
setAttributes(directoryNoSearch, S_IRUSR);
|
||||||
|
assertThrown!ProcessException(spawnProcess(prog.path, null, Config.none, directoryNoSearch));
|
||||||
|
assertThrown!ProcessException(spawnProcess(prog.path, null, Config.detached, directoryNoSearch));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue