OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/test/nacl_security_tests/nacl_security_tests_posix.h" | |
6 #include <string> | |
7 #include "chrome/test/nacl_security_tests/commands_posix.h" | |
8 | |
9 #define RETURN_IF_NOT_DENIED(x) \ | |
10 if (sandbox::SBOX_TEST_DENIED != x) { \ | |
11 return false; \ | |
12 } | |
13 | |
14 // Runs the security tests of sandbox for the nacl loader process. | |
15 extern "C" bool RunNaClLoaderTests(void) { | |
16 // Need to check if the system supports CLONE_NEWPID before testing | |
17 // the filesystem accesses (otherwise the sandbox is not enabled). | |
18 RETURN_IF_NOT_DENIED(sandbox::TestOpenReadFile("/etc")); | |
19 RETURN_IF_NOT_DENIED(sandbox::TestOpenReadFile("/tmp")); | |
20 RETURN_IF_NOT_DENIED(sandbox::TestOpenReadFile("$HOME")); | |
21 RETURN_IF_NOT_DENIED(sandbox::TestOpenWriteFile("/etc")); | |
22 RETURN_IF_NOT_DENIED(sandbox::TestOpenWriteFile("/etc/passwd")); | |
23 RETURN_IF_NOT_DENIED(sandbox::TestOpenWriteFile("/bin")); | |
24 RETURN_IF_NOT_DENIED(sandbox::TestOpenWriteFile("/usr/bin")); | |
25 RETURN_IF_NOT_DENIED(sandbox::TestOpenWriteFile("/usr/bin/bash")); | |
26 RETURN_IF_NOT_DENIED(sandbox::TestOpenWriteFile("/usr/bin/login")); | |
27 RETURN_IF_NOT_DENIED(sandbox::TestOpenWriteFile("/usr/sbin")); | |
28 RETURN_IF_NOT_DENIED(sandbox::TestOpenWriteFile("$HOME")); | |
29 | |
30 // Linux (suid) sandbox doesn't block connect, etc... | |
31 RETURN_IF_NOT_DENIED(sandbox::TestCreateProcess("/usr/bin/env")); | |
32 RETURN_IF_NOT_DENIED(sandbox::TestConnect("www.archive.org")); | |
33 | |
34 return true; | |
35 } | |
36 | |
OLD | NEW |