+6
-6
@@ -1,5 +1,5 @@
|
||||
//! Inject: inspect a podman image's config, infer the default command argv,
|
||||
//! and inject the slim init binary + null-delimited argv/env files into the
|
||||
//! and inject the boco init binary + null-delimited argv/env files into the
|
||||
//! mounted rootfs.
|
||||
|
||||
use anyhow::{Context, Result, anyhow};
|
||||
@@ -68,21 +68,21 @@ pub fn null_delimited(items: &[String]) -> Vec<u8> {
|
||||
data
|
||||
}
|
||||
|
||||
/// Install `content` into the mounted rootfs at `<mount>/slim/<name>` with
|
||||
/// Install `content` into the mounted rootfs at `<mount>/boco/<name>` with
|
||||
/// the given mode.
|
||||
fn install_into_rootfs(mount: &str, name: &str, mode: &str, content: &[u8]) -> Result<()> {
|
||||
let temp = tempfile::NamedTempFile::new()?;
|
||||
fs::write(temp.path(), content)?;
|
||||
let src = temp.path().to_str().context("temp path is not UTF-8")?;
|
||||
let dest = format!("{mount}/slim/{name}");
|
||||
let dest = format!("{mount}/boco/{name}");
|
||||
cmd(&[
|
||||
"podman", "unshare", "--", "install", "-D", "-m", mode, src, &dest,
|
||||
])?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Inject /slim/init (binary), /slim/exec (null-delimited argv), /slim/env
|
||||
/// (null-delimited env), and optionally /slim/user and /slim/workdir into a
|
||||
/// Inject /boco/init (binary), /boco/exec (null-delimited argv), /boco/env
|
||||
/// (null-delimited env), and optionally /boco/user and /boco/workdir into a
|
||||
/// mounted container image rootfs.
|
||||
pub fn inject(
|
||||
mount_path: &Path,
|
||||
@@ -93,7 +93,7 @@ pub fn inject(
|
||||
) -> Result<()> {
|
||||
let mount_str = mount_path.to_str().context("mount path is not UTF-8")?;
|
||||
|
||||
let init_binary = fs::read(init_binary_path()?).context("Failed to read slim-init binary")?;
|
||||
let init_binary = fs::read(init_binary_path()?).context("Failed to read boco-init binary")?;
|
||||
let exec_data = null_delimited(argv);
|
||||
let env_data = null_delimited(env);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user