From 3cbf143da6c6213a184b7562555cf0cfee3ca133 Mon Sep 17 00:00:00 2001 From: aszlig Date: Thu, 20 Sep 2018 16:46:49 +0200 Subject: pkgs/sandbox: Add UTS/PID/IPC namespacing In order to isolate processes even further it's a good idea to not let them access information about other PIDs, eg. by enumerating /proc. However, this still bind-mounts /sys from the root namespace, so we might want to restrict /sys further. For our games however we will need /sys because it is used to enumerate gamepads and other input devices. Currently the processes will now be PID 1. I've tested this against a few games and none of them had problems with that so far, so let's keep it that way. Another thing we might want to add and which currently isn't there is a subreaper, which is useful if we have a process that leaves zombie processes around. Signed-off-by: aszlig --- tests/sandbox.nix | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/sandbox.nix b/tests/sandbox.nix index f3013b2e..e92099bf 100644 --- a/tests/sandbox.nix +++ b/tests/sandbox.nix @@ -37,6 +37,11 @@ # Should fail because we can't access the host's PATH ! echo foo | grep -qF foo + # Write PID information to files, so that we can later verify whether + # we were in a PID namespace. + echo $$ > /home/foo/.cache/xdg/ownpid + ls -d1 /proc/[0-9]* > /home/foo/.cache/xdg/procpids + # Check whether we can access files behind nested storepaths that are # symlinks. lfile="$(< ${mkNestedLinksTo (pkgs.writeText "target" "file")})" @@ -116,5 +121,8 @@ $machine->succeed('grep -qF XDG1 /home/foo/.local/share/xdg/1'); $machine->succeed('grep -qF XDG2 /home/foo/.config/xdg/2'); $machine->succeed('grep -qF XDG3 /home/foo/.cache/xdg/3'); + + $machine->succeed('test "$(< /home/foo/.cache/xdg/procpids)" = /proc/1'); + $machine->succeed('test "$(< /home/foo/.cache/xdg/ownpid)" = 1'); ''; } -- cgit 1.4.1