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