feat: run pre_sudo before pre_commands (#1469)

This commit is contained in:
Andre Toerien
2025-11-11 17:17:00 +02:00
committed by GitHub
parent ec8d30f634
commit bb4afb71e9
2 changed files with 7 additions and 8 deletions

View File

@@ -1607,8 +1607,7 @@ impl Config {
self.config_file.misc.as_ref().and_then(|misc| misc.sudo_command)
}
/// If `true`, `sudo` should be called after `pre_commands` in order to elevate at the
/// start of the session (and not in the middle).
/// If `true`, `sudo -v` should be called to cache credentials at the start of the run
pub fn pre_sudo(&self) -> bool {
self.config_file
.misc

View File

@@ -206,18 +206,18 @@ fn run() -> Result<()> {
None
};
if let Some(commands) = config.pre_commands() {
for (name, command) in commands {
generic::run_custom_command(name, command, &ctx)?;
}
}
if config.pre_sudo() {
if let Some(sudo) = ctx.sudo() {
sudo.elevate(&ctx)?;
}
}
if let Some(commands) = config.pre_commands() {
for (name, command) in commands {
generic::run_custom_command(name, command, &ctx)?;
}
}
for step in step::default_steps() {
step.run(&mut runner, &ctx)?
}