summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2021-06-12 03:08:53 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-06-12 03:08:53 +0000
commit62a5e4154bef2a4d1172bff488e120f9ae13f560 (patch)
treebb2d12fcb00260a05a06fd9dde7c12b7e21c53b9
parent6ddae5257a27f8f0a8dc774e21886d593725d52f (diff)
parent2a8f28f46094672eec33ae234ed97a8b63c483c4 (diff)
downloadextras-62a5e4154bef2a4d1172bff488e120f9ae13f560.tar.gz
Snap for 7450397 from 2a8f28f46094672eec33ae234ed97a8b63c483c4 to sc-d1-release
Change-Id: I6bf5a3a7b3056ec3bca657f2389b63ac6c3d1981
-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())