From 0723f448fdad1fcf84ec7ae7d702baba11cb06d1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabian=20Gr=C3=BCnbichler?= Date: Mon, 25 Jan 2021 14:43:02 +0100 Subject: [PATCH] use new HttpClientOptions constructors MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit and make password non-optional from the start. Signed-off-by: Fabian Grünbichler --- src/backup.rs | 7 ++++--- src/lib.rs | 8 +++++--- src/restore.rs | 7 ++++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/backup.rs b/src/backup.rs index b5e1263..e2062e7 100644 --- a/src/backup.rs +++ b/src/backup.rs @@ -107,9 +107,10 @@ impl BackupTask { self.check_aborted()?; let command_future = async { - let options = HttpClientOptions::new() - .fingerprint(self.setup.fingerprint.clone()) - .password(self.setup.password.clone()); + let options = HttpClientOptions::new_non_interactive( + self.setup.password.clone(), + self.setup.fingerprint.clone(), + ); let http = HttpClient::new(&self.setup.host, self.setup.port, &self.setup.auth_id, options)?; let writer = BackupWriter::start( diff --git a/src/lib.rs b/src/lib.rs index b755014..fd7c064 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -134,7 +134,7 @@ pub(crate) struct BackupSetup { pub backup_type: String, pub backup_id: String, pub backup_time: i64, - pub password: Option, + pub password: String, pub keyfile: Option, pub key_password: Option, pub fingerprint: Option, @@ -222,7 +222,8 @@ pub extern "C" fn proxmox_backup_new( let backup_id = tools::utf8_c_string(backup_id)? .ok_or_else(|| format_err!("backup_id must not be NULL"))?; - let password = tools::utf8_c_string(password)?; + let password = tools::utf8_c_string(password)? + .ok_or_else(|| format_err!("password must not be NULL"))?; let keyfile = tools::utf8_c_string(keyfile)?.map(std::path::PathBuf::from); let key_password = tools::utf8_c_string(key_password)?; let fingerprint = tools::utf8_c_string(fingerprint)?; @@ -701,7 +702,8 @@ pub extern "C" fn proxmox_restore_new( let backup_id = snapshot.group().backup_id().to_owned(); let backup_time = snapshot.backup_time(); - let password = tools::utf8_c_string(password)?; + let password = tools::utf8_c_string(password)? + .ok_or_else(|| format_err!("password must not be null"))?; let keyfile = tools::utf8_c_string(keyfile)?.map(std::path::PathBuf::from); let key_password = tools::utf8_c_string(key_password)?; let fingerprint = tools::utf8_c_string(fingerprint)?; diff --git a/src/restore.rs b/src/restore.rs index 1cc99a6..0790d7f 100644 --- a/src/restore.rs +++ b/src/restore.rs @@ -75,9 +75,10 @@ impl RestoreTask { pub async fn connect(&self) -> Result { - let options = HttpClientOptions::new() - .fingerprint(self.setup.fingerprint.clone()) - .password(self.setup.password.clone()); + let options = HttpClientOptions::new_non_interactive( + self.setup.password.clone(), + self.setup.fingerprint.clone(), + ); let http = HttpClient::new(&self.setup.host, self.setup.port, &self.setup.auth_id, options)?; let client = BackupReader::start( -- 2.39.5