Add --uid --gid options to zipfuse
So far, files and directories in a zipfuse filesystem had root as its
uid/gid. This change adds two options --uid and --gid to zipfuse which
are used to override the behavior.
For now, microdroid_manager uses `--uid 0 --gid 0` which means there's
no behavioral change. A follow-up change will set the IDs to a non-root
value.
Bug: 264668376
Test: run microdroid tests
Change-Id: I935424a52edcc3868fdf6aef526a641855a67f63
diff --git a/microdroid_manager/src/main.rs b/microdroid_manager/src/main.rs
index 4018d00..1ef41cb 100644
--- a/microdroid_manager/src/main.rs
+++ b/microdroid_manager/src/main.rs
@@ -488,6 +488,8 @@
}
impl Zipfuse {
+ const MICRODROID_PAYLOAD_UID: u32 = 0; // TODO(b/264861173) should be non-root
+ const MICRODROID_PAYLOAD_GID: u32 = 0; // TODO(b/264861173) should be non-root
fn mount(
&mut self,
noexec: MountForExec,
@@ -501,6 +503,8 @@
cmd.arg("--noexec");
}
cmd.args(["-p", &ready_prop, "-o", option]);
+ cmd.args(["-u", &Self::MICRODROID_PAYLOAD_UID.to_string()]);
+ cmd.args(["-g", &Self::MICRODROID_PAYLOAD_GID.to_string()]);
cmd.arg(zip_path).arg(mount_dir);
self.ready_properties.push(ready_prop);
cmd.spawn().with_context(|| format!("Failed to run zipfuse for {mount_dir:?}"))