Changed permission of temporary bugreport and dumpstate log files to Shell.
BUG: 27164100
Change-Id: I569cbe4854fad44c95c9bf3e2efa9c3c93317003
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 462cf7d..128681f 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -488,7 +488,8 @@
MYLOGD("Not adding zip entry %s from fd because zip_writer is not set\n", entry_name.c_str());
return false;
}
- MYLOGD("Adding zip entry %s\n", entry_name.c_str());
+ // Logging statement below is useful to time how long each entry takes, but it's too verbose.
+ // MYLOGD("Adding zip entry %s\n", entry_name.c_str());
int32_t err = zip_writer->StartEntryWithTime(entry_name.c_str(),
ZipWriter::kCompress, get_mtime(fd, now));
if (err) {
@@ -1237,10 +1238,18 @@
if (is_redirecting) {
redirect_to_file(stderr, const_cast<char*>(log_path.c_str()));
+ if (chown(log_path.c_str(), AID_SHELL, AID_SHELL)) {
+ MYLOGE("Unable to change ownership of dumpstate log file %s: %s\n",
+ log_path.c_str(), strerror(errno));
+ }
/* TODO: rather than generating a text file now and zipping it later,
it would be more efficient to redirect stdout to the zip entry
directly, but the libziparchive doesn't support that option yet. */
redirect_to_file(stdout, const_cast<char*>(tmp_path.c_str()));
+ if (chown(tmp_path.c_str(), AID_SHELL, AID_SHELL)) {
+ MYLOGE("Unable to change ownership of temporary bugreport file %s: %s\n",
+ tmp_path.c_str(), strerror(errno));
+ }
}
// NOTE: there should be no stdout output until now, otherwise it would break the header.
// In particular, DurationReport objects should be created passing 'title, NULL', so their