Skip to content

Commit 8a5c7ae

Browse files
image-proxy: Use privileged user when pull from containers storage
We were defaulting to unprivileged user "nobody" when pulling an image, but pulling from containers-storage was failing as it requires extra privileges. Default to the current user, usually root, when pulling from containers-storage Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent 7016477 commit 8a5c7ae

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

crates/lib/src/bootc_composefs/status.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,12 +381,28 @@ pub(crate) fn list_bootloader_entries(storage: &Storage) -> Result<Vec<Bootloade
381381
pub(crate) async fn get_container_manifest_and_config(
382382
imgref: &String,
383383
) -> Result<ImgConfigManifest> {
384+
use containers_image_proxy::{ImageProxy, ImageReference, Transport};
385+
386+
let imgref = ImageReference::from_str(&imgref)
387+
.context("Failed to parse '{imgref}' into ImageReference")?;
388+
384389
let mut config = crate::deploy::new_proxy_config();
385-
ostree_ext::container::merge_default_container_proxy_opts(&mut config)?;
386-
let proxy = containers_image_proxy::ImageProxy::new_with_config(config).await?;
390+
391+
if imgref.transport == Transport::ContainerStorage {
392+
// Fetching from containers-storage, may require privileges to read files
393+
ostree_ext::container::merge_default_container_proxy_opts_with_isolation(
394+
&mut config,
395+
None,
396+
)?;
397+
} else {
398+
// Apply our defaults to the proxy config
399+
ostree_ext::container::merge_default_container_proxy_opts(&mut config)?;
400+
}
401+
402+
let proxy = ImageProxy::new_with_config(config).await?;
387403

388404
let img = proxy
389-
.open_image(&imgref)
405+
.open_image_ref(&imgref)
390406
.await
391407
.with_context(|| format!("Opening image {imgref}"))?;
392408

0 commit comments

Comments
 (0)