Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "crash-reporter/crash_collector.h" |
| 6 | |
Ken Mixter | 04ec10f | 2010-08-26 16:02:02 -0700 | [diff] [blame] | 7 | #include <dirent.h> |
Ken Mixter | 9b34647 | 2010-11-07 13:45:45 -0800 | [diff] [blame] | 8 | #include <fcntl.h> // For file creation modes. |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 9 | #include <pwd.h> // For struct passwd. |
| 10 | #include <sys/types.h> // for mode_t. |
Ken Mixter | 9b34647 | 2010-11-07 13:45:45 -0800 | [diff] [blame] | 11 | #include <sys/wait.h> // For waitpid. |
| 12 | #include <unistd.h> // For execv and fork. |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 13 | |
Ken Mixter | ee849c5 | 2010-09-30 15:30:10 -0700 | [diff] [blame] | 14 | #include <set> |
| 15 | |
Ken Mixter | 9b34647 | 2010-11-07 13:45:45 -0800 | [diff] [blame] | 16 | #include "base/eintr_wrapper.h" |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 17 | #include "base/file_util.h" |
| 18 | #include "base/logging.h" |
| 19 | #include "base/string_util.h" |
Ken Mixter | a324932 | 2011-03-03 08:47:38 -0800 | [diff] [blame] | 20 | #include "chromeos/process.h" |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 21 | |
| 22 | static const char kDefaultUserName[] = "chronos"; |
Ken Mixter | ee849c5 | 2010-09-30 15:30:10 -0700 | [diff] [blame] | 23 | static const char kLsbRelease[] = "/etc/lsb-release"; |
Ken Mixter | c49dbd4 | 2010-12-14 17:44:11 -0800 | [diff] [blame] | 24 | static const char kShellPath[] = "/bin/sh"; |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 25 | static const char kSystemCrashPath[] = "/var/spool/crash"; |
| 26 | static const char kUserCrashPath[] = "/home/chronos/user/crash"; |
Thieu Le | 1652fb2 | 2011-03-03 12:14:43 -0800 | [diff] [blame^] | 27 | static const char kCrashTestInProgressPath[] = "/tmp/crash-test-in-progress"; |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 28 | |
| 29 | // Directory mode of the user crash spool directory. |
| 30 | static const mode_t kUserCrashPathMode = 0755; |
| 31 | |
| 32 | // Directory mode of the system crash spool directory. |
| 33 | static const mode_t kSystemCrashPathMode = 01755; |
| 34 | |
| 35 | static const uid_t kRootOwner = 0; |
| 36 | static const uid_t kRootGroup = 0; |
| 37 | |
Ken Mixter | da5db7a | 2010-09-17 13:50:42 -0700 | [diff] [blame] | 38 | // Maximum crash reports per crash spool directory. Note that this is |
| 39 | // a separate maximum from the maximum rate at which we upload these |
| 40 | // diagnostics. The higher this rate is, the more space we allow for |
| 41 | // core files, minidumps, and kcrash logs, and equivalently the more |
| 42 | // processor and I/O bandwidth we dedicate to handling these crashes when |
| 43 | // many occur at once. Also note that if core files are configured to |
| 44 | // be left on the file system, we stop adding crashes when either the |
| 45 | // number of core files or minidumps reaches this number. |
| 46 | const int CrashCollector::kMaxCrashDirectorySize = 32; |
Ken Mixter | 04ec10f | 2010-08-26 16:02:02 -0700 | [diff] [blame] | 47 | |
Ken Mixter | afcf808 | 2010-10-26 14:45:01 -0700 | [diff] [blame] | 48 | CrashCollector::CrashCollector() |
| 49 | : forced_crash_directory_(NULL), |
| 50 | lsb_release_(kLsbRelease) { |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | CrashCollector::~CrashCollector() { |
| 54 | } |
| 55 | |
| 56 | void CrashCollector::Initialize( |
| 57 | CrashCollector::CountCrashFunction count_crash_function, |
Ken Mixter | a324932 | 2011-03-03 08:47:38 -0800 | [diff] [blame] | 58 | CrashCollector::IsFeedbackAllowedFunction is_feedback_allowed_function) { |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 59 | CHECK(count_crash_function != NULL); |
| 60 | CHECK(is_feedback_allowed_function != NULL); |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 61 | |
| 62 | count_crash_function_ = count_crash_function; |
| 63 | is_feedback_allowed_function_ = is_feedback_allowed_function; |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Ken Mixter | 9b34647 | 2010-11-07 13:45:45 -0800 | [diff] [blame] | 66 | int CrashCollector::WriteNewFile(const FilePath &filename, |
| 67 | const char *data, |
| 68 | int size) { |
| 69 | int fd = HANDLE_EINTR(open(filename.value().c_str(), |
| 70 | O_CREAT | O_WRONLY | O_TRUNC | O_EXCL, 0666)); |
| 71 | if (fd < 0) { |
| 72 | return -1; |
| 73 | } |
| 74 | |
| 75 | int rv = file_util::WriteFileDescriptor(fd, data, size); |
| 76 | HANDLE_EINTR(close(fd)); |
| 77 | return rv; |
| 78 | } |
| 79 | |
Ken Mixter | ee849c5 | 2010-09-30 15:30:10 -0700 | [diff] [blame] | 80 | std::string CrashCollector::Sanitize(const std::string &name) { |
| 81 | std::string result = name; |
| 82 | for (size_t i = 0; i < name.size(); ++i) { |
| 83 | if (!isalnum(result[i]) && result[i] != '_') |
| 84 | result[i] = '_'; |
| 85 | } |
| 86 | return result; |
| 87 | } |
| 88 | |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 89 | std::string CrashCollector::FormatDumpBasename(const std::string &exec_name, |
| 90 | time_t timestamp, |
| 91 | pid_t pid) { |
| 92 | struct tm tm; |
| 93 | localtime_r(×tamp, &tm); |
Ken Mixter | ee849c5 | 2010-09-30 15:30:10 -0700 | [diff] [blame] | 94 | std::string sanitized_exec_name = Sanitize(exec_name); |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 95 | return StringPrintf("%s.%04d%02d%02d.%02d%02d%02d.%d", |
Ken Mixter | ee849c5 | 2010-09-30 15:30:10 -0700 | [diff] [blame] | 96 | sanitized_exec_name.c_str(), |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 97 | tm.tm_year + 1900, |
| 98 | tm.tm_mon + 1, |
| 99 | tm.tm_mday, |
| 100 | tm.tm_hour, |
| 101 | tm.tm_min, |
| 102 | tm.tm_sec, |
| 103 | pid); |
| 104 | } |
| 105 | |
Ken Mixter | 207694d | 2010-10-28 15:42:37 -0700 | [diff] [blame] | 106 | FilePath CrashCollector::GetCrashPath(const FilePath &crash_directory, |
| 107 | const std::string &basename, |
| 108 | const std::string &extension) { |
| 109 | return crash_directory.Append(StringPrintf("%s.%s", |
| 110 | basename.c_str(), |
| 111 | extension.c_str())); |
| 112 | } |
| 113 | |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 114 | FilePath CrashCollector::GetCrashDirectoryInfo( |
| 115 | uid_t process_euid, |
| 116 | uid_t default_user_id, |
| 117 | gid_t default_user_group, |
| 118 | mode_t *mode, |
| 119 | uid_t *directory_owner, |
| 120 | gid_t *directory_group) { |
| 121 | if (process_euid == default_user_id) { |
| 122 | *mode = kUserCrashPathMode; |
| 123 | *directory_owner = default_user_id; |
| 124 | *directory_group = default_user_group; |
| 125 | return FilePath(kUserCrashPath); |
| 126 | } else { |
| 127 | *mode = kSystemCrashPathMode; |
| 128 | *directory_owner = kRootOwner; |
| 129 | *directory_group = kRootGroup; |
| 130 | return FilePath(kSystemCrashPath); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | bool CrashCollector::GetUserInfoFromName(const std::string &name, |
| 135 | uid_t *uid, |
| 136 | gid_t *gid) { |
| 137 | char storage[256]; |
| 138 | struct passwd passwd_storage; |
| 139 | struct passwd *passwd_result = NULL; |
| 140 | |
| 141 | if (getpwnam_r(name.c_str(), &passwd_storage, storage, sizeof(storage), |
| 142 | &passwd_result) != 0 || passwd_result == NULL) { |
Ken Mixter | a324932 | 2011-03-03 08:47:38 -0800 | [diff] [blame] | 143 | LOG(ERROR) << "Cannot find user named " << name; |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 144 | return false; |
| 145 | } |
| 146 | |
| 147 | *uid = passwd_result->pw_uid; |
| 148 | *gid = passwd_result->pw_gid; |
| 149 | return true; |
| 150 | } |
| 151 | |
| 152 | bool CrashCollector::GetCreatedCrashDirectoryByEuid(uid_t euid, |
Ken Mixter | 207694d | 2010-10-28 15:42:37 -0700 | [diff] [blame] | 153 | FilePath *crash_directory, |
| 154 | bool *out_of_capacity) { |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 155 | uid_t default_user_id; |
| 156 | gid_t default_user_group; |
| 157 | |
Ken Mixter | 207694d | 2010-10-28 15:42:37 -0700 | [diff] [blame] | 158 | if (out_of_capacity != NULL) *out_of_capacity = false; |
| 159 | |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 160 | // For testing. |
| 161 | if (forced_crash_directory_ != NULL) { |
| 162 | *crash_directory = FilePath(forced_crash_directory_); |
| 163 | return true; |
| 164 | } |
| 165 | |
| 166 | if (!GetUserInfoFromName(kDefaultUserName, |
| 167 | &default_user_id, |
| 168 | &default_user_group)) { |
Ken Mixter | a324932 | 2011-03-03 08:47:38 -0800 | [diff] [blame] | 169 | LOG(ERROR) << "Could not find default user info"; |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 170 | return false; |
| 171 | } |
| 172 | mode_t directory_mode; |
| 173 | uid_t directory_owner; |
| 174 | gid_t directory_group; |
| 175 | *crash_directory = |
| 176 | GetCrashDirectoryInfo(euid, |
| 177 | default_user_id, |
| 178 | default_user_group, |
| 179 | &directory_mode, |
| 180 | &directory_owner, |
| 181 | &directory_group); |
| 182 | |
| 183 | if (!file_util::PathExists(*crash_directory)) { |
| 184 | // Create the spool directory with the appropriate mode (regardless of |
| 185 | // umask) and ownership. |
| 186 | mode_t old_mask = umask(0); |
| 187 | if (mkdir(crash_directory->value().c_str(), directory_mode) < 0 || |
| 188 | chown(crash_directory->value().c_str(), |
| 189 | directory_owner, |
| 190 | directory_group) < 0) { |
Ken Mixter | a324932 | 2011-03-03 08:47:38 -0800 | [diff] [blame] | 191 | LOG(ERROR) << "Unable to create appropriate crash directory"; |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 192 | return false; |
| 193 | } |
| 194 | umask(old_mask); |
| 195 | } |
| 196 | |
| 197 | if (!file_util::PathExists(*crash_directory)) { |
Ken Mixter | a324932 | 2011-03-03 08:47:38 -0800 | [diff] [blame] | 198 | LOG(ERROR) << "Unable to create crash directory " |
| 199 | << crash_directory->value().c_str(); |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 200 | return false; |
| 201 | } |
| 202 | |
Ken Mixter | 04ec10f | 2010-08-26 16:02:02 -0700 | [diff] [blame] | 203 | if (!CheckHasCapacity(*crash_directory)) { |
Ken Mixter | 207694d | 2010-10-28 15:42:37 -0700 | [diff] [blame] | 204 | if (out_of_capacity != NULL) *out_of_capacity = true; |
Ken Mixter | 04ec10f | 2010-08-26 16:02:02 -0700 | [diff] [blame] | 205 | return false; |
| 206 | } |
| 207 | |
Ken Mixter | 0340316 | 2010-08-18 15:23:16 -0700 | [diff] [blame] | 208 | return true; |
| 209 | } |
Ken Mixter | 04ec10f | 2010-08-26 16:02:02 -0700 | [diff] [blame] | 210 | |
| 211 | // Return true if the given crash directory has not already reached |
| 212 | // maximum capacity. |
| 213 | bool CrashCollector::CheckHasCapacity(const FilePath &crash_directory) { |
| 214 | DIR* dir = opendir(crash_directory.value().c_str()); |
| 215 | if (!dir) { |
| 216 | return false; |
| 217 | } |
| 218 | struct dirent ent_buf; |
| 219 | struct dirent* ent; |
Ken Mixter | 04ec10f | 2010-08-26 16:02:02 -0700 | [diff] [blame] | 220 | bool full = false; |
Ken Mixter | ee849c5 | 2010-09-30 15:30:10 -0700 | [diff] [blame] | 221 | std::set<std::string> basenames; |
Ken Mixter | 04ec10f | 2010-08-26 16:02:02 -0700 | [diff] [blame] | 222 | while (readdir_r(dir, &ent_buf, &ent) == 0 && ent != NULL) { |
| 223 | if ((strcmp(ent->d_name, ".") == 0) || |
| 224 | (strcmp(ent->d_name, "..") == 0)) |
| 225 | continue; |
| 226 | |
Ken Mixter | ee849c5 | 2010-09-30 15:30:10 -0700 | [diff] [blame] | 227 | std::string filename(ent->d_name); |
| 228 | size_t last_dot = filename.rfind("."); |
| 229 | std::string basename; |
| 230 | // If there is a valid looking extension, use the base part of the |
| 231 | // name. If the only dot is the first byte (aka a dot file), treat |
| 232 | // it as unique to avoid allowing a directory full of dot files |
| 233 | // from accumulating. |
| 234 | if (last_dot != std::string::npos && last_dot != 0) |
| 235 | basename = filename.substr(0, last_dot); |
| 236 | else |
| 237 | basename = filename; |
| 238 | basenames.insert(basename); |
Ken Mixter | 04ec10f | 2010-08-26 16:02:02 -0700 | [diff] [blame] | 239 | |
Ken Mixter | ee849c5 | 2010-09-30 15:30:10 -0700 | [diff] [blame] | 240 | if (basenames.size() >= static_cast<size_t>(kMaxCrashDirectorySize)) { |
Ken Mixter | a324932 | 2011-03-03 08:47:38 -0800 | [diff] [blame] | 241 | LOG(WARNING) << "Crash directory " << crash_directory.value() |
| 242 | << " already full with " << kMaxCrashDirectorySize |
| 243 | << " pending reports"; |
Ken Mixter | 04ec10f | 2010-08-26 16:02:02 -0700 | [diff] [blame] | 244 | full = true; |
| 245 | break; |
| 246 | } |
| 247 | } |
| 248 | closedir(dir); |
| 249 | return !full; |
| 250 | } |
Ken Mixter | ee849c5 | 2010-09-30 15:30:10 -0700 | [diff] [blame] | 251 | |
Ken Mixter | c49dbd4 | 2010-12-14 17:44:11 -0800 | [diff] [blame] | 252 | bool CrashCollector::IsCommentLine(const std::string &line) { |
| 253 | size_t found = line.find_first_not_of(" "); |
| 254 | return found != std::string::npos && line[found] == '#'; |
| 255 | } |
| 256 | |
Ken Mixter | ee849c5 | 2010-09-30 15:30:10 -0700 | [diff] [blame] | 257 | bool CrashCollector::ReadKeyValueFile( |
| 258 | const FilePath &path, |
| 259 | const char separator, |
| 260 | std::map<std::string, std::string> *dictionary) { |
| 261 | std::string contents; |
| 262 | if (!file_util::ReadFileToString(path, &contents)) { |
| 263 | return false; |
| 264 | } |
| 265 | typedef std::vector<std::string> StringVector; |
| 266 | StringVector lines; |
| 267 | SplitString(contents, '\n', &lines); |
| 268 | bool any_errors = false; |
| 269 | for (StringVector::iterator line = lines.begin(); line != lines.end(); |
| 270 | ++line) { |
| 271 | // Allow empty strings. |
| 272 | if (line->empty()) |
| 273 | continue; |
Ken Mixter | c49dbd4 | 2010-12-14 17:44:11 -0800 | [diff] [blame] | 274 | // Allow comment lines. |
| 275 | if (IsCommentLine(*line)) |
| 276 | continue; |
Ken Mixter | ee849c5 | 2010-09-30 15:30:10 -0700 | [diff] [blame] | 277 | StringVector sides; |
| 278 | SplitString(*line, separator, &sides); |
| 279 | if (sides.size() != 2) { |
| 280 | any_errors = true; |
| 281 | continue; |
| 282 | } |
| 283 | dictionary->insert(std::pair<std::string, std::string>(sides[0], sides[1])); |
| 284 | } |
| 285 | return !any_errors; |
| 286 | } |
| 287 | |
Ken Mixter | c49dbd4 | 2010-12-14 17:44:11 -0800 | [diff] [blame] | 288 | bool CrashCollector::GetLogContents(const FilePath &config_path, |
| 289 | const std::string &exec_name, |
| 290 | const FilePath &output_file) { |
| 291 | std::map<std::string, std::string> log_commands; |
| 292 | if (!ReadKeyValueFile(config_path, ':', &log_commands)) { |
Ken Mixter | a324932 | 2011-03-03 08:47:38 -0800 | [diff] [blame] | 293 | LOG(INFO) << "Unable to read log configuration file " |
| 294 | << config_path.value(); |
Ken Mixter | c49dbd4 | 2010-12-14 17:44:11 -0800 | [diff] [blame] | 295 | return false; |
| 296 | } |
| 297 | |
| 298 | if (log_commands.find(exec_name) == log_commands.end()) |
| 299 | return false; |
| 300 | |
Ken Mixter | a324932 | 2011-03-03 08:47:38 -0800 | [diff] [blame] | 301 | chromeos::ProcessImpl diag_process; |
| 302 | diag_process.AddArg(kShellPath); |
Ken Mixter | c49dbd4 | 2010-12-14 17:44:11 -0800 | [diff] [blame] | 303 | std::string shell_command = log_commands[exec_name]; |
Ken Mixter | a324932 | 2011-03-03 08:47:38 -0800 | [diff] [blame] | 304 | diag_process.AddStringOption("-c", shell_command); |
| 305 | diag_process.RedirectOutput(output_file.value()); |
Ken Mixter | c49dbd4 | 2010-12-14 17:44:11 -0800 | [diff] [blame] | 306 | |
Ken Mixter | a324932 | 2011-03-03 08:47:38 -0800 | [diff] [blame] | 307 | int result = diag_process.Run(); |
| 308 | if (result != 0) { |
| 309 | LOG(INFO) << "Running shell command " << shell_command << "failed with: " |
| 310 | << result; |
Ken Mixter | c49dbd4 | 2010-12-14 17:44:11 -0800 | [diff] [blame] | 311 | return false; |
| 312 | } |
| 313 | return true; |
| 314 | } |
| 315 | |
Ken Mixter | afcf808 | 2010-10-26 14:45:01 -0700 | [diff] [blame] | 316 | void CrashCollector::AddCrashMetaData(const std::string &key, |
| 317 | const std::string &value) { |
| 318 | extra_metadata_.append(StringPrintf("%s=%s\n", key.c_str(), value.c_str())); |
| 319 | } |
| 320 | |
Ken Mixter | ee849c5 | 2010-09-30 15:30:10 -0700 | [diff] [blame] | 321 | void CrashCollector::WriteCrashMetaData(const FilePath &meta_path, |
Ken Mixter | c909b69 | 2010-10-18 12:26:05 -0700 | [diff] [blame] | 322 | const std::string &exec_name, |
| 323 | const std::string &payload_path) { |
Ken Mixter | ee849c5 | 2010-09-30 15:30:10 -0700 | [diff] [blame] | 324 | std::map<std::string, std::string> contents; |
Ken Mixter | afcf808 | 2010-10-26 14:45:01 -0700 | [diff] [blame] | 325 | if (!ReadKeyValueFile(FilePath(std::string(lsb_release_)), '=', &contents)) { |
Ken Mixter | a324932 | 2011-03-03 08:47:38 -0800 | [diff] [blame] | 326 | LOG(ERROR) << "Problem parsing " << lsb_release_; |
Ken Mixter | ee849c5 | 2010-09-30 15:30:10 -0700 | [diff] [blame] | 327 | // Even though there was some failure, take as much as we could read. |
| 328 | } |
| 329 | std::string version("unknown"); |
| 330 | std::map<std::string, std::string>::iterator i; |
| 331 | if ((i = contents.find("CHROMEOS_RELEASE_VERSION")) != contents.end()) { |
| 332 | version = i->second; |
| 333 | } |
Ken Mixter | c909b69 | 2010-10-18 12:26:05 -0700 | [diff] [blame] | 334 | int64 payload_size = -1; |
| 335 | file_util::GetFileSize(FilePath(payload_path), &payload_size); |
Ken Mixter | afcf808 | 2010-10-26 14:45:01 -0700 | [diff] [blame] | 336 | std::string meta_data = StringPrintf("%sexec_name=%s\n" |
Ken Mixter | ee849c5 | 2010-09-30 15:30:10 -0700 | [diff] [blame] | 337 | "ver=%s\n" |
Ken Mixter | 207694d | 2010-10-28 15:42:37 -0700 | [diff] [blame] | 338 | "payload=%s\n" |
Ken Mixter | c909b69 | 2010-10-18 12:26:05 -0700 | [diff] [blame] | 339 | "payload_size=%lld\n" |
Ken Mixter | ee849c5 | 2010-09-30 15:30:10 -0700 | [diff] [blame] | 340 | "done=1\n", |
Ken Mixter | afcf808 | 2010-10-26 14:45:01 -0700 | [diff] [blame] | 341 | extra_metadata_.c_str(), |
Ken Mixter | ee849c5 | 2010-09-30 15:30:10 -0700 | [diff] [blame] | 342 | exec_name.c_str(), |
Ken Mixter | c909b69 | 2010-10-18 12:26:05 -0700 | [diff] [blame] | 343 | version.c_str(), |
Ken Mixter | 207694d | 2010-10-28 15:42:37 -0700 | [diff] [blame] | 344 | payload_path.c_str(), |
Ken Mixter | c909b69 | 2010-10-18 12:26:05 -0700 | [diff] [blame] | 345 | payload_size); |
Ken Mixter | 9b34647 | 2010-11-07 13:45:45 -0800 | [diff] [blame] | 346 | // We must use WriteNewFile instead of file_util::WriteFile as we |
| 347 | // do not want to write with root access to a symlink that an attacker |
| 348 | // might have created. |
| 349 | if (WriteNewFile(meta_path, meta_data.c_str(), meta_data.size()) < 0) { |
Ken Mixter | a324932 | 2011-03-03 08:47:38 -0800 | [diff] [blame] | 350 | LOG(ERROR) << "Unable to write " << meta_path.value(); |
Ken Mixter | ee849c5 | 2010-09-30 15:30:10 -0700 | [diff] [blame] | 351 | } |
| 352 | } |
Thieu Le | 1652fb2 | 2011-03-03 12:14:43 -0800 | [diff] [blame^] | 353 | |
| 354 | bool CrashCollector::IsCrashTestInProgress() { |
| 355 | return file_util::PathExists(FilePath(kCrashTestInProgressPath)); |
| 356 | } |