| 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 "crash-reporter/system_logging.h" | 20 #include "crash-reporter/system_logging.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"; | |
| 28 | 27 |
| 29 // Directory mode of the user crash spool directory. | 28 // Directory mode of the user crash spool directory. |
| 30 static const mode_t kUserCrashPathMode = 0755; | 29 static const mode_t kUserCrashPathMode = 0755; |
| 31 | 30 |
| 32 // Directory mode of the system crash spool directory. | 31 // Directory mode of the system crash spool directory. |
| 33 static const mode_t kSystemCrashPathMode = 01755; | 32 static const mode_t kSystemCrashPathMode = 01755; |
| 34 | 33 |
| 35 static const uid_t kRootOwner = 0; | 34 static const uid_t kRootOwner = 0; |
| 36 static const uid_t kRootGroup = 0; | 35 static const uid_t kRootGroup = 0; |
| 37 | 36 |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 version.c_str(), | 403 version.c_str(), |
| 405 payload_path.c_str(), | 404 payload_path.c_str(), |
| 406 payload_size); | 405 payload_size); |
| 407 // We must use WriteNewFile instead of file_util::WriteFile as we | 406 // We must use WriteNewFile instead of file_util::WriteFile as we |
| 408 // do not want to write with root access to a symlink that an attacker | 407 // do not want to write with root access to a symlink that an attacker |
| 409 // might have created. | 408 // might have created. |
| 410 if (WriteNewFile(meta_path, meta_data.c_str(), meta_data.size()) < 0) { | 409 if (WriteNewFile(meta_path, meta_data.c_str(), meta_data.size()) < 0) { |
| 411 logger_->LogError("Unable to write %s", meta_path.value().c_str()); | 410 logger_->LogError("Unable to write %s", meta_path.value().c_str()); |
| 412 } | 411 } |
| 413 } | 412 } |
| 414 | |
| 415 bool CrashCollector::IsCrashTestInProgress() { | |
| 416 return file_util::PathExists(FilePath(kCrashTestInProgressPath)); | |
| 417 } | |
| OLD | NEW |