diff --git a/test/testdotfile.cpp b/test/testdotfile.cpp index e62fb12..41bf3a0 100644 --- a/test/testdotfile.cpp +++ b/test/testdotfile.cpp @@ -21,12 +21,12 @@ const std::string homeDirectory = "/home/" + Machine::the().username(); const size_t homeDirectorySize = homeDirectory.size(); -void createTestDotfiles(const std::vector& fileNames, const std::vector& fileContents) +void createTestDotfiles(const std::vector& fileNames, const std::vector& fileContents, bool asRoot = false) { VERIFY(fileNames.size() == fileContents.size()); bool root = !geteuid() ? true : false; - if (root) { + if (root && !asRoot) { setegid(Machine::the().gid()); seteuid(Machine::the().uid()); } @@ -45,7 +45,7 @@ void createTestDotfiles(const std::vector& fileNames, const std::ve } } - if (root) { + if (root && !asRoot) { seteuid(0); setegid(0); } @@ -216,7 +216,7 @@ TEST_CASE(PullSystemDotfiles) { VERIFY(geteuid() == 0); - createTestDotfiles({ "etc/group" }, { "" }); + createTestDotfiles({ "etc/group" }, { "" }, true); Dotfile::the().setSystemDirectories({ "/etc" }); Dotfile::the().pull({ "etc/group" });