[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/utils.cc b/utils.cc
index 1d1cb7d..6ebffd0 100644
--- a/utils.cc
+++ b/utils.cc
@@ -50,7 +50,7 @@
DirectFileWriter writer;
TEST_AND_RETURN_FALSE_ERRNO(0 == writer.Open(path,
O_WRONLY | O_CREAT | O_TRUNC,
- 0666));
+ 0600));
ScopedFileWriterCloser closer(&writer);
TEST_AND_RETURN_FALSE_ERRNO(data_len == writer.Write(data, data_len));
return true;