Skip to content

Commit 99d30df

Browse files
committed
install: Fallback to no sepolicy when init imgstore
Check for the policy csum to make sure there is actually a policy available to lookup when trying to label the bootc container storage. Fixes #1303 Signed-off-by: ckyrouac <[email protected]>
1 parent 21c57d4 commit 99d30df

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/src/store/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,27 @@ impl Storage {
9292
let sepolicy = if self.sysroot.booted_deployment().is_none() {
9393
// fallback to policy from container root
9494
// this should only happen during cleanup of a broken install
95+
tracing::trace!("falling back to container root's selinux policy");
9596
let container_root = Dir::open_ambient_dir("/", cap_std::ambient_authority())?;
9697
&ostree::SePolicy::new_at(container_root.as_raw_fd(), gio::Cancellable::NONE)?
9798
} else {
9899
// load the sepolicy from the booted ostree deployment so the imgstorage can be
99100
// properly labeled with /var/lib/container/storage labels
101+
tracing::trace!("loading sepolicy from booted ostree deployment");
100102
let dep = self.sysroot.booted_deployment().unwrap();
101103
let dep_fs = deployment_fd(&self.sysroot, &dep)?;
102104
&ostree::SePolicy::new_at(dep_fs.as_raw_fd(), gio::Cancellable::NONE)?
103105
};
104106

105-
let imgstore = crate::imgstorage::Storage::create(&sysroot_dir, &self.run, Some(sepolicy))?;
107+
let sepolicy = if sepolicy.csum().is_none() {
108+
None
109+
} else {
110+
Some(sepolicy)
111+
};
112+
113+
tracing::trace!("sepolicy in get_ensure_imgstore: {sepolicy:?}");
114+
115+
let imgstore = crate::imgstorage::Storage::create(&sysroot_dir, &self.run, sepolicy)?;
106116
Ok(self.imgstore.get_or_init(|| imgstore))
107117
}
108118

0 commit comments

Comments
 (0)