OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 "crash-reporter/crash_collector.h" | 5 #include "crash-reporter/crash_collector.h" |
6 | 6 |
7 #include <dirent.h> | 7 #include <dirent.h> |
8 #include <fcntl.h> // For file creation modes. | 8 #include <fcntl.h> // For file creation modes. |
9 #include <pwd.h> // For struct passwd. | 9 #include <pwd.h> // For struct passwd. |
10 #include <sys/types.h> // for mode_t. | 10 #include <sys/types.h> // for mode_t. |
11 #include <sys/wait.h> // For waitpid. | 11 #include <sys/wait.h> // For waitpid. |
12 #include <unistd.h> // For execv and fork. | 12 #include <unistd.h> // For execv and fork. |
13 | 13 |
14 #include <set> | 14 #include <set> |
15 | 15 |
16 #include "base/eintr_wrapper.h" | 16 #include "base/eintr_wrapper.h" |
17 #include "base/file_util.h" | 17 #include "base/file_util.h" |
18 #include "base/logging.h" | 18 #include "base/logging.h" |
19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
20 #include "chromeos/process.h" | 20 #include "chromeos/process.h" |
21 | 21 |
22 static const char kDefaultUserName[] = "chronos"; | 22 static const char kDefaultUserName[] = "chronos"; |
23 static const char kLsbRelease[] = "/etc/lsb-release"; | 23 static const char kLsbRelease[] = "/etc/lsb-release"; |
24 static const char kShellPath[] = "/bin/sh"; | 24 static const char kShellPath[] = "/bin/sh"; |
25 static const char kSystemCrashPath[] = "/var/spool/crash"; | 25 static const char kSystemCrashPath[] = "/var/spool/crash"; |
26 static const char kUserCrashPath[] = "/home/chronos/user/crash"; | 26 static const char kUserCrashPath[] = "/home/chronos/user/crash"; |
| 27 static const char kCrashTestInProgressPath[] = "/tmp/crash-test-in-progress"; |
27 | 28 |
28 // Directory mode of the user crash spool directory. | 29 // Directory mode of the user crash spool directory. |
29 static const mode_t kUserCrashPathMode = 0755; | 30 static const mode_t kUserCrashPathMode = 0755; |
30 | 31 |
31 // Directory mode of the system crash spool directory. | 32 // Directory mode of the system crash spool directory. |
32 static const mode_t kSystemCrashPathMode = 01755; | 33 static const mode_t kSystemCrashPathMode = 01755; |
33 | 34 |
34 static const uid_t kRootOwner = 0; | 35 static const uid_t kRootOwner = 0; |
35 static const uid_t kRootGroup = 0; | 36 static const uid_t kRootGroup = 0; |
36 | 37 |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 version.c_str(), | 343 version.c_str(), |
343 payload_path.c_str(), | 344 payload_path.c_str(), |
344 payload_size); | 345 payload_size); |
345 // We must use WriteNewFile instead of file_util::WriteFile as we | 346 // We must use WriteNewFile instead of file_util::WriteFile as we |
346 // do not want to write with root access to a symlink that an attacker | 347 // do not want to write with root access to a symlink that an attacker |
347 // might have created. | 348 // might have created. |
348 if (WriteNewFile(meta_path, meta_data.c_str(), meta_data.size()) < 0) { | 349 if (WriteNewFile(meta_path, meta_data.c_str(), meta_data.size()) < 0) { |
349 LOG(ERROR) << "Unable to write " << meta_path.value(); | 350 LOG(ERROR) << "Unable to write " << meta_path.value(); |
350 } | 351 } |
351 } | 352 } |
| 353 |
| 354 bool CrashCollector::IsCrashTestInProgress() { |
| 355 return file_util::PathExists(FilePath(kCrashTestInProgressPath)); |
| 356 } |
OLD | NEW |