mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 06:00:35 +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
|
||||
version(Posix)
|
||||
{
|
||||
import core.sys.posix.sys.stat : S_IRUSR;
|
||||
auto directoryNoSearch = uniqueTempPath();
|
||||
mkdir(directoryNoSearch);
|
||||
scope(exit) rmdirRecurse(directoryNoSearch);
|
||||
setAttributes(directoryNoSearch, S_IRUSR);
|
||||
assertThrown!ProcessException(spawnProcess(prog.path, null, Config.none, directoryNoSearch));
|
||||
assertThrown!ProcessException(spawnProcess(prog.path, null, Config.detached, directoryNoSearch));
|
||||
if (core.sys.posix.unistd.getuid() != 0)
|
||||
{
|
||||
import core.sys.posix.sys.stat : S_IRUSR;
|
||||
auto directoryNoSearch = uniqueTempPath();
|
||||
mkdir(directoryNoSearch);
|
||||
scope(exit) rmdirRecurse(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