Skip to content

Commit

Permalink
add warning for interactiveSudo usage & update schema
Browse files Browse the repository at this point in the history
  • Loading branch information
n-hass committed Feb 15, 2024
1 parent f269062 commit a395fce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions interface.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
},
"tempPath": {
"type": "string"
},
"interactiveSudo": {
"type": "boolean"
}
}
},
Expand Down
8 changes: 5 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,14 +544,16 @@ async fn run_deploy(
let mut deploy_defs = deploy_data.defs()?;

if node.generic_settings.interactive_sudo.unwrap_or(false) {
info!("Interactive sudo is enabled, you will be prompted for the sudo password for {}.", node.node_settings.hostname);
warn!("Interactive sudo is enabled! Using a sudo password is less secure than correctly configured SSH keys.\nPlease use keys in production environments.");
info!("You will now be prompted for the sudo password for {}.", node.node_settings.hostname);
let sudo_password = rpassword::prompt_password(format!("(sudo for {}) Password: ", node.node_settings.hostname)).unwrap_or("".to_string());

deploy_defs.sudo_password = Some(sudo_password);


// this instructs sudo to hide the password prompt and accept input from stdin
if let Some(original) = deploy_defs.sudo.clone() {
if !original.contains("-S") {
deploy_defs.sudo = Some(format!("{} -S -p \"\"", original));
deploy_defs.sudo = Some(format!("{} -S -p \"\"", original));
}
} else {
deploy_defs.sudo = Some("sudo -S -p \"\"".to_string());
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,9 @@ pub fn make_deploy_data<'a, 's>(
if let Some(activation_timeout) = cmd_overrides.activation_timeout {
merged_settings.activation_timeout = Some(activation_timeout);
}
if let Some(interactive_sudo) = cmd_overrides.interactive_sudo {
merged_settings.interactive_sudo = Some(interactive_sudo);
}

DeployData {
node_name,
Expand Down

0 comments on commit a395fce

Please sign in to comment.