Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #593 from cgwalters/revert-cap-std-ocidir
Browse files Browse the repository at this point in the history
encapsulate: Fix regression with relative directories
  • Loading branch information
jmarrero authored Jan 26, 2024
2 parents 7953da3 + daff9f8 commit ecce09a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/src/container/encapsulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,16 @@ async fn build_impl(
drop(ocidir);

// Pass the temporary oci directory as the current working directory for the skopeo process
let target_fd = 3i32;
let tempoci = ImageReference {
transport: Transport::OciDir,
name: ".".into(),
name: format!("/proc/self/fd/{target_fd}"),
};
let digest = skopeo::copy(
&tempoci,
dest,
authfile.as_deref(),
Some(tempdir.try_clone()?),
Some((std::sync::Arc::new(tempdir.try_clone()?.into()), target_fd)),
)
.await?;
Some(digest)
Expand Down
8 changes: 4 additions & 4 deletions lib/src/container/skopeo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
use super::ImageReference;
use anyhow::{Context, Result};
use cap_std_ext::cap_std::fs::Dir;
use cap_std_ext::cmdext::CapStdExtCommandExt;
use fn_error_context::context;
use io_lifetimes::OwnedFd;
use serde::Deserialize;
use std::io::Read;
use std::path::Path;
Expand Down Expand Up @@ -66,15 +66,15 @@ pub(crate) async fn copy(
src: &ImageReference,
dest: &ImageReference,
authfile: Option<&Path>,
cwd: Option<Dir>,
add_fd: Option<(std::sync::Arc<OwnedFd>, i32)>,
) -> Result<String> {
let digestfile = tempfile::NamedTempFile::new()?;
let mut cmd = new_cmd();
cmd.stdout(std::process::Stdio::null()).arg("copy");
cmd.arg("--digestfile");
cmd.arg(digestfile.path());
if let Some(cwd) = cwd {
cmd.cwd_dir(cwd);
if let Some((add_fd, n)) = add_fd {
cmd.take_fd_n(add_fd, n);
}
if let Some(authfile) = authfile {
cmd.arg("--authfile");
Expand Down

0 comments on commit ecce09a

Please sign in to comment.