Skip to content

Commit e7be393

Browse files
committed
install: Use tmpdir for target fetch verification
We create a transient ostree repo, to do so use the global install tmpdir. Signed-off-by: Colin Walters <[email protected]>
1 parent 36f8add commit e7be393

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

lib/src/install.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,11 +1120,12 @@ pub(crate) fn setup_sys_mount(fstype: &str, fspath: &str) -> Result<()> {
11201120

11211121
/// Verify that we can load the manifest of the target image
11221122
#[context("Verifying fetch")]
1123-
async fn verify_target_fetch(imgref: &ostree_container::OstreeImageReference) -> Result<()> {
1124-
let tmpdir = tempfile::tempdir()?;
1125-
let tmprepo = &ostree::Repo::new_for_path(tmpdir.path());
1126-
tmprepo
1127-
.create(ostree::RepoMode::Bare, ostree::gio::Cancellable::NONE)
1123+
async fn verify_target_fetch(
1124+
tmpdir: &Dir,
1125+
imgref: &ostree_container::OstreeImageReference,
1126+
) -> Result<()> {
1127+
let tmpdir = &TempDir::new_in(&tmpdir)?;
1128+
let tmprepo = &ostree::Repo::create_at_dir(tmpdir.as_fd(), ".", ostree::RepoMode::Bare, None)
11281129
.context("Init tmp repo")?;
11291130

11301131
tracing::trace!("Verifying fetch for {imgref}");
@@ -1207,10 +1208,6 @@ async fn prepare_install(
12071208
};
12081209
tracing::debug!("Target image reference: {target_imgref}");
12091210

1210-
if !target_opts.skip_fetch_check {
1211-
verify_target_fetch(&target_imgref).await?;
1212-
}
1213-
12141211
// A bit of basic global state setup
12151212
ensure_var()?;
12161213
setup_tmp_mounts()?;
@@ -1220,6 +1217,10 @@ async fn prepare_install(
12201217
// And continue to init global state
12211218
ensure_writable_etc_containers(&tempdir)?;
12221219

1220+
if !target_opts.skip_fetch_check {
1221+
verify_target_fetch(&tempdir, &target_imgref).await?;
1222+
}
1223+
12231224
// Even though we require running in a container, the mounts we create should be specific
12241225
// to this process, so let's enter a private mountns to avoid leaking them.
12251226
if !external_source && std::env::var_os("BOOTC_SKIP_UNSHARE").is_none() {

0 commit comments

Comments
 (0)