fix: Use sudo for login when using rechunk
This commit is contained in:
parent
7f8095d283
commit
185a34f86b
7 changed files with 20 additions and 9 deletions
|
|
@ -327,8 +327,8 @@ impl BuildDriver for Driver {
|
|||
impl_build_driver!(push(opts))
|
||||
}
|
||||
|
||||
fn login() -> Result<()> {
|
||||
impl_build_driver!(login())
|
||||
fn login(privileged: bool) -> Result<()> {
|
||||
impl_build_driver!(login(privileged))
|
||||
}
|
||||
|
||||
#[cfg(feature = "prune")]
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ impl BuildDriver for BuildahDriver {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn login() -> Result<()> {
|
||||
fn login(_privileged: bool) -> Result<()> {
|
||||
trace!("BuildahDriver::login()");
|
||||
|
||||
if let Some(Credentials {
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ impl BuildDriver for DockerDriver {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn login() -> Result<()> {
|
||||
fn login(_privileged: bool) -> Result<()> {
|
||||
trace!("DockerDriver::login()");
|
||||
|
||||
if let Some(Credentials {
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ impl BuildDriver for PodmanDriver {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn login() -> Result<()> {
|
||||
fn login(privileged: bool) -> Result<()> {
|
||||
trace!("PodmanDriver::login()");
|
||||
|
||||
if let Some(Credentials {
|
||||
|
|
@ -262,11 +262,22 @@ impl BuildDriver for PodmanDriver {
|
|||
password,
|
||||
}) = Credentials::get()
|
||||
{
|
||||
let use_sudo = privileged && !running_as_root();
|
||||
let output = pipe!(
|
||||
stdin = password;
|
||||
{
|
||||
let c = cmd!(
|
||||
"podman",
|
||||
if use_sudo {
|
||||
"sudo"
|
||||
} else {
|
||||
"podman"
|
||||
},
|
||||
if use_sudo && has_env_var(SUDO_ASKPASS) => [
|
||||
"-A",
|
||||
"-p",
|
||||
SUDO_PROMPT,
|
||||
],
|
||||
if use_sudo => "podman",
|
||||
"login",
|
||||
"-u",
|
||||
username,
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ pub trait BuildDriver: PrivateDriver {
|
|||
///
|
||||
/// # Errors
|
||||
/// Will error if login fails.
|
||||
fn login() -> Result<()>;
|
||||
fn login(privileged: bool) -> Result<()>;
|
||||
|
||||
/// Runs prune commands for the driver.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ impl BlueBuildCommand for BuildCommand {
|
|||
if self.push {
|
||||
blue_build_utils::check_command_exists("cosign")?;
|
||||
Driver::check_signing_files(&CheckKeyPairOpts::builder().dir(Path::new(".")).build())?;
|
||||
Driver::login()?;
|
||||
Driver::login(self.rechunk)?;
|
||||
Driver::signing_login()?;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ impl BlueBuildCommand for LoginCommand {
|
|||
.build(),
|
||||
);
|
||||
|
||||
Driver::login()?;
|
||||
Driver::login(false)?;
|
||||
Driver::signing_login()?;
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue