fix: propagate RustDesk password to service profiles
This commit is contained in:
parent
a76c6724f1
commit
aa0d861778
1 changed files with 46 additions and 3 deletions
|
|
@ -104,9 +104,25 @@ pub fn ensure_rustdesk(
|
|||
log_event(&format!("Falha ao definir senha padrão: {error}"));
|
||||
} else {
|
||||
log_event("Senha padrão definida com sucesso");
|
||||
match ensure_password_files(&password) {
|
||||
Ok(_) => log_event("Senha persistida nos perfis do RustDesk"),
|
||||
if let Err(error) = set_verification_method(&exe_path) {
|
||||
log_event(&format!("Falha ao ajustar verification-method via CLI: {error}"));
|
||||
}
|
||||
if let Err(error) = set_approve_mode(&exe_path) {
|
||||
log_event(&format!("Falha ao ajustar approve-mode via CLI: {error}"));
|
||||
}
|
||||
match propagate_password_profile() {
|
||||
Ok(true) => log_event("Perfil de senha propagado para ProgramData/LocalService"),
|
||||
Ok(false) => match ensure_password_files(&password) {
|
||||
Ok(_) => log_event("Senha persistida via fallback nos perfis do RustDesk"),
|
||||
Err(error) => log_event(&format!("Falha ao persistir senha nos perfis: {error}")),
|
||||
},
|
||||
Err(error) => {
|
||||
log_event(&format!("Falha ao copiar perfil de senha: {error}"));
|
||||
match ensure_password_files(&password) {
|
||||
Ok(_) => log_event("Senha persistida via fallback nos perfis do RustDesk"),
|
||||
Err(inner) => log_event(&format!("Falha ao persistir senha nos perfis: {inner}")),
|
||||
}
|
||||
}
|
||||
}
|
||||
match replicate_password_artifacts() {
|
||||
Ok(_) => log_event("Artefatos de senha replicados para o serviço do RustDesk"),
|
||||
|
|
@ -322,6 +338,14 @@ fn set_password(exe_path: &Path, secret: &str) -> Result<(), RustdeskError> {
|
|||
run_with_args(exe_path, &["--password", secret])
|
||||
}
|
||||
|
||||
fn set_verification_method(exe_path: &Path) -> Result<(), RustdeskError> {
|
||||
run_with_args(exe_path, &["--set-verification-method", "use-permanent-password"])
|
||||
}
|
||||
|
||||
fn set_approve_mode(exe_path: &Path) -> Result<(), RustdeskError> {
|
||||
run_with_args(exe_path, &["--set-approve-mode", "password"])
|
||||
}
|
||||
|
||||
fn set_custom_id(exe_path: &Path, machine_id: &str) -> Result<String, RustdeskError> {
|
||||
let custom_id = derive_numeric_id(machine_id);
|
||||
run_with_args(exe_path, &["--set-id", &custom_id])?;
|
||||
|
|
@ -461,6 +485,25 @@ fn ensure_password_files(secret: &str) -> Result<(), String> {
|
|||
}
|
||||
}
|
||||
|
||||
fn propagate_password_profile() -> io::Result<bool> {
|
||||
let Some(src_dir) = user_appdata_config_dir() else {
|
||||
return Ok(false);
|
||||
};
|
||||
let src_path = src_dir.join("RustDesk.toml");
|
||||
if !src_path.exists() {
|
||||
return Ok(false);
|
||||
}
|
||||
let contents = fs::read(&src_path)?;
|
||||
for dest_root in [program_data_config_dir(), PathBuf::from(LOCAL_SERVICE_CONFIG)] {
|
||||
let target_path = dest_root.join("RustDesk.toml");
|
||||
if let Some(parent) = target_path.parent() {
|
||||
fs::create_dir_all(parent)?;
|
||||
}
|
||||
fs::write(&target_path, &contents)?;
|
||||
}
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn replicate_password_artifacts() -> io::Result<()> {
|
||||
let Some(src) = user_appdata_config_dir() else {
|
||||
return Ok(());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue