Skip to content

Commit 9054d42

Browse files
committed
ostree-ext: Remove privilege dropping for container pulls
The setpriv-based isolation was fragile (systemd-only), never ported to composefs-rs, and will be obsolete with the podman pull migration. Signed-off-by: gursewak1997 <gursmangat@gmail.com>
1 parent c60b918 commit 9054d42

3 files changed

Lines changed: 2 additions & 75 deletions

File tree

crates/ostree-ext/src/container/mod.rs

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -428,23 +428,17 @@ impl ManifestDiff<'_> {
428428

429429
/// Apply default configuration for container image pulls to an existing configuration.
430430
/// For example, if `authfile` is not set, and `auth_anonymous` is `false`, and a global configuration file exists, it will be used.
431-
///
432-
/// If there is no configured explicit subprocess for skopeo, and the process is running
433-
/// as root, then a default isolation of running the process via `nobody` will be applied.
434431
pub fn merge_default_container_proxy_opts(
435432
config: &mut containers_image_proxy::ImageProxyConfig,
436433
) -> Result<()> {
437-
let user = rustix::process::getuid()
438-
.is_root()
439-
.then_some(isolation::DEFAULT_UNPRIVILEGED_USER);
440-
merge_default_container_proxy_opts_with_isolation(config, user)
434+
merge_default_container_proxy_opts_with_isolation(config, None)
441435
}
442436

443437
/// Apply default configuration for container image pulls, with optional support
444438
/// for isolation as an unprivileged user.
445439
pub fn merge_default_container_proxy_opts_with_isolation(
446440
config: &mut containers_image_proxy::ImageProxyConfig,
447-
isolation_user: Option<&str>,
441+
_isolation_user: Option<&str>,
448442
) -> Result<()> {
449443
let auth_specified =
450444
config.auth_anonymous || config.authfile.is_some() || config.auth_data.is_some();
@@ -458,22 +452,6 @@ pub fn merge_default_container_proxy_opts_with_isolation(
458452
config.auth_anonymous = true;
459453
}
460454
}
461-
// By default, drop privileges, unless the higher level code
462-
// has configured the skopeo command explicitly.
463-
let isolation_user = config
464-
.skopeo_cmd
465-
.is_none()
466-
.then_some(isolation_user.as_ref())
467-
.flatten();
468-
if let Some(user) = isolation_user {
469-
// Read the default authfile if it exists and pass it via file descriptor
470-
// which will ensure it's readable when we drop privileges.
471-
if let Some(authfile) = config.authfile.take() {
472-
config.auth_data = Some(std::fs::File::open(authfile)?);
473-
}
474-
let cmd = crate::isolation::unprivileged_subprocess(bootc_utils::skopeo_bin(), user);
475-
config.skopeo_cmd = Some(cmd);
476-
}
477455
Ok(())
478456
}
479457

@@ -520,8 +498,6 @@ pub mod store;
520498
mod update_detachedmeta;
521499
pub use update_detachedmeta::*;
522500

523-
use crate::isolation;
524-
525501
#[cfg(test)]
526502
mod tests {
527503
use std::process::Command;

crates/ostree-ext/src/isolation.rs

Lines changed: 0 additions & 47 deletions
This file was deleted.

crates/ostree-ext/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ type Result<T> = anyhow::Result<T>;
4040
// Import global functions.
4141
pub mod globals;
4242

43-
mod isolation;
44-
4543
pub mod bootabletree;
4644
pub mod cli;
4745
pub mod container;

0 commit comments

Comments
 (0)