Mount the new system as 'postinstall_file' in postinstall.
When mounting the new filesystem on /postinstall, we need to override
the file attributes from the new system (unknown to the current selinux
policies) with a consistent label that will be used only in the context
of postinstall. This patch passes an extra option to mount(2) in
Brillo and Android to achieve this.
Bug: 27177071
TEST=Deployed a postinstall script with `ls -laZ`, contents show "postinstall_file".
Change-Id: Ia43b45c92e4c4cd340a884818ac00f24a418f9e7
diff --git a/common/utils.cc b/common/utils.cc
index b4956e7..912bc96 100644
--- a/common/utils.cc
+++ b/common/utils.cc
@@ -614,7 +614,8 @@
bool MountFilesystem(const string& device,
const string& mountpoint,
unsigned long mountflags, // NOLINT(runtime/int)
- const string& type) {
+ const string& type,
+ const string& fs_mount_options) {
vector<const char*> fstypes;
if (type.empty()) {
fstypes = {"ext2", "ext3", "ext4", "squashfs"};
@@ -623,7 +624,7 @@
}
for (const char* fstype : fstypes) {
int rc = mount(device.c_str(), mountpoint.c_str(), fstype, mountflags,
- nullptr);
+ fs_mount_options.c_str());
if (rc == 0)
return true;