diff --git a/process/drivers/podman_driver.rs b/process/drivers/podman_driver.rs index 30dedb7..09902a6 100644 --- a/process/drivers/podman_driver.rs +++ b/process/drivers/podman_driver.rs @@ -403,10 +403,6 @@ impl RunDriver for PodmanDriver { fn run(opts: &RunOpts) -> Result { trace!("PodmanDriver::run({opts:#?})"); - if !nix::unistd::Uid::effective().is_root() { - bail!("You must be root to run privileged podman!"); - } - let cid_path = TempDir::new().into_diagnostic()?; let cid_file = cid_path.path().join("cid"); @@ -426,10 +422,6 @@ impl RunDriver for PodmanDriver { fn run_output(opts: &RunOpts) -> Result { trace!("PodmanDriver::run_output({opts:#?})"); - if !nix::unistd::Uid::effective().is_root() { - bail!("You must be root to run privileged podman!"); - } - let cid_path = TempDir::new().into_diagnostic()?; let cid_file = cid_path.path().join("cid"); @@ -529,6 +521,7 @@ impl RunDriver for PodmanDriver { fn podman_run(opts: &RunOpts, cid_file: &Path) -> Command { let command = cmd!( + if opts.priviledged && !nix::unistd::Uid::effective().is_root() => "sudo", "podman", "run", format!("--cidfile={}", cid_file.display()),