Skip to content

Commit

Permalink
install: Bail out if we detect we're running rootless
Browse files Browse the repository at this point in the history
It's an easy mistake to make and the error message is less
than obvious.

Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Oct 11, 2023
1 parent 5f8e9dc commit 75906e2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/src/containerenv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub(crate) struct ContainerExecutionInfo {
pub(crate) id: String,
pub(crate) image: String,
pub(crate) imageid: String,
pub(crate) rootless: Option<String>,
}

/// Load and parse the `/run/.containerenv` file.
Expand Down
4 changes: 4 additions & 0 deletions lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,10 @@ async fn prepare_install(

// This command currently *must* be run inside a privileged container.
let container_info = crate::containerenv::get_container_execution_info(&rootfs)?;
if let Some("1") = container_info.rootless.as_deref() {
anyhow::bail!("Cannot install from rootless podman; this command must be run as root");
}

let source = SourceInfo::from_container(&container_info)?;

ensure_var()?;
Expand Down

0 comments on commit 75906e2

Please sign in to comment.