| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "sandbox/linux/syscall_broker/broker_file_permission.h" | 5 #include "sandbox/linux/syscall_broker/broker_file_permission.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 | 10 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 bool allow_create) | 215 bool allow_create) |
| 216 : path_(path), | 216 : path_(path), |
| 217 recursive_(recursive), | 217 recursive_(recursive), |
| 218 unlink_(unlink), | 218 unlink_(unlink), |
| 219 allow_read_(allow_read), | 219 allow_read_(allow_read), |
| 220 allow_write_(allow_write), | 220 allow_write_(allow_write), |
| 221 allow_create_(allow_create) { | 221 allow_create_(allow_create) { |
| 222 // Validate this permission and die if invalid! | 222 // Validate this permission and die if invalid! |
| 223 | 223 |
| 224 // Must have enough length for a '/' | 224 // Must have enough length for a '/' |
| 225 CHECK(path_.length() > 0) << GetErrorMessageForTests(); | 225 LOG_IF(FATAL, path_.empty()) << GetErrorMessageForTests(); |
| 226 // Whitelisted paths must be absolute. | 226 // Whitelisted paths must be absolute. |
| 227 CHECK(path_[0] == '/') << GetErrorMessageForTests(); | 227 LOG_IF(FATAL, path_[0] != '/') << GetErrorMessageForTests(); |
| 228 | 228 |
| 229 // Don't allow unlinking on creation without create permission | 229 // Don't allow unlinking on creation without create permission |
| 230 if (unlink_) { | 230 if (unlink_) { |
| 231 CHECK(allow_create) << GetErrorMessageForTests(); | 231 LOG_IF(FATAL, !allow_create) << GetErrorMessageForTests(); |
| 232 } | 232 } |
| 233 const char last_char = *(path_.rbegin()); | 233 const char last_char = *(path_.rbegin()); |
| 234 // Recursive paths must have a trailing slash | 234 // Recursive paths must have a trailing slash |
| 235 if (recursive_) { | 235 if (recursive_) { |
| 236 CHECK(last_char == '/') << GetErrorMessageForTests(); | 236 LOG_IF(FATAL, last_char != '/') << GetErrorMessageForTests(); |
| 237 } else { | 237 } else { |
| 238 CHECK(last_char != '/') << GetErrorMessageForTests(); | 238 LOG_IF(FATAL, last_char == '/') << GetErrorMessageForTests(); |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 | 241 |
| 242 } // namespace syscall_broker | 242 } // namespace syscall_broker |
| 243 | 243 |
| 244 } // namespace sandbox | 244 } // namespace sandbox |
| OLD | NEW |