Example #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])
Example #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)
Example #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()
Example #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])
Example #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()