OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <errno.h> | 5 #include <errno.h> |
6 #include <linux/unistd.h> | 6 #include <linux/unistd.h> |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <sys/prctl.h> | 8 #include <sys/prctl.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 } else { | 48 } else { |
49 #if defined(SECCOMP_BPF_STANDALONE) | 49 #if defined(SECCOMP_BPF_STANDALONE) |
50 Die::LogToStderr(msg, file, line); | 50 Die::LogToStderr(msg, file, line); |
51 #else | 51 #else |
52 logging::LogMessage(file, line, logging::LOG_FATAL).stream() << msg; | 52 logging::LogMessage(file, line, logging::LOG_FATAL).stream() << msg; |
53 #endif | 53 #endif |
54 } | 54 } |
55 ExitGroup(); | 55 ExitGroup(); |
56 } | 56 } |
57 | 57 |
| 58 void Die::RawSandboxDie(const char *msg) { |
| 59 if (!msg) |
| 60 msg = ""; |
| 61 RAW_LOG(FATAL, msg); |
| 62 ExitGroup(); |
| 63 } |
| 64 |
58 void Die::SandboxInfo(const char *msg, const char *file, int line) { | 65 void Die::SandboxInfo(const char *msg, const char *file, int line) { |
59 if (!suppress_info_) { | 66 if (!suppress_info_) { |
60 #if defined(SECCOMP_BPF_STANDALONE) | 67 #if defined(SECCOMP_BPF_STANDALONE) |
61 Die::LogToStderr(msg, file, line); | 68 Die::LogToStderr(msg, file, line); |
62 #else | 69 #else |
63 logging::LogMessage(file, line, logging::LOG_INFO).stream() << msg; | 70 logging::LogMessage(file, line, logging::LOG_INFO).stream() << msg; |
64 #endif | 71 #endif |
65 } | 72 } |
66 } | 73 } |
67 | 74 |
68 void Die::LogToStderr(const char *msg, const char *file, int line) { | 75 void Die::LogToStderr(const char *msg, const char *file, int line) { |
69 if (msg) { | 76 if (msg) { |
70 char buf[40]; | 77 char buf[40]; |
71 snprintf(buf, sizeof(buf), "%d", line); | 78 snprintf(buf, sizeof(buf), "%d", line); |
72 std::string s = std::string(file) + ":" + buf + ":" + msg + "\n"; | 79 std::string s = std::string(file) + ":" + buf + ":" + msg + "\n"; |
73 | 80 |
74 // No need to loop. Short write()s are unlikely and if they happen we | 81 // No need to loop. Short write()s are unlikely and if they happen we |
75 // probably prefer them over a loop that blocks. | 82 // probably prefer them over a loop that blocks. |
76 if (HANDLE_EINTR(SandboxSyscall(__NR_write, 2, s.c_str(), s.length()))) { } | 83 if (HANDLE_EINTR(SandboxSyscall(__NR_write, 2, s.c_str(), s.length()))) { } |
77 } | 84 } |
78 } | 85 } |
79 | 86 |
80 bool Die::simple_exit_ = false; | 87 bool Die::simple_exit_ = false; |
81 bool Die::suppress_info_ = false; | 88 bool Die::suppress_info_ = false; |
82 | 89 |
83 } // namespace | 90 } // namespace |
OLD | NEW |