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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 71BA96053D for ; Fri, 5 Feb 2021 16:35:51 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 677AEAE2D for ; Fri, 5 Feb 2021 16:35:51 +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 DC68EAE23 for ; Fri, 5 Feb 2021 16:35:50 +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 A8B17461F3 for ; Fri, 5 Feb 2021 16:35:50 +0100 (CET) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pbs-devel@lists.proxmox.com Date: Fri, 5 Feb 2021 16:35:26 +0100 Message-Id: <20210205153535.2578184-2-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210205153535.2578184-1-f.gruenbichler@proxmox.com> References: <20210205153535.2578184-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.027 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [key.rs, proxmox-backup-client.rs] Subject: [pbs-devel] [PATCH proxmox-backup 01/10] key: make 'default' master key explicit 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: Fri, 05 Feb 2021 15:35:51 -0000 Signed-off-by: Fabian Grünbichler --- src/bin/proxmox-backup-client.rs | 2 +- src/bin/proxmox_backup_client/key.rs | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs index dfb944f0..58f8740d 100644 --- a/src/bin/proxmox-backup-client.rs +++ b/src/bin/proxmox-backup-client.rs @@ -896,7 +896,7 @@ async fn create_backup( let crypt_config = CryptConfig::new(key)?; - match key::find_master_pubkey()? { + match key::find_default_master_pubkey()? { Some(ref path) if path.exists() => { let pem_data = file_get_contents(path)?; let rsa = openssl::rsa::Rsa::public_key_from_pem(&pem_data)?; diff --git a/src/bin/proxmox_backup_client/key.rs b/src/bin/proxmox_backup_client/key.rs index 405cb818..037ee0eb 100644 --- a/src/bin/proxmox_backup_client/key.rs +++ b/src/bin/proxmox_backup_client/key.rs @@ -34,14 +34,14 @@ use proxmox_backup::{ }; pub const DEFAULT_ENCRYPTION_KEY_FILE_NAME: &str = "encryption-key.json"; -pub const MASTER_PUBKEY_FILE_NAME: &str = "master-public.pem"; +pub const DEFAULT_MASTER_PUBKEY_FILE_NAME: &str = "master-public.pem"; -pub fn find_master_pubkey() -> Result, Error> { - super::find_xdg_file(MASTER_PUBKEY_FILE_NAME, "main public key file") +pub fn find_default_master_pubkey() -> Result, Error> { + super::find_xdg_file(DEFAULT_MASTER_PUBKEY_FILE_NAME, "default master public key file") } -pub fn place_master_pubkey() -> Result { - super::place_xdg_file(MASTER_PUBKEY_FILE_NAME, "main public key file") +pub fn place_default_master_pubkey() -> Result { + super::place_xdg_file(DEFAULT_MASTER_PUBKEY_FILE_NAME, "default master public key file") } pub fn find_default_encryption_key() -> Result, Error> { @@ -360,6 +360,9 @@ fn show_key(path: Option, param: Value) -> Result<(), Error> { )] /// Import an RSA public key used to put an encrypted version of the symmetric backup encryption /// key onto the backup server along with each backup. +/// +/// The imported key will be used as default master key for future invocations by the same local +/// user. fn import_master_pubkey(path: String) -> Result<(), Error> { let pem_data = file_get_contents(&path)?; @@ -367,7 +370,7 @@ fn import_master_pubkey(path: String) -> Result<(), Error> { bail!("Unable to decode PEM data - {}", err); } - let target_path = place_master_pubkey()?; + let target_path = place_default_master_pubkey()?; replace_file(&target_path, &pem_data, CreateOptions::new())?; -- 2.20.1