summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2021-06-11 06:46:14 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-06-11 06:46:14 +0000
commitd2fb9ed584afdcba2cd1f6adebfd6562a6a16e02 (patch)
treebb2d12fcb00260a05a06fd9dde7c12b7e21c53b9
parent983c1dadfe854936bfb615df005fe6a213dd462a (diff)
parent3387c68feb8567aaeb1a33ebec5c9dfbafea5737 (diff)
downloadextras-d2fb9ed584afdcba2cd1f6adebfd6562a6a16e02.tar.gz
Snap for 7448313 from 3387c68feb8567aaeb1a33ebec5c9dfbafea5737 to sc-d2-release
Change-Id: I567977876f48010c8214e10dba267f9aa1ab5482
-rw-r--r--profcollectd/libprofcollectd/report.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/profcollectd/libprofcollectd/report.rs b/profcollectd/libprofcollectd/report.rs
index f3b8fe12..c37993b7 100644
--- a/profcollectd/libprofcollectd/report.rs
+++ b/profcollectd/libprofcollectd/report.rs
@@ -19,9 +19,9 @@
use anyhow::{anyhow, Result};
use lazy_static::lazy_static;
use macaddr::MacAddr6;
-use std::fs::{self, File};
+use std::fs::{self, File, Permissions};
use std::io::{Read, Write};
-use std::os::unix::fs::OpenOptionsExt;
+use std::os::unix::fs::PermissionsExt;
use std::path::{Path, PathBuf};
use std::time::SystemTime;
use uuid::v1::{Context, Timestamp};
@@ -45,11 +45,14 @@ pub fn pack_report(profile: &Path, report: &Path, config: &Config) -> Result<Str
// Remove the current report file if exists.
fs::remove_file(&report).ok();
+ let report_file = fs::OpenOptions::new().create_new(true).write(true).open(&report)?;
+
// Set report file ACL bits to 644, so that this can be shared to uploaders.
// Who has permission to actually read the file is protected by SELinux policy.
- let report = fs::OpenOptions::new().create_new(true).write(true).mode(0o644).open(&report)?;
+ fs::set_permissions(&report, Permissions::from_mode(0o644))?;
+
let options = FileOptions::default().compression_method(Deflated);
- let mut zip = ZipWriter::new(report);
+ let mut zip = ZipWriter::new(report_file);
fs::read_dir(profile)?
.filter_map(|e| e.ok())