feat: run pre_sudo before pre_commands (#1469)
This commit is contained in:
@@ -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
|
||||
|
||||
12
src/main.rs
12
src/main.rs
@@ -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)?
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user