Skip to content

Commit 9b6b2a0

Browse files
Johan-Liebert1allisonkarlitskaya
authored andcommitted
skopeo: Use podman unshare for containers-storage when not root
Calling `podman unshare` from inside a rootful container fails, which breaks image pulls in said case. We have sufficient privileges to pull from containers storage if we are in a rootful container thus don't need unshare Signed-off-by: Pragyan Poudyal <[email protected]>
1 parent 8cbe48d commit 9b6b2a0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

crates/composefs-oci/src/skopeo.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use async_compression::tokio::bufread::{GzipDecoder, ZstdDecoder};
77
use containers_image_proxy::{ImageProxy, ImageProxyConfig, OpenedImage};
88
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
99
use oci_spec::image::{Descriptor, ImageConfiguration, ImageManifest, MediaType};
10+
use rustix::process::geteuid;
1011
use tokio::{io::AsyncReadExt, sync::Semaphore};
1112

1213
use composefs::{
@@ -25,7 +26,7 @@ struct ImageOp<ObjectID: FsVerityHashValue> {
2526
impl<ObjectID: FsVerityHashValue> ImageOp<ObjectID> {
2627
async fn new(repo: &Arc<Repository<ObjectID>>, imgref: &str) -> Result<Self> {
2728
// See https://github.com/containers/skopeo/issues/2563
28-
let skopeo_cmd = if imgref.starts_with("containers-storage:") {
29+
let skopeo_cmd = if imgref.starts_with("containers-storage:") && !geteuid().is_root() {
2930
let mut cmd = Command::new("podman");
3031
cmd.args(["unshare", "skopeo"]);
3132
Some(cmd)

0 commit comments

Comments
 (0)