From e2f9ed1176b269fb61d2de4f163ed190d35459d9 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Mon, 24 Jan 2022 17:27:40 +0100 Subject: [PATCH] Test: Fix file permissions for system file tests --- test/testdotfile.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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" });