-
Notifications
You must be signed in to change notification settings - Fork 119
imgstorage: Set selinux labels for imgstorage #1198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,13 +7,15 @@ use cap_std_ext::cap_std::fs::Dir; | |
use cap_std_ext::dirext::CapStdExtDirExt; | ||
use clap::ValueEnum; | ||
use fn_error_context::context; | ||
use std::os::fd::AsRawFd; | ||
|
||
use ostree_ext::container::OstreeImageReference; | ||
use ostree_ext::keyfileext::KeyFileExt; | ||
use ostree_ext::ostree; | ||
use ostree_ext::sysroot::SysrootLock; | ||
use ostree_ext::{gio, ostree}; | ||
|
||
use crate::spec::ImageStatus; | ||
use crate::utils::deployment_fd; | ||
|
||
mod ostree_container; | ||
|
||
|
@@ -85,7 +87,18 @@ impl Storage { | |
return Ok(imgstore); | ||
} | ||
let sysroot_dir = crate::utils::sysroot_dir(&self.sysroot)?; | ||
let imgstore = crate::imgstorage::Storage::create(&sysroot_dir, &self.run)?; | ||
|
||
if self.sysroot.booted_deployment().is_none() { | ||
anyhow::bail!("Not a bootc system (this shouldn't be possible)"); | ||
} | ||
|
||
// load the sepolicy from the booted ostree deployment so the imgstorage can be | ||
// properly labeled with /var/lib/container/storage labels | ||
let dep = self.sysroot.booted_deployment().unwrap(); | ||
let dep_fs = deployment_fd(&self.sysroot, &dep)?; | ||
let sepolicy = &ostree::SePolicy::new_at(dep_fs.as_raw_fd(), gio::Cancellable::NONE)?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The booted deployment's directory is going to be equivalent (mostly) to If we did that it'd argue to just open up the But...eh, this can all be followup. |
||
|
||
let imgstore = crate::imgstorage::Storage::create(&sysroot_dir, &self.run, Some(sepolicy))?; | ||
Ok(self.imgstore.get_or_init(|| imgstore)) | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in order to add a bit more crash resilence here it'd be a good idea to do e.g.:
or so - that should help ensure that we don't end up in a situation where (on a system crash) the
LABELED
file exists but the pending writes to do the relabeling didn't land.(arg, in a quick test this fails because a cap-std
Dir
is anO_PATH
fd and we can'tfsync
on that, I will look at a little helper for this)