OSDN Git Service

Changed permission of temporary bugreport and dumpstate log files to Shell.
authorFelipe Leme <felipeal@google.com>
Fri, 12 Feb 2016 17:04:16 +0000 (09:04 -0800)
committerFelipe Leme <felipeal@google.com>
Fri, 12 Feb 2016 17:42:39 +0000 (09:42 -0800)
BUG: 27164100

Change-Id: I569cbe4854fad44c95c9bf3e2efa9c3c93317003

cmds/dumpstate/dumpstate.cpp

index 462cf7d..128681f 100644 (file)
@@ -488,7 +488,8 @@ static bool add_zip_entry_from_fd(const std::string& entry_name, int fd) {
         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 @@ int main(int argc, char *argv[]) {
 
     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