From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id DA6646B038 for ; Mon, 25 Jan 2021 14:44:03 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D893EB2AF for ; Mon, 25 Jan 2021 14:44:03 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 57D8DB2A5 for ; Mon, 25 Jan 2021 14:44:03 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 2673245717 for ; Mon, 25 Jan 2021 14:44:03 +0100 (CET) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pbs-devel@lists.proxmox.com Date: Mon, 25 Jan 2021 14:43:02 +0100 Message-Id: <20210125134302.3394328-18-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210125134302.3394328-1-f.gruenbichler@proxmox.com> References: <20210125134302.3394328-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.025 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox-backup-qemu 2/2] use new HttpClientOptions constructors X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jan 2021 13:44:03 -0000 and make password non-optional from the start. Signed-off-by: Fabian Grünbichler --- Notes: needs corresponding proxmox_backup commit 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.20.1