Ensure that cached oat and image files are world readable like odex files
(cherry picked from commit 389ca5b86e1411c28b785408a7a4b8ac7837355c)
Change-Id: I619601e9549764a11b78d782725a1dab5c80afb3
diff --git a/src/image_writer.cc b/src/image_writer.cc
index 9e01d01..d1328c1 100644
--- a/src/image_writer.cc
+++ b/src/image_writer.cc
@@ -17,6 +17,7 @@
#include "image_writer.h"
#include <sys/mman.h>
+#include <sys/stat.h>
#include <vector>
@@ -92,6 +93,10 @@
LOG(ERROR) << "Failed to open image file " << image_filename;
return false;
}
+ if (fchmod(file->Fd(), 0644) != 0) {
+ PLOG(ERROR) << "Failed to make image file world readable: " << image_filename;
+ return EXIT_FAILURE;
+ }
bool success = file->WriteFully(image_->Begin(), image_end_);
if (!success) {
PLOG(ERROR) << "Failed to write image file " << image_filename;