Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(948)

Unified Diff: sandbox/linux/syscall_broker/broker_host.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sandbox/linux/syscall_broker/broker_host.cc
diff --git a/sandbox/linux/syscall_broker/broker_host.cc b/sandbox/linux/syscall_broker/broker_host.cc
index 29300f7e374359ec4038db80c46105de658aa60f..7ebc7850a0f4da1e4fc781db9441bf6b6060d0a7 100644
--- a/sandbox/linux/syscall_broker/broker_host.cc
+++ b/sandbox/linux/syscall_broker/broker_host.cc
@@ -38,8 +38,13 @@ bool IsRunningOnValgrind() {
// make a direct system call since we want to keep in control of the broker
// process' system calls profile to be able to loosely sandbox it.
int sys_open(const char* pathname, int flags) {
- // Always pass a defined |mode| in case flags mistakenly contains O_CREAT.
- const int mode = 0;
+ // Hardcode mode to rw------- when creating files.
+ int mode;
+ if (flags & O_CREAT) {
+ mode = 0600;
+ } else {
+ mode = 0;
+ }
if (IsRunningOnValgrind()) {
// Valgrind does not support AT_FDCWD, just use libc's open() in this case.
return open(pathname, flags, mode);
@@ -59,8 +64,9 @@ void OpenFileForIPC(const BrokerPolicy& policy,
DCHECK(write_pickle);
DCHECK(opened_files);
const char* file_to_open = NULL;
+ bool unlink_after_open = false;
const bool safe_to_open_file = policy.GetFileNameIfAllowedToOpen(
- requested_filename.c_str(), flags, &file_to_open);
+ requested_filename.c_str(), flags, &file_to_open, &unlink_after_open);
if (safe_to_open_file) {
CHECK(file_to_open);
@@ -69,6 +75,9 @@ void OpenFileForIPC(const BrokerPolicy& policy,
write_pickle->WriteInt(-errno);
} else {
// Success.
+ if (unlink_after_open) {
+ unlink(file_to_open);
+ }
opened_files->push_back(opened_fd);
write_pickle->WriteInt(0);
}
« no previous file with comments | « sandbox/linux/syscall_broker/broker_file_permission_unittest.cc ('k') | sandbox/linux/syscall_broker/broker_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698