From 874af9b05bec0bd73a333166a8b5291ecb1c0e3e Mon Sep 17 00:00:00 2001 From: Andrew Fontaine Date: Wed, 26 Jan 2022 22:10:49 -0500 Subject: Add custom sudo command support This is useful for nodes that utilize `doas` instead of `sudo`. --- src/lib.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 981ec1e..39bc3aa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -161,6 +161,7 @@ pub struct CmdOverrides { pub magic_rollback: Option, pub temp_path: Option, pub confirm_timeout: Option, + pub sudo: Option, pub dry_activate: bool, } @@ -350,7 +351,7 @@ impl<'a> DeployData<'a> { let profile_path = self.get_profile_path()?; let sudo: Option = match self.merged_settings.user { - Some(ref user) if user != &ssh_user => Some(format!("sudo -u {}", user)), + Some(ref user) if user != &ssh_user => Some(format!("{} {}", self.get_sudo(), user)), _ => None, }; @@ -392,6 +393,13 @@ impl<'a> DeployData<'a> { }; Ok(profile_user) } + + fn get_sudo(&'a self) -> String { + return match self.merged_settings.sudo { + Some(ref x) => x.clone(), + None => "sudo -u".to_string() + }; + } } pub fn make_deploy_data<'a, 's>( -- cgit v1.2.3