示例#1
0
 def testEnterSandbox(self):
     sandbox.EnterSandbox(self._user, self._group)
     self._mock_setresuid.assert_called_with(self._uid, self._uid,
                                             self._uid)
     self._mock_setresgid.assert_called_with(self._gid, self._gid,
                                             self._gid)
     self._mock_setgroups.assert_called_with([self._gid])
示例#2
0
def _EnterSandbox(user: str, group: str) -> None:
    if platform.system() == "Linux" or platform.system() == "Darwin":
        # pylint: disable=g-import-not-at-top
        from grr_response_client.unprivileged.unix import sandbox
        # pylint: enable=g-import-not-at-top
        sandbox.EnterSandbox(user, group)
示例#3
0
 def testEnterSandbox_nothing(self):
     sandbox.EnterSandbox("", "")
     self._mock_setresuid.assert_not_called()
     self._mock_setresgid.assert_not_called()
     self._mock_setgroups.assert_not_called()
示例#4
0
 def testEnterSandbox_groupOnly(self):
     sandbox.EnterSandbox("", self._group)
     self._mock_setresuid.assert_not_called()
     self._mock_setresgid.assert_called_with(self._gid, self._gid,
                                             self._gid)
     self._mock_setgroups.assert_called_with([self._gid])
示例#5
0
 def testEnterSandbox_userOnly(self):
     sandbox.EnterSandbox(self._user, "")
     self._mock_setresuid.assert_called_with(self._uid, self._uid,
                                             self._uid)
     self._mock_setresgid.assert_not_called()
     self._mock_setgroups.assert_not_called()