Add a cap-std-apis feature with open/create
I'm trying to make more use of `cap-std` in our stack, and this will be a key enabling API. Actually a notable side benefit of this is that we don't need to teach the ostree C code itself to use `openat2`, we inherit cap-std's setup. All of the internal ostree code using the prior `openat()` should continue to work. I only did basic sanity checking of this; there may be bugs in other APIs.
This commit is contained in:
1 parent
4f7eea6aa7
commit
6940896c4e
5 files changed
+68
No files matched your search
@@ -28,6 +28,26 @@ impl TestRepo {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[cfg(feature = "cap-std-apis")]
|
||||
pub struct CapTestRepo {
|
||||
pub dir: cap_tempfile::TempDir,
|
||||
pub repo: ostree::Repo,
|
||||
}
|
||||
|
||||
#[cfg(feature = "cap-std-apis")]
|
||||
impl CapTestRepo {
|
||||
pub fn new() -> Self {
|
||||
Self::new_with_mode(ostree::RepoMode::Archive)
|
||||
}
|
||||
|
||||
pub fn new_with_mode(repo_mode: ostree::RepoMode) -> Self {
|
||||
let dir = cap_tempfile::tempdir(cap_std::ambient_authority()).unwrap();
|
||||
let repo = ostree::Repo::create_at_dir(&dir, ".", repo_mode, None).expect("repo create");
|
||||
Self { dir, repo }
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_mtree(repo: &ostree::Repo) -> ostree::MutableTree {
|
||||
let mtree = ostree::MutableTree::new();
|
||||
let file = gio::File::for_path(
|
||||
|
||||
Reference in new issue
Block a user