[update_engine] Fix file creation mask to be 0600
In addition to changing the write() call in utils.cc, I also set the umask
of the process to be 177 -- meaning that files will be AT MOST -rw-------
I do this _after_ we initialize logging, so that we don't create log files
with unnecessarily restrictive permissions.
BUG=chromium-os:6581
TEST=Unit tests,
Change-Id: Id6b805a1524af391755bc1df69ec0f6c382154c2
[update_engine] Ensure that created files have restrictive permissions
Change-Id: If93e043465083f7c48619d0e7163dd73f8c46090
Review URL: http://codereview.chromium.org/3495002
diff --git a/split_file_writer.cc b/split_file_writer.cc
index 690d4e3..dd211c8 100644
--- a/split_file_writer.cc
+++ b/split_file_writer.cc
@@ -43,7 +43,7 @@
ssize_t SplitFileWriter::Write(const void* bytes, size_t count) {
const size_t original_count = count;
-
+
// This first block is trying to read the first sizeof(uint64_t)
// bytes, which are the number of bytes that should be written
// to the first FileWriter.
@@ -78,11 +78,11 @@
first_length_ -
(bytes_received_ - static_cast<off_t>(sizeof(uint64_t))),
static_cast<off_t>(count));
-
+
int rc = PerformWrite(first_file_writer_, bytes, bytes_to_write);
if (rc != static_cast<int>(bytes_to_write))
return rc;
-
+
bytes_received_ += bytes_to_write;
count -= bytes_to_write;
bytes = static_cast<const void*>(