Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6fe9db67 authored by Felipe Leme's avatar Felipe Leme
Browse files

Changed permission of temporary bugreport and dumpstate log files to Shell.

BUG: 27164100

Change-Id: I569cbe4854fad44c95c9bf3e2efa9c3c93317003
parent 421c1c07
Loading
Loading
Loading
Loading
+10 −1
Original line number Original line Diff line number Diff line
@@ -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());
        MYLOGD("Not adding zip entry %s from fd because zip_writer is not set\n", entry_name.c_str());
        return false;
        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(),
    int32_t err = zip_writer->StartEntryWithTime(entry_name.c_str(),
            ZipWriter::kCompress, get_mtime(fd, now));
            ZipWriter::kCompress, get_mtime(fd, now));
    if (err) {
    if (err) {
@@ -1237,10 +1238,18 @@ int main(int argc, char *argv[]) {


    if (is_redirecting) {
    if (is_redirecting) {
        redirect_to_file(stderr, const_cast<char*>(log_path.c_str()));
        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,
        /* TODO: rather than generating a text file now and zipping it later,
           it would be more efficient to redirect stdout to the zip entry
           it would be more efficient to redirect stdout to the zip entry
           directly, but the libziparchive doesn't support that option yet. */
           directly, but the libziparchive doesn't support that option yet. */
        redirect_to_file(stdout, const_cast<char*>(tmp_path.c_str()));
        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.
    // 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
    // In particular, DurationReport objects should be created passing 'title, NULL', so their