refactor password deadlock and password_security

This commit is contained in:
rustdesk
2022-07-30 02:01:40 +08:00
parent cf88ca2bce
commit 125f6dd810
7 changed files with 225 additions and 283 deletions

View File

@@ -171,21 +171,19 @@ fn import_config(path: &str) {
let path2 = std::path::Path::new(&path2);
let path = std::path::Path::new(path);
log::info!("import config from {:?} and {:?}", path, path2);
let mut config: Config = load_path(path.into());
let config: Config = load_path(path.into());
if config.id.is_empty() || config.key_pair.0.is_empty() {
log::info!("Empty source config, skipped");
return;
}
if get_modified_time(&path) > get_modified_time(&Config::file()) {
config.decrypt_password();
if Config::set(config) {
if store_path(Config::file(), config).is_err() {
log::info!("config written");
}
}
let mut config2: Config2 = load_path(path2.into());
let config2: Config2 = load_path(path2.into());
if get_modified_time(&path2) > get_modified_time(&Config2::file()) {
config2.decrypt_password();
if Config2::set(config2) {
if store_path(Config2::file(), config2).is_err() {
log::info!("config2 written");
}
}